Skip to content

Commit e013180

Browse files
committed
fixup: bridge DD_* fallbacks for saluki-only keys
Saluki-only keys set via DD_* env vars were silently dropped, causing SMP memory regressions in the DSD quality_gates benchmarks (~20% RSS increase). Adds bridge_dd_fallbacks() to read saluki-only values from the Datadog source when the Saluki source has not set them. Covers aggregate_context_limit, interner sizes, autoscale, and OTLP context limits.
1 parent 64e5b69 commit e013180

2 files changed

Lines changed: 52 additions & 11 deletions

File tree

lib/agent-data-plane-config-system/src/bootstrap.rs

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use std::path::PathBuf;
2323

2424
use agent_data_plane_config::{BootstrapConfiguration, LocalApiBootstrap, RuntimeAuthority, SalukiOnlyConfiguration};
25+
use bytesize::ByteSize;
2526
use datadog_agent_config::{DatadogRemapper, KEY_ALIASES};
2627
use saluki_config_tools::{ConfigurationLoader, GenericConfiguration};
2728
use saluki_error::{generic_error, GenericError};
@@ -173,14 +174,11 @@ pub(crate) fn load_local_sources(
173174
.as_typed()
174175
.map_err(|e| generic_error!("Failed to parse the Saluki-schema-only configuration: {}", e))?;
175176

176-
// `dogstatsd_tcp_port` is not in the Datadog core schema, so it cannot go through the overlay
177-
// witness. The Saluki source owns this key, but existing deployments set it via `DD_*` env
178-
// vars. Bridge the Datadog source value into the Saluki-only struct when not already set.
179-
if saluki_only.dogstatsd.tcp_port.is_none() {
180-
if let Ok(Some(v)) = datadog_generic.try_get_typed::<u16>("dogstatsd_tcp_port") {
181-
saluki_only.dogstatsd.tcp_port = Some(v);
182-
}
183-
}
177+
// DD->Saluki migration bridge: Saluki-schema-only keys are owned by the Saluki source
178+
// (SALUKI_* / saluki.yaml), but existing deployments and test configs set them via DD_* env
179+
// vars. Bridge each Datadog source value into the Saluki-only struct when the Saluki source
180+
// has not already set it. SALUKI_* always wins (it is checked first).
181+
bridge_dd_fallbacks(&mut saluki_only, &datadog_generic);
184182
let saluki_bootstrap = saluki_generic
185183
.as_typed()
186184
.map_err(|e| generic_error!("Failed to parse the Saluki bootstrap slice: {}", e))?;
@@ -244,3 +242,47 @@ fn patch_snapshot_pipeline_gates(
244242

245243
Ok(())
246244
}
245+
246+
/// Bridges Saluki-schema-only keys from the Datadog source (`DD_*`) into the Saluki-only struct.
247+
///
248+
/// Saluki-schema-only keys are owned by the Saluki source (`SALUKI_*` / `saluki.yaml`). The clean
249+
/// end state reads them only from there. However, existing deployments and test infrastructure set
250+
/// these keys via `DD_*` env vars. This function provides a bounded migration-compatibility layer:
251+
/// each value is read from the Datadog source only when the Saluki source has not already set it.
252+
fn bridge_dd_fallbacks(saluki_only: &mut SalukiOnlyConfiguration, dd: &GenericConfiguration) {
253+
// ---- dogstatsd ----
254+
if saluki_only.dogstatsd.tcp_port.is_none() {
255+
if let Ok(Some(v)) = dd.try_get_typed::<u16>("dogstatsd_tcp_port") {
256+
saluki_only.dogstatsd.tcp_port = Some(v);
257+
}
258+
}
259+
if saluki_only.dogstatsd.string_interner_size_bytes.is_none() {
260+
if let Ok(Some(v)) = dd.try_get_typed::<ByteSize>("dogstatsd_string_interner_size_bytes") {
261+
saluki_only.dogstatsd.string_interner_size_bytes = Some(v.0);
262+
}
263+
}
264+
if saluki_only.dogstatsd.autoscale_udp_listeners.is_none() {
265+
if let Ok(Some(v)) = dd.try_get_typed::<bool>("dogstatsd_autoscale_udp_listeners") {
266+
saluki_only.dogstatsd.autoscale_udp_listeners = Some(v);
267+
}
268+
}
269+
270+
// ---- aggregate ----
271+
if saluki_only.aggregate.context_limit.is_none() {
272+
if let Ok(Some(v)) = dd.try_get_typed::<usize>("aggregate_context_limit") {
273+
saluki_only.aggregate.context_limit = Some(v);
274+
}
275+
}
276+
277+
// ---- otlp ----
278+
if saluki_only.otlp.cached_contexts_limit.is_none() {
279+
if let Ok(Some(v)) = dd.try_get_typed::<usize>("otlp_cached_context_limit") {
280+
saluki_only.otlp.cached_contexts_limit = Some(v);
281+
}
282+
}
283+
if saluki_only.otlp.traces_string_interner_size.is_none() {
284+
if let Ok(Some(v)) = dd.try_get_typed::<ByteSize>("otlp_config.traces.string_interner_size") {
285+
saluki_only.otlp.traces_string_interner_size = Some(v.0);
286+
}
287+
}
288+
}

lib/agent-data-plane-config-system/src/system.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,8 @@ fn assemble(
200200
/// autodiscovery). In that case we establish a lightweight Agent connection for the env-provider
201201
/// attachments without subscribing to the config stream.
202202
async fn start_local(
203-
bootstrap: BootstrapConfiguration, saluki_only: SalukiOnlyConfiguration,
204-
datadog_snapshot: serde_json::Value, standalone_mode: bool, otlp_enabled: bool,
205-
registration: RemoteAgentRegistration,
203+
bootstrap: BootstrapConfiguration, saluki_only: SalukiOnlyConfiguration, datadog_snapshot: serde_json::Value,
204+
standalone_mode: bool, otlp_enabled: bool, registration: RemoteAgentRegistration,
206205
) -> Result<StartedConfigurationSystem, GenericError> {
207206
let datadog: DatadogConfiguration = serde_json::from_value(datadog_snapshot.clone())
208207
.map_err(|e| generic_error!("Failed to parse the local Datadog snapshot at startup: {}", e))?;

0 commit comments

Comments
 (0)