feat(asap-precompute-go): bootstrap module + types + window + snapshot cache + OTel adapter (Phase 2 steps 2.1-2.4) - #219
Merged
Conversation
…t cache + OTel adapter (Phase 2 steps 2.1-2.4)
Brings in the host-neutral edge-precompute runtime per ADR-0002 and
ADR-0003. Layer-3 owns Observation / SketchEnvelope / windowing /
delta-encoding; Layer-4 OTel adapter implements Decode/Encode against
pmetric.Metrics. Steps 2.5-2.11 (per-shim refactor + ControlChannel
implementations) are out of scope.
Source files:
- observation.go / envelope.go: host-neutral input + output types,
Encoding enum, SketchType enum, KeyValue, ResourceLabels.
- config.go: PrecomputeConfig + PrecomputeConfigSet (versioned plan),
AggregationMode / OnOverflow / WindowSpec / SketchParams /
Encoding / Quantiles fields.
- matchers.go: SeriesKey / AttributesKey byte-equivalent to today's
per-OTel-processor seriesKey/attributesKey output.
- precompute.go: Precompute interface + impl, Sketch interface,
Observe / ObserveEnvelope / Tick / UpdateConfig / Stats /
Shutdown.
- window.go: tumbling windowState, OnOverflow{Drop,EvictOldest}
policies, AllowedLateness drop, ResourceLabels propagation,
observeEnvelope merge / apply-delta path.
- snapshot_cache.go: outbound (delta source-of-truth) + inbound
(apply-delta target) caches with first-time / above-threshold
semantics.
- telemetry.go: PrecomputeStats atomics + StatsSnapshot.
- adapter.go: Adapter interface (Decode/Encode/ScheduleTick/
EmitTelemetry).
- controlchannel/channel.go: ControlChannel trait only; impls land
in step 2.10.
- otel/{config,seriesattrs,decode,encode,adapter}.go: OTel-typed
Adapter implementing precompute.Adapter against pmetric.Metrics;
TransmitSketch=true output mode (quantile-output deferred to
Phase 2.5).
Tests (46 cases, all green under -race):
- byte-equivalence regression for SeriesKey vs today's
ddsketchprocessor::seriesKey + ::attributesKey (5 fixtures).
- end-to-end Tumbling rotate, late-data drop, MaxSeries Drop +
EvictOldest, ResourceLabels propagation.
- snapshot cache: first-full / subsequent-delta / above-threshold-
refresh / inbound round-trip / Reset.
- Precompute: full Observe→Tick path, DeltaTransmission state
machine (PROTO_FULL → PROTO_DELTA → PROTO_FULL on threshold),
UpdateConfig atomic swap, Stats accounting.
- OTel adapter: Decode for Gauge / Sum / DDSketch (envelope
preservation, no scalar expansion), Encode grouping by
ResourceLabels, MetricSuffix / MetricName, default scope name,
delta encoding round-trip.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 2, 2026
fix(processors): unbreak baselines - DataDog->sketchlib-go fixtures + post-#211 sink assertions
#220
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bootstraps
asap-precompute-go/— the host-neutral edge-precompute runtime described indocs/design-asap-edge-framework.mdand pinned by ADR-0002 and ADR-0003. This is Phase 2 steps 2.1-2.4 only.Observation/SketchEnvelope/Encoding/SketchType/KeyValuetypes;PrecomputeConfig+PrecomputeConfigSet; tumbling-onlywindowStatewith MaxSeries/AllowedLateness; outbound + inboundSnapshotCache;Precomputeinterface + impl driving Observe/ObserveEnvelope/Tick/UpdateConfig/Stats/Shutdown;Sketch+SketchObserverinterfaces for Layer-1 wrappers (steps 2.5-2.9).otel.Adapterimplementsprecompute.Adapteroverpmetric.Metrics—Decodeproduces host-neutral Observations (Gauge/Sum → KindFloat; DDSketch/KLL/HLL/CountSketch/CountMinSketch → KindEnvelope, no scalar expansion);Encodegroups envelopes by ResourceLabels and emits typed sketch metrics;MetricSuffix/MetricName/ReadAsInt/WriteSeen/DropOriginalknobs from the feasibility audit.controlchannel/ControlChannelinterface only — implementations (OpAmpChannel/HttpPollChannel/FileWatchChannel) land in step 2.10.TestSeriesKey_ByteEquivalence(5 fixtures) checks thatSeriesKey(aggID, resAttrs, dpAttrs, aggregateBy)is byte-identical to today's per-OTel-processorseriesKey + attributesKeyoutput, so the snapshot cache survives the runtime extraction (ADR-0002 "Behavior preservation").Out of scope (deferred follow-ups)
TransmitSketch=false→ emit one gauge per quantile). Encode currently requires the runtime to keepTransmitSketch=true. The encode boundary doesn't have a Sketch instance to query — Phase 2.5 follow-up.Test plan
go vet ./...— clean.go build ./...— clean.go test ./... -race -count=1— 46 cases, all PASS.gofmt -l .— empty (using Go 1.25.3 toolchain).precompute.New(...)and verify byte-level snapshot-cache continuity against pre-existing windows.ControlChanneland confirmsUpdateConfigswaps the active plan without dropping in-flight observations.🤖 Generated with Claude Code