Skip to content

refactor(countsketchprocessor): thin shim delegating to asap-precompute-go (Phase 2 step 2.8) - #229

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

zzylol merged 1 commit into
mainfrom
phase2/countsketch-shim

Conversation

@zzylol

@zzylol zzylol commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • CountSketch processor reduces from ~663 LoC processor.go to a thin shim. State machine (windowing, snapshot caching, delta encoding) moves to asap-precompute-go.
  • sketch_wrapper.go implements precompute.Sketch + precompute.FrequencySketch (EstimateCount, TopK) over the sketchlib-go CountSketch.
  • Per-config flags GlobalAggregation=true, OmitResourceAttrs=true, EmitWindowStats=true, fixed MetricName=countsketch_partition preserve the legacy single-partition emit shape with sample_count and window_duration_seconds attrs.
  • Single Precompute instance suffices because GlobalAggregation collapses every observation into one shared series — no per-metric map is needed.
  • Public test API per ADR-0002 §"Test API contract": Shim.ProcessBatch, Shim.ProcessMetrics, Shim.FlushWindow.
  • delta_transmission_test.go TestCSDelta_MultipleWindowsConvergence updated to apply each delta against the cached baseline (the runtime's SnapshotCache.ComputeDelta keeps outbound at the prior baseline whenever delta stays under threshold) instead of the previously-reconstructed sketch.

Phase 2 step 2.8.

Test plan

  • cd opentelemetry-collector-contrib-patch/processor/countsketchprocessor && go test ./... passes
  • cd integration/parity && go test -v -run TestParity_CountSketch ./... parity OK: 1 envelope byte-identical
  • cd integration/parity && go test ./... (full parity suite) passes

🤖 Generated with Claude Code

…te-go

CountSketch processor reduces from ~663 LoC to a thin shim. State
machine moves to asap-precompute-go. sketch_wrapper.go implements
FrequencySketch over sketchlib-go CountSketch.

GlobalAggregation + EmitWindowStats config flags preserve legacy
single-partition emit shape with sample_count / window_duration_seconds
attrs.

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

Parity harness: TestParity_CountSketch byte-identical (1 envelope).

Phase 2 step 2.8.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit fa64b10 into main May 4, 2026
@zzylol
zzylol deleted the phase2/countsketch-shim branch May 4, 2026 13:34
zzylol added a commit that referenced this pull request May 4, 2026
…n sketch wrappers (#232)

Correct SnapshotCache semantics — every ComputeDelta updates the cached
snapshot, matching all 5 legacy OTel processors. The previous
"refresh-only-on-full" path was a design error; no configurable policy
knob is needed because there's only one correct behavior.

Extract platform-independent sketch wrappers (DDSketch, KLL, HLL,
CountSketch, CountMinSketch) into asap-precompute-go/sketches/ so
Telegraf / Vector / OTAP adapters can reuse them.

Document delta-snapshot semantics in design doc.

Note: PR #229 (CountSketch) and PR #230 (CMS) workaround in
shim_helpers.go::applyDeltaTransmission becomes redundant after this
lands; those PRs can rebase to drop the workaround.

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