feat(asap-precompute-go): telegraf codec (Phase 4 step B) - #234
Merged
Merged
Conversation
….Metric Implements Phase B of the Telegraf integration plan in docs/design-asap-telegraf-integration.md. The codec translates telegraf.Metric ↔ Observation / SketchEnvelope, mirroring the OTel codec in asap-precompute-go/otel. Single-field decode (configurable ValueField); base64-envelope shortcut for pre-aggregated upstream sketches. Encode emits the envelope as a single base64-encoded field for binary-clean transport through Telegraf's outputs. NO plugin code — Phase C separately. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
May 5, 2026
Adds the Layer-4 OTAP-Rust codec at `asap-precompute-rs/src/otap/`, gated behind the non-default `otap` Cargo feature. Mirrors the two-layer split pinned by `docs/design-asap-otap-rust-integration.md` §2 and the Phase-4 Telegraf codec (PR #234) in shape: pure data-shape translation between `arrow::RecordBatch` and the host-neutral `Observation` / `SketchEnvelope` types, no Tokio tasks, no timers, no control-channel inbox. Lifecycle (Wakeup-driven flush, control channel, linkme registration) is Phase C and explicitly deferred. The Strategy-B carrier keys (_asap_envelope, _asap_sketch_type, etc.) are defined as constants matching edge-framework §7.2's table byte-for-byte so cross-platform interop holds. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Phase B of the Telegraf integration plan in
docs/design-asap-telegraf-integration.md:the
asap-precompute-go/telegraf/codec. Pure data-shape translationbetween
telegraf.Metricand the host-neutralObservation/SketchEnvelope, mirroringasap-precompute-go/otel.In scope
decode.go—Decode(metric, cfg) (*Observation, error). Readscfg.ValueFieldas a float (KindFloat), or routes throughcfg.EnvelopeField(default_asap_envelope_b64) as apre-aggregated
SketchEnvelopeshortcut (KindEnvelope). Returnstyped errors for missing / non-numeric value fields and malformed
envelope payloads. Tags are sorted by key for stable series-key
hashing — same contract as the OTel codec.
encode.go—Encode([]*SketchEnvelope, cfg) ([]telegraf.Metric, error).One emitted metric per envelope;
env.MetricNameas Name (withcfg.OutputMetricNamefallback);env.ResourceLabelsflattened intoTags alongside
env.Labels(last-write semantics on collision sodata-point Labels win); single field whose value is
base64(JSON(SketchEnvelope)); timestamp fromWindowEndMs(falling back to
WindowStartMs, thentime.Now()).adapter.go— thinAdapterstruct wrapping the package-levelhelpers; mirrors
otel.Adaptershape but does NOT implementprecompute.Adapter(no goroutines / tickers — those live in thePhase C plugin).
config.go—AdapterConfigwithValueField,EnvelopeField,OutputMetricNameplusDefaultAdapterConfig().Out of scope (deferred)
telegraf-patch/processors/allsketches/plugin(StreamingProcessor, flush ticker, control-channel goroutine,
config translation). Not touched in this PR.
build_sketchtelegraf.sh+ Telegraf submoduleregistration patch.
sketchcollector.value_fieldonly per design doc§10).
asapTelegraf serializer (separate PR per design §4).Test coverage
go test ./telegraf/...runs 22 tests covering:KindFloat.KindEnvelope,scalar field ignored.
back to scalar path.
timestamp from
WindowEndMs.cfg.OutputMetricName.ResourceLabelsinto Telegraf tags.EnvelopeFieldconfig → error (data-loss prevention).time.Now().WindowStartMsfallback whenWindowEndMsis zero.Decode/Encodewrap helpers.field-by-field assertion).
go build ./...,go vet ./...,go test ./...all green; existingotel/and runtime tests unchanged.Dependencies
Adds
github.com/influxdata/telegraf v1.34.4as a direct dep (pinnedto a release that matches the project's existing
go 1.24.0directive — newer 1.36+ telegraf releases require Go 1.25+, which
would force a toolchain bump that's out of scope here). Tidy left the
indirect-dep tree unchanged except for one zeebo/assert patch bump
that telegraf brought along — net diff is 1 require line in
go.modand ~6 lines ofgo.sum. Telegraf does NOT pull in a heavytransitive tree at this code-import depth (we only use
telegraf.Metricandmetric.New).Test plan
go build ./...fromasap-precompute-go/go vet ./...go test ./telegraf/...(22 PASS)go test ./...(all packages green; existingotel//controlchannel//sketches/tests still pass)StreamingProcessor— that's where end-to-end correctness isproven; this PR alone doesn't gate on a sketchtelegraf binary
build.
🤖 Generated with Claude Code