Repository navigation
feat(metrics): add programmable metric pipeline IR, single-region engine, and live generations - #3424
lukesteensen wants to merge 0 commit into
Conversation
Binary Size Analysis (Agent Data Plane)Baseline: 70e6f7a · Comparison: a38d3c9 · diff ✅ Binary size difference within thresholdChanges by Module
Detailed Symbol Changes |
Regression Detector (Agent Data Plane)Run ID: Optimization Goals: ✅ No significant changes detectedFine details of change detection per experiment (5)Experiments configured
Bounds Checks: ✅ Passed (5)
ExplanationA change is flagged as a regression when |Δ mean %| > 5.00% in the regressing direction for its optimization goal AND SMP marks the experiment as a regression ( |
4e4d129 to
c0cdb35
Compare
68bca9f to
e8e6d6d
Compare
b42546b to
a6ee440
Compare
e8e6d6d to
05ec4b1
Compare
a6ee440 to
a38d3c9
Compare
05ec4b1 to
86a3bac
Compare
a38d3c9 to
cdb3820
Compare
4518b03 to
ce306ec
Compare
cdb3820 to
ce306ec
Compare
…ransform-kernels` (#3427) Peels off Phase 1 from #3424 as a purely mechanical, zero-behavior-change extraction. Extracts deterministic, zero-async transformation domain logic into a new `lib/saluki-transform-kernels` crate (named to avoid overlap with `saluki-metrics` and accommodate future non-metrics transformation kernels) and delegates the existing components in `lib/saluki-components` and `bin/agent-data-plane/src/components/` as thin wrappers: 1. `metric_name`, `histogram`, and `filterlist` (`Blocklist`, `PrefixFilterKernel`, `PostAggregateFilterKernel`) 2. `routing_filter` (`MetricAllowlistKernel`, `MetricMirroring`, `compact_metric_prefixes`) 3. `timestamp_split` and `host_tags` (`HostTagsKernel`) 4. `tag_filter` (`TagFilterKernel`) 5. `mapper` (`MapperKernel`) 6. `aggregate` (`AggregateCore<M>`, `extract_closed_values`, `expand_flushed_metric`) Verified with `cargo check --workspace --tests`, `cargo clippy --workspace --all-targets -- -D warnings`, `make check-unused-deps`, `saluki-transform-kernels` unit tests, `architecture-tests`, and end-to-end Panoramic suites (via #3424). Co-authored-by: luke.steensen <luke.steensen@datadoghq.com>
…ransform-kernels` (#3427) Peels off Phase 1 from #3424 as a purely mechanical, zero-behavior-change extraction. Extracts deterministic, zero-async transformation domain logic into a new `lib/saluki-transform-kernels` crate (named to avoid overlap with `saluki-metrics` and accommodate future non-metrics transformation kernels) and delegates the existing components in `lib/saluki-components` and `bin/agent-data-plane/src/components/` as thin wrappers: 1. `metric_name`, `histogram`, and `filterlist` (`Blocklist`, `PrefixFilterKernel`, `PostAggregateFilterKernel`) 2. `routing_filter` (`MetricAllowlistKernel`, `MetricMirroring`, `compact_metric_prefixes`) 3. `timestamp_split` and `host_tags` (`HostTagsKernel`) 4. `tag_filter` (`TagFilterKernel`) 5. `mapper` (`MapperKernel`) 6. `aggregate` (`AggregateCore<M>`, `extract_closed_values`, `expand_flushed_metric`) Verified with `cargo check --workspace --tests`, `cargo clippy --workspace --all-targets -- -D warnings`, `make check-unused-deps`, `saluki-transform-kernels` unit tests, `architecture-tests`, and end-to-end Panoramic suites (via #3424). Co-authored-by: luke.steensen <luke.steensen@datadoghq.com> 6c8f2e2
…hind `FlushCursor` (#3641) ## Summary `AggregateCore` in `saluki-transform-kernels` currently exposes `contexts_and_remove_buf_mut`, `pending_removals`, `AggregatedMetric`, `FlushWindow`, `extract_closed_values`, and `expand_flushed_metric` so `AggregateState::flush` can iterate the internal `HashMap` directly across `dispatcher.push(...).await`. This follow-up PR encapsulates the internal storage and flush mechanics behind an opaque `FlushCursor` API: - Add `AggregateCore::begin_flush`, `AggregateCore::flush_chunk`, and `AggregateCore::finish_flush`. - Add `AggregateCore::entry_size_bytes()` so callers account for memory bounds without depending on `AggregatedMetric`. - Keep `AggregatedMetric`, `FlushWindow`, `extract_closed_values`, and `expand_flushed_metric` private inside `saluki-transform-kernels::aggregate`. - Re-check emptiness in `finish_flush` before removing pending contexts so samples inserted between flush chunks are never dropped. - Update `lib/saluki-components/src/transforms/aggregate/mod.rs` to drive flushes in bounded 1,024-context chunks and drop the mutable borrow on `AggregateCore` before awaiting downstream dispatch. This keeps #3427 strictly mechanical while giving future dense aggregate storage (#3496) and interleaved resumable flushes (#3499) a clean crate boundary. ## Change Type - [ ] Bug fix - [ ] New feature - [x] Non-functional - [ ] Performance ## How did you test this PR? - `cargo check --workspace --tests` - `cargo clippy -p saluki-transform-kernels -p saluki-components --all-targets -- -D warnings` - `cargo nextest run -p saluki-transform-kernels` (34/34 passed, including `chunked_flush_cursor_matches_full_flush_and_preserves_interleaved_inserts`) - `cargo nextest run -p saluki-components -E 'test(transforms::aggregate)'` (41/41 passed) - `make fmt` ## References - Stacked on: #3427 (`programmable-phase1-metric-kernels`) - Required by: #3424 (`programmable-exploration`) Co-authored-by: luke.steensen <luke.steensen@datadoghq.com>
Summary
This draft PR is the core programmable metrics baseline (Phases 2–5 + RAR telemetry), stacked directly on Phase 1 (#3427) so its diff contains only the new IR, compiled single-region engine, live generation switching, RAR telemetry, and dynamic delivery preview—without repeating Phase 0 or Phase 1.
PR Stack
main, 2 commits)saluki-transform-kernels#3427 — Phase 1 pure metric kernelssaluki-metric-kernels(base:main, 6 commits)programmable-phase1-metric-kernels, 11 commits)programmable-exploration, 1 commit)Why
Today ADP's metrics path fans across 6–10 separate Tokio transform tasks connected by
EventsBufferchannels (mapper -> prefix_filter -> no_agg_split -> tag_filterlist -> aggregate -> post_agg_filter -> host_tags -> route_filter). That makes whole-pipeline reasoning, live topology updates, and cross-stage optimization difficult, and adds task/channel/memory overhead on production containers (0.05–1.2CPUs).Building on the pure kernels in #3427, this PR lowers native
datadog.yamlconfig into a small whole-program IR (MetricPlan) and executes it in one compiled region:agent-data-plane debug explain-metrics-plan [--json], static telemetry-contract warnings, and fast in-process deterministic simulation (proptest).-28%..-34%CPU,-65%..-88%RSS).Commit Reading Guide (11 linear commits on top of #3427)
explain(3 commits):1bdd240587:lib/saluki-metric-plantyped DAG IR (policy as literals; host tags & operational signals as runtime bindings), declarative effect contracts, validator, and static telemetry-contract analyzer.57f6f71e1a: Deterministic single-threadedReferenceInterpretersupporting 0, 1, or N statefulAggregateoperators.7dbd0adddf: NativeSalukiConfigurationlowering,explain_plan, offlineagent-data-plane debug explain-metrics-plan [--json], and native-vs-interpreter differential tests.d9f315401f: Dead-node / constant-drop optimizer, flat compiledFusedMetricEngine, andproptestengine-vs-interpreter simulation.7837a48a41:MetricRegionTransformhostingFusedMetricEnginein a single Tokio task.0df8da30c4: Boot-time flagexperimental.programmable_metrics.enabled(defaultfalse) wiringSources -> metrics_region -> Encoders.c2b7d0357d: Admission stamping, semantic plan diffing, atomic stateless swaps, exact LCM bucket-boundary cuts (single- and multi-stage chained aggregates, safe against backward clock skew), rollback, andproptestcut-conservation simulation.9f69e9e90d: Live native reloads (metric_filter,tag_filterlist, MRFmetric_mirroring),expected_tags_durationexpiry,dogstatsd topcontext snapshots, firmMemoryBounds, invalid-mapper degradation parity, JMX-over-DogStatsD stream classification, and 3-way differential matrix tests.a57ad2e477: Hot-path polish (~50 lines): reusable scratch buffers, zero-copymove_batchheader swaps, non-timestampedTimestampSplitfast path, 1024-metric chunked flushes with 256-slot retained buffer caps, and a bounded per-context cache inTagFilterKernel(declared inspecify_bounds).cef0cb0cf9:DeliveryHost(lib/saluki-components/src/forwarders/delivery_host.rs) demonstrating live recipient add, in-place API-key rotation, transport replacement with graceful drain, failover routing, and task reclamation. (Not yet wired intoDatadogForwarder.)c0cdb35610: Per-operator RAR-compatible telemetry (aggregator.*,filterlist.*,tag_filterlist.*,dogstatsd.listener_filtered_points,no_aggregation.*) accumulated as plainu64s insidesaluki-metric-plan(zerosaluki-metricscoupling) and published once per batch/flush inMetricRegion.Verification
cargo check --workspace --tests&cargo clippy --workspace --all-targets -- -D warnings— 0 warningssaluki-metric-kernels+saluki-metric-plan(includingproptestrandomized engine & cut-conservation simulations) +architecture-tests— 80/80 passedagent-data-plane(including value-exact 3-way native vs. interpreter vs.MetricRegionTransformdifferential tests) — 353/353 passedsaluki-components(metric_region,delivery_host) — 8/8 passedDD_EXPERIMENTAL_PROGRAMMABLE_METRICS_ENABLED=true):dsd-origin-detection-matrix-*skipped locally due to nokind.)dogstatsd-top,dogstatsd-invalid-mapper-profile, strict memory bounds, RAR registration, and liveness).Local A/B Benchmark (Native vs. Programmable Baseline, same release image)
Measured on Linux Docker containers under both production-like
--cpuscgroup limits and 4-core SMP using the exact SMPladingtraffic profiles (DD_EXPERIMENTAL_PROGRAMMABLE_METRICS_ENABLED=falsevs.true):idle@0.3CPU0.006 → 0.005cores (-6.6%)30.6 → 30.3(-0.9%)30.6 → 30.3(-0.9%)dsd 1 MiB/s, 3k ctx@0.3CPU0.022 → 0.020cores (-7.7%)53.9 → 51.1(-5.2%)53.9 → 51.1(-5.2%)dsd 10 MiB/s, 10k ctx@0.6CPU (60s)0.081 → 0.078cores (-4.0%)76.1 → 69.1(-9.2%)76.9 → 74.0(-3.8%)otlp 5 MiB/s@0.6CPU (30s, sat.)6.55 → 6.52 MiB/s(-0.5% ingress)886.7 → 890.6(+0.4%)886.7 → 890.6(+0.4%)dsd 100 MiB/s, 3k ctx@4.0CPU (SMP)0.504 → 0.499cores (-1.1%)78.8 → 68.6(-13.0%)78.8 → 71.5(-9.3%)routing dual-ship 500 MiB/s@1.2CPU (30s, sat.)366.4 → 369.1 MiB/s(+0.7% ingress)52.8 → 54.4(+3.0%)59.4 → 61.0(+2.8%)mapper profiles 10 MiB/s, 3k ctx@1.2CPU (30s)0.062 → 0.058cores (-6.4%)44.0 → 42.5(-3.5%)54.1 → 52.1(-3.8%)tagfilter 1k rules 100 MiB/s, 78k ctx@4.0CPU0.760 → 0.742cores (-2.4%)274.7 → 259.8(-5.4%)318.5 → 320.8(+0.7%)tagvalue 10k rules 100 MiB/s, 78k ctx@4.0CPU0.784 → 0.749cores (-4.5%)310.2 → 312.4(+0.7%)343.4 → 343.1(-0.1%)tagvalue 1r repl25 100 MiB/s, 78k ctx@4.0CPU0.783 → 0.738cores (-5.8%)243.8 → 241.2(-1.1%)288.6 → 287.1(-0.5%)(See #3440 stacked on top for whole-program blocklist pushdown results: -28% to -34% CPU and -65% to -88% RSS.)
Sample
agent-data-plane debug explain-metrics-planoutputKnown Gaps (Intentionally Deferred Pending Alignment)
aggregate_active_contexts_by_origin): main RAR telemetry (aggregator.*,filterlist.*,tag_filterlist.*,no_aggregation.*) is now wired; origin-breakdown active-context gauges can follow cleanly if needed.MetricRegionstill collects a flush tick's emitted metrics before callingdispatch_emitted(fine at 3k–10k contexts, adds peak memory at 78k–250k contexts).dsd-origin-detection-matrix-*, and live Remote Config churn against Core Agent.DeliveryHostintoDatadogForwarder, external program installation / panic containment, and Remote Config authoring format.Questions for Maintainers
MetricRegionseparates DogStatsD (including JMX-over-DogStatsD) from passthrough sources viaSome(MetricOrigin::OriginMetadata { .. }). Should production use explicit multi-input ports onTransform(pairs well with the typed-Eventbreakup discussion) or side-carried stream identity?u64deltas insidesaluki-metric-planand publishing viaRegionTelemetryEmitterkeyed by logicalNodeIdfeel like the right separation?validate_planstrictly fail-closed while handling Datadog-Agent-compatible startup degradation (e.g., invaliddogstatsd_mapper_profiles) insidenative_pipeline_configfeel like the right split?saluki-transform-kernels#3427) first, then reviewing this baseline (feat(metrics): add programmable metric pipeline IR, single-region engine, and live generations #3424) and pushdown (perf(dogstatsd,metric-plan): push whole-program blocklist drop predicate into DogStatsD ingress #3440), make sense as the ramp path?