Skip to content

feat(asapedgeprocessor): accept per-metric sample_p in fused asap_edge + sample HLL/CMS - #444

Merged
zzylol merged 1 commit into
mainfrom
fix/asapedge-fused-sample-p
May 26, 2026
Merged

zzylol merged 1 commit into
mainfrom
fix/asapedge-fused-sample-p

Conversation

@zzylol

@zzylol zzylol commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Activating sampling crash-looped the edge collector: the control plane emits a per-metric sample_p into the FUSED asap_edge processor's config (set when a metric's workload sample_p < 1), but the fused per-metric config struct didn't define the key, so the collector's strict mapstructure decode rejected it (metrics[N] has invalid keys: sample_p) and crashed. A prior PR (feat(sketches): per-metric sample_p knob on the CMS + HLL warm processors #441) added SampleP only to the NON-fused hll/countminsketch processors; the deploy runs ASAP_EDGE_FUSED=1.
  • Add SampleP float64 \mapstructure:"sample_p"`toMetricFamily(the fused per-metric struct) inconfig.go, validated to (0,1]with0/unset normalised to 1.0` (sampling disabled).
  • Wire it into the warm sketch-build (sketch.go newSketchAggregator): the HLL and CountMinSketch factories call sketchlib-go's WithSampleP(p). WithSampleP(1.0) is an exact no-op, so the unset/1.0 path stays byte-identical to today. DDSketch/KLL/CountSketch (no sampling support) ignore it. Mirrors the standalone processors' wiring from feat(sketches): per-metric sample_p knob on the CMS + HLL warm processors #441.
  • Backend already reads sample_p off the SketchEnvelope and rescales by 1/p at query, so the agent just needs to accept the key and build the sketch with the probability.

Files / functions touched (for merge-coordination with the cold-density agent)

Scoped to the warm path only — the cold/gorilla feed path is untouched:

  • config.go — MetricFamily struct (+SampleP field); Config.Validate() (+(0,1] normalise/validate loop).
  • sketch.go — newSketchAggregator() (apply WithSampleP to HLL/CMS factories; retain factory on sketchAggregator for test observability).
  • sample_p_path_test.go — new test file.
  • go.mod/go.sum — add confmap (test-only, for the strict-decode regression).

Test plan

  • go build ./..., go vet ./..., gofmt -l clean
  • New sample_p_path_test.go:
    • TestFusedConfigSamplePDecodes — a fused config with sample_p on HLL/CMS metrics decodes through the real strict confmap path WITHOUT the crash; values populate; unset normalises to 1.0.
    • TestFusedSketchBuildAppliesSampleP — the built HLL/CMS sketch has SampleP()==0.5 with sample_p: 0.5, and 1.0 (no sampling) when unset; DDSketch ignores the knob.
    • TestFusedConfigSamplePRejectsOutOfRange — out-of-range sample_p rejected at Validate.
  • Full package suite passes (no pre-existing processor_test.go pdata-skew in this checkout)

🤖 Generated with Claude Code

…e + sample HLL/CMS

The fused asap_edge processor's per-metric config struct did not define
sample_p, so the collector's strict mapstructure decode rejected the key
the control plane emits when a metric's workload sample_p < 1, crash-looping
the agent. Add SampleP to MetricFamily (validated to (0,1], 0/unset => 1.0 =
no sampling) and wire it into the warm sketch-build: HLL and CountMinSketch
factories call sketchlib-go's WithSampleP(p). WithSampleP(1.0) is an exact
no-op, so the unset/1.0 path stays byte-identical to today. DDSketch/KLL/
CountSketch (no sampling support) ignore it. Mirrors the standalone
hll/countminsketch processors' sample_p wiring (#441) for the fused path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit e4b9d94 into main May 26, 2026
@zzylol
zzylol deleted the fix/asapedge-fused-sample-p branch May 26, 2026 11:33
zzylol added a commit that referenced this pull request Aug 27, 2026
…redesign

ASAPPlanner's post-ASAP IR (crates/types/src/post_asap) selects a
candidate logical DAG (SummaryAgg/summary family+algorithm+params/
Reduction/SummaryEstimate) and, per its own README "Scope" and
asap-aware-mapping/README.md "Non-Goals", explicitly does not choose
collector/backend placement, transport mode, or physical resources. Note
in Purpose that the ASAPQuery-backend control plane compiles that
selection - it does not serialize it directly - into this document's
collector configuration and a companion backend configuration sharing one
plan identity, and link ASAPQuery-backend PR #444's new
design-compiled-plan-collector-backend-split.md for that compile step.

Point the existing "Current contract gap" section (no plan_id/version/
activation/expiry/backend-compat on this wire) at that same design as the
proposed closing mechanism, without claiming any of it is implemented
here yet - the OpAMP envelope encoding for those fields is still an open
question in that design, to be resolved and documented in this file once
it lands.

Co-Authored-By: Claude Sonnet 5 <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