feat(telegraf-patch): allsketches processor (Phase 4 step C) - #237
Merged
Merged
Conversation
… (Phase 4 step C) Implements processors.allsketches per design-asap-telegraf-integration.md. One Telegraf StreamingProcessor with sketch_type config dispatching to asap-precompute-go/sketches/ wrappers. Lifecycle: Start spawns ticker; Add observes via Phase-B codec; Stop drains pending windows. NO build script, NO submodule patch — Phase D separately. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 4, 2026
zzylol
added a commit
that referenced
this pull request
May 5, 2026
The processors.allsketches unified plugin (PR #237) supersedes the older per-sketch aggregator-based attempt at Telegraf integration. Remove the dead scaffolding: - telegraf-patch/plugins/aggregators/{ddsketch,kll,countmin,gorilla,sketchutil}/ - telegraf-patch/plugins/aggregators/all/* (registration overlays) - telegraf-patch/plugins/outputs/gorilla_s3/ (was wired to deleted gorilla) Restore script and build pipeline already skip these per PR #240. Three stale reference comments updated (matched_accuracy/main.go, matched_accuracy/README.md, design-asap-edge-framework.md §7 table). Net: 2420 LoC removed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zzylol
added a commit
that referenced
this pull request
May 5, 2026
The processors.allsketches unified plugin (PR #237) supersedes the older per-sketch aggregator-based attempt at Telegraf integration. Remove the dead scaffolding: - telegraf-patch/plugins/aggregators/{ddsketch,kll,countmin,gorilla,sketchutil}/ - telegraf-patch/plugins/aggregators/all/* (registration overlays) - telegraf-patch/plugins/outputs/gorilla_s3/ (was wired to deleted gorilla) Restore script and build pipeline already skip these per PR #240. Three stale reference comments updated (matched_accuracy/main.go, matched_accuracy/README.md, design-asap-edge-framework.md §7 table). Net: 2420 LoC removed. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
zzylol
added a commit
that referenced
this pull request
May 5, 2026
Phase 5 step C of the OTAP-Rust integration: full asap_sketches plugin lifecycle on top of the Phase B codec. Adds Tokio-driven input task + Wakeup-style flush ticker + control-channel poll task + graceful drain, with 5-sketch dispatch (DDSketch / KLL / HLL / CountSketch / CountMinSketch) selected by the sketch_type config knob, mirroring the Telegraf-side allsketches processor (#237). New code: - src/otap/config.rs: PluginConfig + 5-sketch sketch_type dispatch factory, mapping the user-facing string to (PrecomputeConfig, SketchFactory, SketchObserver). Mirrors Telegraf's toPrecomputeConfig + sketchFactory. - src/otap/records.rs: local OtapMetricRecords model with the bidirectional sibling-batch <-> flat-batch projection that Phase B deferred. flatten() lowers per-row attribute rows into top-level Strategy-B columns the codec consumes; lift() raises Strategy-B columns onto the per-row attribute child batch on emit so OTAP's strict schema validator (crates/pdata/src/schema/payloads.rs:: check_match) accepts the result. The upstream OtapArrowRecords binding lands in Phase D once the OTAP submodule is wired in. - src/otap/lifecycle.rs: AsapSketchesPlugin Tokio runtime — three concurrent tasks (input stream consumer, interval-driven flush ticker, control-channel poll) plus oneshot-driven graceful shutdown that invokes Precompute::drain before exit so terminating before the natural window boundary doesn't drop in-flight observations. - tests/otap_lifecycle.rs: end-to-end harness with one test per sketch_type (5 tests), drain-before-window-boundary test, control-channel plan-change test, plus shutdown smoke tests. Plugin shell scaffolding (Phase D wires the linkme registration): - otap-patch/plugins/asap_sketches/sample.toml: canonical TOML config block. - otap-patch/plugins/asap_sketches/README.md: user-facing config + lifecycle docs. - otap-patch/plugins/asap_sketches/src/mod.rs: placeholder for Phase D's linkme distributed-slice entry. Cargo.toml: tokio (rt + sync + time + macros) and futures gated under the existing `otap` feature; no new top-level features. NOT in this PR (Phase D / E): - build_sketchotap.sh build script. - otap-patch/all/mod.rs linkme registration. - Cross-host envelope parity test. Verification: - cargo test --release -p asap-precompute-rs --features otap: 127 tests pass (was 118; added 9 lifecycle tests). - cargo test --release -p asap-precompute-rs (no features): 88 tests pass — otap-gated code is absent from the default build. - cargo clippy --release -p asap-precompute-rs --features otap --all-targets -- -D warnings: clean. - RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p asap-precompute-rs --features otap: clean. 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
Implements
processors.allsketchesperdocs/design-asap-telegraf-integration.md§3, §5, §6, §8 — a single unified TelegrafStreamingProcessorwhosesketch_typeconfig field dispatches into the existingasap-precompute-go/sketches/<type>wrappers. No build script, no submodule patch — those are Phase D.File layout
telegraf-patch/processors/allsketches/:allsketches.go(203 LoC) —StreamingProcessorimpl:Startvalidates config + spawns flush ticker,Adddecodes via Phase-B codec then callsPrecompute.Observe,Stopdrains pending window withnow+2*windowto force-rotate the tumbling window.config.go(156 LoC) —toPrecomputeConfig/toAdapterConfig/sketchFactorydispatch table mappingsketch_type→ wrapper constructor + observer.factory.go(27 LoC) —processors.AddStreaming("allsketches", …)registration with codec defaults.sample.conf(33 LoC) — canonical[[processors.allsketches]]block.README.md(121 LoC) — user-facing config docs.allsketches_test.go(204 LoC) — lifecycle coverage.go.mod/go.sum— module rooted atgithub.com/influxdata/telegraf/plugins/processors/allsketches, with sibling-checkoutreplacedirectives forasap-precompute-go,sketchlib-go, and the patchedpdata.Dispatch table
sketch_typeddsketchsketches.NewDDSketchWrapper(alpha)sketches.DDSketchObserver{}kllsketches.NewKLLWrapper(k, seed)sketches.KLLObserver{}hllsketches.NewHLLWrapper()sketches.HLLObserver{}countsketchsketches.NewCountSketchWrapper(rows, cols)sketches.CountSketchObserver{DefaultKey}countminsketchsketches.NewCMSWrapper(rows, cols, false)sketches.CMSObserver{}Defaults applied per sketch when unset: ddsketch alpha=0.01, kll k=200, countsketch/cms rows=4 cols=2048.
Test summary
go test -race ./...— all green (1.145s):TestStart_InvalidSketchType— unknownsketch_typerejected atStart.TestStart_InvalidWindow— unparsablewindow_sizerejected atStart.TestDDSketch_HappyPath— Start → 32 scalar Adds → Stop emits envelope-bearing metrics on the accumulator; verifies_asap_envelope_b64field is base64-decodable.TestEnvelopeShortcut— feed pre-aggregated_asap_envelope_b64field, decode-side envelope-shortcut path exercised without value_field.TestStopWithoutStart— Stop is a safe no-op when Start was never called (Telegraf reload race protection).TestAllSketchTypes— loops over all fivesketch_types, each constructs and processes 8 scalars and emits at least one envelope on Stop.Test plan
go build ./...cleango vet ./...cleango test -race ./...all passbuild_sketchtelegraf.shbuilds binary including the registered pluginsketchcollector🤖 Generated with Claude Code