Skip to content

Commit e3f291b

Browse files
authored
feat(config): default data_plane.dogstatsd.enabled to true (#1474)
## Summary Default `data_plane.dogstatsd.enabled` to `true` so that enabling the data plane via `data_plane.enabled` automatically routes DogStatsD to ADP without requiring a separate explicit opt-in. This aligns ADP's behavior with the Core Agent's routing truth table, where enabling `data_plane.enabled` is the single lever for routing DogStatsD to ADP. The Core Agent remains authoritative and communicates the resolved DogStatsD decision (including suppression from `use_dogstatsd=false`) to ADP via `data_plane.dogstatsd.enabled` through the config stream. ## Test plan - [x] `config::tests::default_enables_dogstatsd` — verifies the new default - [x] `config::tests::use_dogstatsd_false_does_not_disable_dogstatsd_by_default` — verifies ADP ignores `use_dogstatsd` directly - [x] `config::tests::explicit_false_disables_dogstatsd` — verifies explicit `false` still works - [x] Run `cargo test --bin agent-data-plane` locally Refs #1334 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: jesse.szwedko <[email protected]>
1 parent 542d70f commit e3f291b

1 file changed

Lines changed: 64 additions & 13 deletions

File tree

bin/agent-data-plane/src/config.rs

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub struct DataPlaneDogStatsDConfiguration {
151151
///
152152
/// When disabled, DogStatsD will not be started.
153153
///
154-
/// Defaults to `false`.
154+
/// Defaults to `true`.
155155
enabled: bool,
156156
}
157157

@@ -162,7 +162,7 @@ impl DataPlaneDogStatsDConfiguration {
162162
// ADP and the Core Agent disagreeing. See `docs/agent-data-plane/configuration/dogstatsd.md`.
163163
fn from_configuration(config: &GenericConfiguration) -> Result<Self, GenericError> {
164164
Ok(Self {
165-
enabled: config.try_get_typed("data_plane.dogstatsd.enabled")?.unwrap_or(false),
165+
enabled: config.try_get_typed("data_plane.dogstatsd.enabled")?.unwrap_or(true),
166166
})
167167
}
168168

@@ -293,31 +293,82 @@ mod tests {
293293

294294
use super::*;
295295

296-
// The Core Agent owns the `use_dogstatsd` decision and communicates the result to ADP via
297-
// `data_plane.dogstatsd.enabled`. These tests guard against a regression where ADP starts
298-
// reading `use_dogstatsd` directly, which would let ADP and the Core Agent disagree.
296+
// ADP ignores `use_dogstatsd`. The Core Agent evaluates that key and delivers the resolved
297+
// decision to ADP by setting `data_plane.dogstatsd.enabled` via the config stream.
298+
299+
#[tokio::test]
300+
async fn default_enables_dogstatsd() {
301+
let (config, _) =
302+
ConfigurationLoader::for_tests(Some(json!({ "data_plane": { "enabled": true } })), None, false).await;
303+
304+
let dp = DataPlaneConfiguration::from_configuration(&config).expect("parse config");
305+
assert!(dp.enabled());
306+
assert!(dp.dogstatsd().enabled());
307+
}
308+
309+
#[tokio::test]
310+
async fn use_dogstatsd_false_does_not_disable_dogstatsd_by_default() {
311+
let (config, _) = ConfigurationLoader::for_tests(
312+
Some(json!({ "use_dogstatsd": false, "data_plane": { "enabled": true } })),
313+
None,
314+
false,
315+
)
316+
.await;
317+
318+
let dp = DataPlaneConfiguration::from_configuration(&config).expect("parse config");
319+
assert!(dp.enabled());
320+
assert!(dp.dogstatsd().enabled());
321+
}
322+
323+
#[tokio::test]
324+
async fn explicit_false_disables_dogstatsd() {
325+
let (config, _) = ConfigurationLoader::for_tests(
326+
Some(json!({ "data_plane": { "enabled": true, "dogstatsd": { "enabled": false } } })),
327+
None,
328+
false,
329+
)
330+
.await;
331+
332+
let dp = DataPlaneConfiguration::from_configuration(&config).expect("parse config");
333+
assert!(dp.enabled());
334+
assert!(!dp.dogstatsd().enabled());
335+
}
299336

300337
#[tokio::test]
301-
async fn use_dogstatsd_true_does_not_enable_dogstatsd() {
302-
let (config, _) = ConfigurationLoader::for_tests(Some(json!({ "use_dogstatsd": true })), None, false).await;
338+
async fn use_dogstatsd_true_does_not_override_explicit_false() {
339+
// `use_dogstatsd=true` must not enable DSD when `data_plane.dogstatsd.enabled=false` is
340+
// set explicitly. ADP reads only its own key.
341+
let (config, _) = ConfigurationLoader::for_tests(
342+
Some(json!({
343+
"use_dogstatsd": true,
344+
"data_plane": { "enabled": true, "dogstatsd": { "enabled": false } },
345+
})),
346+
None,
347+
false,
348+
)
349+
.await;
303350

304-
let dsd = DataPlaneDogStatsDConfiguration::from_configuration(&config).expect("parse config");
305-
assert!(!dsd.enabled());
351+
let dp = DataPlaneConfiguration::from_configuration(&config).expect("parse config");
352+
assert!(dp.enabled());
353+
assert!(!dp.dogstatsd().enabled());
306354
}
307355

308356
#[tokio::test]
309-
async fn use_dogstatsd_false_does_not_disable_dogstatsd() {
357+
async fn use_dogstatsd_false_does_not_disable_dogstatsd_when_explicitly_enabled() {
358+
// `use_dogstatsd=false` must not disable DSD when `data_plane.dogstatsd.enabled=true` is
359+
// set explicitly. The Core Agent communicates its resolved decision via that key.
310360
let (config, _) = ConfigurationLoader::for_tests(
311361
Some(json!({
312362
"use_dogstatsd": false,
313-
"data_plane": { "dogstatsd": { "enabled": true } },
363+
"data_plane": { "enabled": true, "dogstatsd": { "enabled": true } },
314364
})),
315365
None,
316366
false,
317367
)
318368
.await;
319369

320-
let dsd = DataPlaneDogStatsDConfiguration::from_configuration(&config).expect("parse config");
321-
assert!(dsd.enabled());
370+
let dp = DataPlaneConfiguration::from_configuration(&config).expect("parse config");
371+
assert!(dp.enabled());
372+
assert!(dp.dogstatsd().enabled());
322373
}
323374
}

0 commit comments

Comments
 (0)