Skip to content

refactor(kllprocessor): thin shim delegating to asap-precompute-go (Phase 2 step 2.6) - #226

Merged
zzylol merged 1 commit into
mainfrom
phase2/kll-shim
May 4, 2026
Merged

zzylol merged 1 commit into
mainfrom
phase2/kll-shim

Conversation

@zzylol

@zzylol zzylol commented May 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactors opentelemetry-collector-contrib-patch/processor/kllprocessor/processor.go from a ~720 LoC state machine into a ~150 LoC shim that delegates window / series-keying / snapshot logic to github.com/ProjectASAP/asap-precompute-go.
  • Adds sketch_wrapper.go implementing precompute.QuantileSketch over *kll.KLLSketch from sketchlib-go (Snapshot/ApplyDelta/Merge/Reset/Quantile). Honors Config.Seed (PR test(integration/parity): all-sketch e2e parity harness #225) so deterministic-replay tests pin compaction RNG.
  • Config.toPrecomputeConfig() translates legacy fields → host-neutral PrecomputeConfig, pinning OmitResourceAttrs=true, EmitWindowStats=false, and threading the metric-name suffix through the shim's encode path (the runtime's MetricName is static-per-Precompute; the shim partitions by input metric name).
  • Public test API per ADR-0002 §"Test API contract": Shim.ProcessBatch, ProcessMetrics, FlushWindow. Existing tests adapted by capitalizing flushWindowFlushWindow (sed-style rename); no test logic changes.

File layout (all under opentelemetry-collector-contrib-patch/processor/kllprocessor/)

File Code LoC Role
processor.go 153 Lifecycle + ConsumeMetrics + test API hooks
encode.go 84 Typed-sketch / per-quantile pmetric encode helpers
selfmonitor.go 39 OTel telemetry-channel wiring (unchanged from legacy)
sketch_wrapper.go 140 *kll.KLLSketchprecompute.QuantileSketch adapter

Test plan

  • go test -race ./... in opentelemetry-collector-contrib-patch/processor/kllprocessor/ — all 16 existing tests pass under race detector.
  • Parity gate: go test -v -run TestParity_KLL ./... in integration/parity/ — PASS, 3 envelopes byte-identical to legacy emit.
  • Sibling parity tests (TestParity_DDSketch, TestParity_HLL, TestParity_CountSketch, TestParity_CountMinSketch) all still PASS — the shim refactor does not regress unrelated sketches.
  • asap-precompute-go test suite still green (no source changes there).

Behavior preservation (ADR-0002)

  • Wire format byte-identical (parity gate, 3 envelopes).
  • Window semantics unchanged — Tumbling for mode: window, Batch for mode: batch.
  • Series-key shape unchanged: per-input-metric Precompute partitioning preserves the legacy metricWindow boundary; OmitResourceAttrs=true keeps the dp-attrs-only key the legacy KLL processor used.
  • Output metric naming unchanged: <input>_kll (TransmitSketch) or <input>{MetricSuffix}_p<NN> (quantile gauge).
  • MutatesData: true preserved (batch path appends synthesized RMs onto input md before forwarding, matching legacy).

🤖 Generated with Claude Code

KLL processor reduces from ~720 LoC to ~120 LoC shim. State machine
moves to asap-precompute-go. sketch_wrapper.go implements QuantileSketch
over sketchlib-go KLL. Config.Seed (added in PR #225) flows through.

Public test API: Shim.ProcessBatch/ProcessMetrics/FlushWindow.

Parity harness: TestParity_KLL byte-identical (3 envelopes).

Phase 2 step 2.6.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit dbf8fa9 into main May 4, 2026
@zzylol
zzylol deleted the phase2/kll-shim branch May 4, 2026 13:31
zzylol added a commit that referenced this pull request May 4, 2026
Each Phase-2 shim depends on github.com/ProjectASAP/asap-precompute-go,
a sibling private module with no module-proxy presence. Mirror the
sketchlib-go replace pattern so OCB resolves it to the local checkout.

Without this, the multi-plugin sketchcollector binary fails to build
once any shim PR (#226-#230) merges.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant