|
22 | 22 | use std::path::PathBuf; |
23 | 23 |
|
24 | 24 | use agent_data_plane_config::{BootstrapConfiguration, LocalApiBootstrap, RuntimeAuthority, SalukiOnlyConfiguration}; |
| 25 | +use bytesize::ByteSize; |
25 | 26 | use datadog_agent_config::{DatadogRemapper, KEY_ALIASES}; |
26 | 27 | use saluki_config_tools::{ConfigurationLoader, GenericConfiguration}; |
27 | 28 | use saluki_error::{generic_error, GenericError}; |
@@ -173,14 +174,11 @@ pub(crate) fn load_local_sources( |
173 | 174 | .as_typed() |
174 | 175 | .map_err(|e| generic_error!("Failed to parse the Saluki-schema-only configuration: {}", e))?; |
175 | 176 |
|
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); |
184 | 182 | let saluki_bootstrap = saluki_generic |
185 | 183 | .as_typed() |
186 | 184 | .map_err(|e| generic_error!("Failed to parse the Saluki bootstrap slice: {}", e))?; |
@@ -244,3 +242,47 @@ fn patch_snapshot_pipeline_gates( |
244 | 242 |
|
245 | 243 | Ok(()) |
246 | 244 | } |
| 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 | +} |
0 commit comments