feat(aggregate transform): Add `set_interval_ms` option #26597
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #26597"
general
weight: 0.35
clreaume
Summary
This PR adds an opt-in
set_interval_msoption (defaultfalse) to theaggregatetransform. When the option is on, each incremental metric that a flush emits getsinterval_msset to the configured flushinterval_ms. Downstream components can then read an aggregated counter as a rate over the window. For example,datadog_metricssends counters that have an interval as Datadog rates.Today, users get this behavior with a
luaorremapstep afteraggregatethat setsinterval_msby hand. The value in that step must match the aggregate interval, and nothing checks that.Behavior when enabled:
Incrementalmetrics are changed. Absolute metrics are not changed, becauseMetricData::into_absolutealready clears the interval. Metrics that pass through unchanged are not changed either, because they are not aggregated over the window.interval_msthat already exists on input is overwritten with the flush interval.Aggregate::newrequiresinterval_msto be a whole number of seconds (a multiple of 1000) when the option is on, because Datadog sends the interval as whole seconds. So this option never creates sub-second rate windows.Aggregate::newrejectsinterval_ms > u32::MAXwhen the option is on, becauseMetricTime::interval_msisNonZeroU32. Configs that do not turn on the option get no new limit.The option is applied once, after the flush, on the slice of
outputthat the flush added. Events that are already in the caller's buffer are not changed.datadog_metricssink: fractional-second intervalsFrom review: both series encoders (
series_to_proto_messagefor v2,encode_metric_to_v3for v3) convertedinterval_msto seconds with integer division. Withinterval_ms < 1000the divisor was 0, so the rate wasinf(orNaNfor a zero counter). Intervals that are not whole seconds overstated the rate (1500 ms was divided by 1).Both encoders now share one
series_interval()helper:interval_ms as f64 / 1000.0).int64 intervalin v2,uint64 intervalsin v3), so it is sent asmax(1, round(secs))instead of being truncated to 0.Tradeoff: for a non-whole-second interval the rate is exact, but
as_count()(rate × interval) uses the rounded field. Whole-second intervals are not affected. A gauge with a sub-second interval now gets interval field 1 instead of 0, and its value does not change.Not in this PR
Review found more edge cases in rate windows. They touch shared code, so they move to a follow-up PR:
sort_and_collapse_counters_by_series_and_timestamp) adds values but keeps one interval. Two sub-second windows of one series in the same second are sent at about twice the rate.set_interval_mscannot produce this (it requires whole seconds); other sources with sub-second intervals can. Before this PR, those were sent asinf.as_count()(rate × interval) returns the true total.References
Closes: #15659
Related: #23762
Related: #24686. That draft sets the interval on counters unconditionally. This PR makes it opt-in, as @pront suggested on #15659, so existing
datadog_metricsoutput does not change unless a user turns the option on.Vector configuration
Output with
set_interval_ms: true:Output with
set_interval_ms: false(unchanged from today):How did you test this PR?
src/transforms/aggregate/tests.rs: config parsing and default, theu32limit, flag off, system-time flush and final flush, overwrite of an existing interval, passthrough and existing output buffer not changed, event-time bucketscargo test --lib --no-default-features --features transforms-aggregate transforms::aggregate: 38 passedcargo fmt --all -- --checkcargo clippy --lib --tests --no-default-features --features transforms-aggregate -- -D warningswebsite/cue/reference/components/transforms/generated/aggregate.cuewithvdev build component-docsvdev check changelog-fragmentssrc/sinks/datadog/metrics/encoder.rsandencoder_v3.rs:series_interval()from 1 ms tou32::MAX, decoded v2 payload for 500 ms and 1500 ms intervals, and a v3 payload-equality check (0.5 over 500 ms encodes the same as 1.0 over 1000 ms)cargo test --lib --no-default-features --features sinks-datadog_metrics,transforms-aggregate -- sinks::datadog::metrics transforms::aggregate: 120 passedcargo clippy --lib --tests --no-default-features --features sinks-datadog_metrics -- -D warningsmake check-generated-docs/ full-feature clippy (not run locally, because it needs the full default-feature build; CI covers these)set_interval_ms_requires_whole_seconds(1, 500, 1500, 10001 ms rejected with the option and accepted without it; 1000, 2000, 60000 ms accepted). Mutation check: with the validation removed, it failsinterval_ms: 1500withset_interval_ms: trueis rejected at startup with the new errorall_series_metric_types,smoke,default_series_version_uses_the_v3_intake): 3 passedwebsite/generated/example-configs/transforms/aggregate/advanced.yamlDoes this PR include user facing changes?
no-changeloglabel to this PR.Changelog fragments:
changelog.d/15659_aggregate_set_interval_ms.enhancement.mdchangelog.d/26597_datadog_metrics_fractional_interval.fix.md