From 7f3aa72ba3795d8ad35ff4e19850dcd5194cc56d Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 27 Mar 2026 11:40:48 +0100 Subject: [PATCH 01/13] More generated things --- .../src/core/configuration/configuration.rs | 632 ++---------------- .../src/core/configuration/mod.rs | 5 +- .../src/core/configuration/sources.rs | 4 +- .../configuration/supported_configurations.rs | 417 +++++++++++- scripts/local_config_map_generate.py | 277 +++++++- supported-configurations.json | 84 ++- 6 files changed, 766 insertions(+), 653 deletions(-) diff --git a/datadog-opentelemetry/src/core/configuration/configuration.rs b/datadog-opentelemetry/src/core/configuration/configuration.rs index dbe23770..e0c50ed2 100644 --- a/datadog-opentelemetry/src/core/configuration/configuration.rs +++ b/datadog-opentelemetry/src/core/configuration/configuration.rs @@ -13,7 +13,9 @@ use rustc_version_runtime::version; use crate::core::configuration::sources::{ CompositeConfigSourceResult, CompositeSource, ConfigKey, ConfigSourceOrigin, }; -use crate::core::configuration::supported_configurations::SupportedConfigurations; +#[path = "supported_configurations.rs"] +mod supported_configurations; +pub(crate) use supported_configurations::{is_alias_deprecated, SupportedConfigurations}; use crate::core::log::LevelFilter; use crate::core::telemetry; use crate::{dd_error, dd_warn}; @@ -930,28 +932,19 @@ pub struct Config { impl Config { fn from_sources(sources: &CompositeSource) -> Self { - let default = default_config(); + use SupportedConfigurations as S; - /// Wrapper to parse "," separated string to vector struct DdTags(Vec); - impl FromStr for DdTags { type Err = &'static str; - fn from_str(s: &str) -> Result { - Ok(DdTags( - s.split(',').map(|s| s.to_string()).collect::>(), - )) + Ok(DdTags(s.split(',').map(|s| s.to_string()).collect())) } } - /// Wrapper to parse "," separated key:value tags to vector<(key, value)> - /// discarding tags without ":" delimiter struct DdKeyValueTags(Vec<(String, String)>); - impl FromStr for DdKeyValueTags { type Err = &'static str; - fn from_str(s: &str) -> Result { Ok(DdKeyValueTags( s.split(',') @@ -965,10 +958,8 @@ impl Config { } struct OtelResourceAttributes(Vec<(String, String)>); - impl FromStr for OtelResourceAttributes { type Err = &'static str; - fn from_str(s: &str) -> Result { Ok(OtelResourceAttributes( s.split(',') @@ -981,19 +972,17 @@ impl Config { } } - let parsed_sampling_rules_config = sources - .get_parse::(SupportedConfigurations::DD_TRACE_SAMPLING_RULES); - + let parsed_sampling_rules_config = + sources.get_parse::(S::DD_TRACE_SAMPLING_RULES); let mut sampling_rules_item = ConfigItemWithOverride::new_rc( parsed_sampling_rules_config.name, - ParsedSamplingRules::default(), // default is empty rules + ParsedSamplingRules::default(), ); - - // Set env value if it was parsed from environment if let Some(rules) = parsed_sampling_rules_config.value { sampling_rules_item.set_value_source(rules.value, rules.origin); } + let default = default_config(); let cisu = ConfigItemSourceUpdater { sources }; Self { @@ -1004,48 +993,27 @@ impl Config { service: cisu.update_string(default.service, ServiceName::Configured), env: cisu.update_string(default.env, Some), version: cisu.update_string(default.version, Some), - // TODO(paullgdc): tags should be merged, not replaced global_tags: cisu .update_parsed_with_transform(default.global_tags, |DdKeyValueTags(tags)| tags), otel_resource_attributes: cisu.update_parsed_with_transform( default.otel_resource_attributes, |OtelResourceAttributes(attrs)| attrs, ), - otel_metrics_exporter: cisu.update_string(default.otel_metrics_exporter, Cow::Owned), otel_metrics_temporality_preference: cisu.update_string( default.otel_metrics_temporality_preference, crate::metrics_exporter::parse_temporality, ), - agent_host: cisu.update_string(default.agent_host, Cow::Owned), - trace_agent_port: cisu.update_parsed(default.trace_agent_port), - trace_agent_url: cisu.update_string(default.trace_agent_url, Cow::Owned), - dogstatsd_agent_host: cisu.update_string(default.dogstatsd_agent_host, Cow::Owned), - dogstatsd_agent_port: cisu.update_parsed(default.dogstatsd_agent_port), - dogstatsd_agent_url: cisu.update_string(default.dogstatsd_agent_url, Cow::Owned), - - trace_partial_flush_enabled: cisu.update_parsed(default.trace_partial_flush_enabled), - trace_partial_flush_min_spans: cisu - .update_parsed(default.trace_partial_flush_min_spans), - - // Use the initialized ConfigItem trace_sampling_rules: sampling_rules_item, trace_rate_limit: cisu.update_parsed(default.trace_rate_limit), - - enabled: cisu.update_parsed(default.enabled), log_level_filter: cisu.update_parsed(default.log_level_filter), - trace_stats_computation_enabled: cisu - .update_parsed(default.trace_stats_computation_enabled), - telemetry_enabled: cisu.update_parsed(default.telemetry_enabled), - telemetry_log_collection_enabled: cisu - .update_parsed(default.telemetry_log_collection_enabled), telemetry_heartbeat_interval: cisu.update_parsed_with_transform( default.telemetry_heartbeat_interval, |interval: f64| interval.abs(), ), - trace_propagation_style: cisu - .update_parsed_with_transform(default.trace_propagation_style, |DdTags(tags)| { - TracePropagationStyle::from_tags(Some(tags)) - }), + trace_propagation_style: cisu.update_parsed_with_transform( + default.trace_propagation_style, + |DdTags(tags)| TracePropagationStyle::from_tags(Some(tags)), + ), trace_propagation_style_extract: cisu.update_parsed_with_transform( default.trace_propagation_style_extract, |DdTags(tags)| TracePropagationStyle::from_tags(Some(tags)), @@ -1054,36 +1022,52 @@ impl Config { default.trace_propagation_style_inject, |DdTags(tags)| TracePropagationStyle::from_tags(Some(tags)), ), - trace_propagation_extract_first: cisu - .update_parsed(default.trace_propagation_extract_first), + trace_partial_flush_min_spans: cisu + .update_parsed(default.trace_partial_flush_min_spans), #[cfg(feature = "test-utils")] wait_agent_info_ready: default.wait_agent_info_ready, extra_services_tracker: ExtraServicesTracker::new(), - remote_config_enabled: cisu.update_parsed(default.remote_config_enabled), remote_config_poll_interval: cisu.update_parsed_with_transform( default.remote_config_poll_interval, |interval: f64| interval.abs().min(RC_DEFAULT_POLL_INTERVAL), ), remote_config_callbacks: Arc::new(Mutex::new(RemoteConfigCallbacks::new())), - datadog_tags_max_length: cisu - .update_parsed_with_transform(default.datadog_tags_max_length, |max: usize| { - max.min(DATADOG_TAGS_MAX_LENGTH) - }), - metrics_otel_enabled: cisu.update_parsed(default.metrics_otel_enabled), - otlp_metrics_endpoint: cisu.update_string(default.otlp_metrics_endpoint, Cow::Owned), - otlp_endpoint: cisu.update_string(default.otlp_endpoint, Cow::Owned), - otlp_headers: cisu.update_string(default.otlp_headers, Cow::Owned), + datadog_tags_max_length: cisu.update_parsed_with_transform( + default.datadog_tags_max_length, + |max: usize| max.min(DATADOG_TAGS_MAX_LENGTH), + ), otlp_metrics_protocol: cisu.update_string( default.otlp_metrics_protocol, crate::metrics_exporter::OtlpProtocol::parse_optional, ), + dogstatsd_agent_url: cisu.update_string(default.dogstatsd_agent_url, Cow::Owned), + otlp_headers: cisu.update_string(default.otlp_headers, Cow::Owned), otlp_metrics_headers: cisu.update_string(default.otlp_metrics_headers, Cow::Owned), otlp_protocol: cisu.update_string( default.otlp_protocol, crate::metrics_exporter::OtlpProtocol::parse_optional, ), + agent_host: cisu.update_string(default.agent_host, Cow::Owned), + dogstatsd_agent_host: cisu.update_string(default.dogstatsd_agent_host, Cow::Owned), + dogstatsd_agent_port: cisu.update_parsed(default.dogstatsd_agent_port), + telemetry_enabled: cisu.update_parsed(default.telemetry_enabled), + metrics_otel_enabled: cisu.update_parsed(default.metrics_otel_enabled), + remote_config_enabled: cisu.update_parsed(default.remote_config_enabled), + telemetry_log_collection_enabled: cisu + .update_parsed(default.telemetry_log_collection_enabled), + trace_agent_port: cisu.update_parsed(default.trace_agent_port), + trace_agent_url: cisu.update_string(default.trace_agent_url, Cow::Owned), + enabled: cisu.update_parsed(default.enabled), + trace_partial_flush_enabled: cisu.update_parsed(default.trace_partial_flush_enabled), + trace_propagation_extract_first: cisu + .update_parsed(default.trace_propagation_extract_first), + trace_stats_computation_enabled: cisu + .update_parsed(default.trace_stats_computation_enabled), + otlp_endpoint: cisu.update_string(default.otlp_endpoint, Cow::Owned), + otlp_metrics_endpoint: cisu.update_string(default.otlp_metrics_endpoint, Cow::Owned), otlp_metrics_timeout: cisu.update_parsed(default.otlp_metrics_timeout), otlp_timeout: cisu.update_parsed(default.otlp_timeout), + otel_metrics_exporter: cisu.update_string(default.otel_metrics_exporter, Cow::Owned), metric_export_interval: cisu.update_parsed(default.metric_export_interval), metric_export_timeout: cisu.update_parsed(default.metric_export_timeout), } @@ -1100,47 +1084,6 @@ impl Config { Self::builder_with_sources(&CompositeSource::default_sources()) } - pub(crate) fn get_telemetry_configuration(&self) -> Vec<&dyn ConfigurationProvider> { - vec![ - &self.service, - &self.env, - &self.version, - &self.global_tags, - &self.agent_host, - &self.trace_agent_port, - &self.trace_agent_url, - &self.dogstatsd_agent_host, - &self.dogstatsd_agent_port, - &self.dogstatsd_agent_url, - &self.trace_sampling_rules, - &self.trace_rate_limit, - &self.enabled, - &self.log_level_filter, - &self.trace_stats_computation_enabled, - &self.telemetry_enabled, - &self.telemetry_log_collection_enabled, - &self.telemetry_heartbeat_interval, - &self.trace_partial_flush_enabled, - &self.trace_partial_flush_min_spans, - &self.trace_propagation_style, - &self.trace_propagation_style_extract, - &self.trace_propagation_style_inject, - &self.trace_propagation_extract_first, - &self.remote_config_enabled, - &self.remote_config_poll_interval, - &self.datadog_tags_max_length, - &self.otlp_endpoint, - &self.otlp_timeout, - &self.otlp_headers, - &self.otlp_protocol, - &self.otlp_metrics_endpoint, - &self.otlp_metrics_timeout, - &self.otlp_metrics_headers, - &self.otlp_metrics_protocol, - &self.metric_export_interval, - &self.metric_export_timeout, - ] - } /// Returns the unique runtime identifier for this process. pub fn runtime_id(&self) -> &str { @@ -1201,11 +1144,6 @@ impl Config { .map(|attr| (attr.0.as_str(), attr.1.as_str())) } - /// Returns the OpenTelemetry metrics exporter type. - pub fn otel_metrics_exporter(&self) -> &str { - self.otel_metrics_exporter.value().as_ref() - } - /// Returns the OpenTelemetry metrics temporality preference (Delta or Cumulative). pub fn otel_metrics_temporality_preference( &self, @@ -1213,21 +1151,6 @@ impl Config { *self.otel_metrics_temporality_preference.value() } - /// Returns the URL of the Datadog trace agent. - pub fn trace_agent_url(&self) -> &Cow<'static, str> { - self.trace_agent_url.value() - } - - /// Returns the host of the DogStatsD agent. - pub fn dogstatsd_agent_host(&self) -> &Cow<'static, str> { - self.dogstatsd_agent_host.value() - } - - /// Returns the port of the DogStatsD agent. - pub fn dogstatsd_agent_port(&self) -> &u32 { - self.dogstatsd_agent_port.value() - } - /// Returns the full URL of the DogStatsD agent. pub fn dogstatsd_agent_url(&self) -> &Cow<'static, str> { self.dogstatsd_agent_url.value() @@ -1243,21 +1166,11 @@ impl Config { *self.trace_rate_limit.value() } - /// Returns whether tracing is enabled. - pub fn enabled(&self) -> bool { - *self.enabled.value() - } - /// Returns the configured log level filter. pub fn log_level_filter(&self) -> &LevelFilter { self.log_level_filter.value() } - /// Returns whether client-side trace stats computation is enabled. - pub fn trace_stats_computation_enabled(&self) -> bool { - *self.trace_stats_computation_enabled.value() - } - #[cfg(feature = "test-utils")] pub(crate) fn __internal_wait_agent_info_ready(&self) -> bool { self.wait_agent_info_ready @@ -1270,36 +1183,11 @@ impl Config { RUNTIME_ID.get_or_init(|| uuid::Uuid::new_v4().to_string()) } - /// Returns whether telemetry collection is enabled. - pub fn telemetry_enabled(&self) -> bool { - *self.telemetry_enabled.value() - } - - /// Returns whether telemetry log collection is enabled. - pub fn telemetry_log_collection_enabled(&self) -> bool { - *self.telemetry_log_collection_enabled.value() - } - /// Returns the telemetry heartbeat interval in seconds. pub fn telemetry_heartbeat_interval(&self) -> f64 { *self.telemetry_heartbeat_interval.value() } - /// Returns whether OpenTelemetry metrics export is enabled. - pub fn metrics_otel_enabled(&self) -> bool { - *self.metrics_otel_enabled.value() - } - - /// Returns the OTLP metrics endpoint URL. - pub fn otlp_metrics_endpoint(&self) -> &str { - self.otlp_metrics_endpoint.value().as_ref() - } - - /// Returns the OTLP endpoint URL (fallback for metrics if metrics endpoint is not set). - pub fn otlp_endpoint(&self) -> &str { - self.otlp_endpoint.value().as_ref() - } - /// Returns the OTLP headers (fallback for metrics if metrics headers are not set). pub fn otlp_headers(&self) -> &str { self.otlp_headers.value().as_ref() @@ -1320,32 +1208,6 @@ impl Config { *self.otlp_protocol.value() } - /// Returns the OTLP metrics timeout in milliseconds. - pub fn otlp_metrics_timeout(&self) -> u32 { - *self.otlp_metrics_timeout.value() - } - - /// Returns the OTLP timeout in milliseconds (fallback for metrics if metrics timeout is not - /// set). - pub fn otlp_timeout(&self) -> u32 { - *self.otlp_timeout.value() - } - - /// Returns the metric export interval in milliseconds. - pub fn metric_export_interval(&self) -> u32 { - *self.metric_export_interval.value() - } - - /// Returns the metric export timeout in milliseconds. - pub fn metric_export_timeout(&self) -> u32 { - *self.metric_export_timeout.value() - } - - /// Returns whether partial trace flushing is enabled. - pub fn trace_partial_flush_enabled(&self) -> bool { - *self.trace_partial_flush_enabled.value() - } - /// Returns the minimum number of spans required to trigger a partial flush. pub fn trace_partial_flush_min_spans(&self) -> usize { *self.trace_partial_flush_min_spans.value() @@ -1366,11 +1228,6 @@ impl Config { self.trace_propagation_style_inject.value().as_deref() } - /// Returns whether to stop extraction after the first successful propagator. - pub fn trace_propagation_extract_first(&self) -> bool { - *self.trace_propagation_extract_first.value() - } - pub(crate) fn update_sampling_rules_from_remote( &self, rules_json: &str, @@ -1455,11 +1312,6 @@ impl Config { self.extra_services_tracker.get_extra_services() } - /// Check if remote configuration is enabled - pub fn remote_config_enabled(&self) -> bool { - *self.remote_config_enabled.value() - } - /// Get RC poll interval (seconds) pub fn remote_config_poll_interval(&self) -> f64 { *self.remote_config_poll_interval.value() @@ -1471,204 +1323,8 @@ impl Config { } } -impl std::fmt::Debug for Config { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("Config") - .field("runtime_id", &self.runtime_id) - .field("tracer_version", &self.tracer_version) - .field("language_version", &self.language_version) - .field("service", &self.service) - .field("env", &self.env) - .field("version", &self.version) - .field("global_tags", &self.global_tags) - .field("trace_agent_url", &self.trace_agent_url) - .field("dogstatsd_agent_url", &self.dogstatsd_agent_url) - .field("trace_sampling_rules", &self.trace_sampling_rules) - .field("trace_rate_limit", &self.trace_rate_limit) - .field("enabled", &self.enabled) - .field("log_level_filter", &self.log_level_filter) - .field( - "trace_stats_computation_enabled", - &self.trace_stats_computation_enabled, - ) - .field("trace_propagation_style", &self.trace_propagation_style) - .field( - "trace_propagation_style_extract", - &self.trace_propagation_style_extract, - ) - .field( - "trace_propagation_style_inject", - &self.trace_propagation_style_inject, - ) - .field( - "trace_propagation_extract_first", - &self.trace_propagation_extract_first, - ) - .field("extra_services_tracker", &self.extra_services_tracker) - .field("remote_config_enabled", &self.remote_config_enabled) - .field( - "remote_config_poll_interval", - &self.remote_config_poll_interval, - ) - .field("remote_config_callbacks", &self.remote_config_callbacks) - .finish() - } -} - fn default_config() -> Config { - Config { - runtime_id: Config::process_runtime_id(), - env: ConfigItem::new(SupportedConfigurations::DD_ENV, None), - // TODO(paullgdc): Default service naming detection, probably from arg0 - service: ConfigItemWithOverride::new_code( - SupportedConfigurations::DD_SERVICE, - ServiceName::Default, - ), - version: ConfigItem::new(SupportedConfigurations::DD_VERSION, None), - global_tags: ConfigItem::new(SupportedConfigurations::DD_TAGS, Vec::new()), - otel_resource_attributes: ConfigItem::new( - SupportedConfigurations::OTEL_RESOURCE_ATTRIBUTES, - Vec::new(), - ), - otel_metrics_exporter: ConfigItem::new( - SupportedConfigurations::OTEL_METRICS_EXPORTER, - Cow::Borrowed("otlp"), - ), - otel_metrics_temporality_preference: ConfigItem::new( - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, - Some(opentelemetry_sdk::metrics::Temporality::Delta), - ), - - agent_host: ConfigItem::new( - SupportedConfigurations::DD_AGENT_HOST, - Cow::Borrowed("localhost"), - ), - trace_agent_port: ConfigItem::new(SupportedConfigurations::DD_TRACE_AGENT_PORT, 8126), - trace_agent_url: ConfigItem::new( - SupportedConfigurations::DD_TRACE_AGENT_URL, - Cow::Borrowed(""), - ), - dogstatsd_agent_host: ConfigItem::new( - SupportedConfigurations::DD_DOGSTATSD_HOST, - Cow::Borrowed("localhost"), - ), - dogstatsd_agent_port: ConfigItem::new(SupportedConfigurations::DD_DOGSTATSD_PORT, 8125), - dogstatsd_agent_url: ConfigItem::new( - SupportedConfigurations::DD_DOGSTATSD_URL, - Cow::Borrowed(""), - ), - trace_sampling_rules: ConfigItemWithOverride::new_rc( - SupportedConfigurations::DD_TRACE_SAMPLING_RULES, - ParsedSamplingRules::default(), // Empty rules by default - ), - trace_rate_limit: ConfigItem::new(SupportedConfigurations::DD_TRACE_RATE_LIMIT, 100), - enabled: ConfigItem::new(SupportedConfigurations::DD_TRACE_ENABLED, true), - log_level_filter: ConfigItem::new( - SupportedConfigurations::DD_LOG_LEVEL, - LevelFilter::default(), - ), - tracer_version: TRACER_VERSION, - language: "rust", - language_version: version().to_string(), - trace_stats_computation_enabled: ConfigItem::new( - SupportedConfigurations::DD_TRACE_STATS_COMPUTATION_ENABLED, - true, - ), - #[cfg(feature = "test-utils")] - wait_agent_info_ready: false, - - telemetry_enabled: ConfigItem::new( - SupportedConfigurations::DD_INSTRUMENTATION_TELEMETRY_ENABLED, - true, - ), - telemetry_log_collection_enabled: ConfigItem::new( - SupportedConfigurations::DD_TELEMETRY_LOG_COLLECTION_ENABLED, - true, - ), - telemetry_heartbeat_interval: ConfigItem::new( - SupportedConfigurations::DD_TELEMETRY_HEARTBEAT_INTERVAL, - 60.0, - ), - trace_partial_flush_enabled: ConfigItem::new( - SupportedConfigurations::DD_TRACE_PARTIAL_FLUSH_ENABLED, - false, - ), - trace_partial_flush_min_spans: ConfigItem::new( - SupportedConfigurations::DD_TRACE_PARTIAL_FLUSH_MIN_SPANS, - 300, - ), - trace_propagation_style: ConfigItem::new( - SupportedConfigurations::DD_TRACE_PROPAGATION_STYLE, - Some(vec![ - TracePropagationStyle::Datadog, - TracePropagationStyle::TraceContext, - ]), - ), - trace_propagation_style_extract: ConfigItem::new( - SupportedConfigurations::DD_TRACE_PROPAGATION_STYLE_EXTRACT, - None, - ), - trace_propagation_style_inject: ConfigItem::new( - SupportedConfigurations::DD_TRACE_PROPAGATION_STYLE_INJECT, - None, - ), - trace_propagation_extract_first: ConfigItem::new( - SupportedConfigurations::DD_TRACE_PROPAGATION_EXTRACT_FIRST, - false, - ), - extra_services_tracker: ExtraServicesTracker::new(), - remote_config_enabled: ConfigItem::new( - SupportedConfigurations::DD_REMOTE_CONFIGURATION_ENABLED, - true, - ), - remote_config_poll_interval: ConfigItem::new( - SupportedConfigurations::DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS, - RC_DEFAULT_POLL_INTERVAL, - ), - remote_config_callbacks: Arc::new(Mutex::new(RemoteConfigCallbacks::new())), - datadog_tags_max_length: ConfigItem::new( - SupportedConfigurations::DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH, - DATADOG_TAGS_MAX_LENGTH, - ), - metrics_otel_enabled: ConfigItem::new( - SupportedConfigurations::DD_METRICS_OTEL_ENABLED, - true, - ), - otlp_metrics_endpoint: ConfigItem::new( - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, - Cow::Borrowed(""), - ), - otlp_endpoint: ConfigItem::new( - SupportedConfigurations::OTEL_EXPORTER_OTLP_ENDPOINT, - Cow::Borrowed(""), - ), - otlp_headers: ConfigItem::new( - SupportedConfigurations::OTEL_EXPORTER_OTLP_HEADERS, - Cow::Borrowed(""), - ), - otlp_metrics_protocol: ConfigItem::new( - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_PROTOCOL, - None, - ), - otlp_metrics_headers: ConfigItem::new( - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_HEADERS, - Cow::Borrowed(""), - ), - otlp_protocol: ConfigItem::new(SupportedConfigurations::OTEL_EXPORTER_OTLP_PROTOCOL, None), - otlp_metrics_timeout: ConfigItem::new( - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_TIMEOUT, - 10000u32, - ), - otlp_timeout: ConfigItem::new(SupportedConfigurations::OTEL_EXPORTER_OTLP_TIMEOUT, 7500u32), - metric_export_interval: ConfigItem::new( - SupportedConfigurations::OTEL_METRIC_EXPORT_INTERVAL, - 10000u32, - ), - metric_export_timeout: ConfigItem::new( - SupportedConfigurations::OTEL_METRIC_EXPORT_TIMEOUT, - 7500u32, - ), - } + supported_configurations::default_config() } /// Builder for constructing a [`Config`] instance. @@ -1767,28 +1423,6 @@ impl ConfigBuilder { self } - /// Enable or disable telemetry data collection and sending. - /// - /// **Default**: `true` - /// - /// Env variable: `DD_INSTRUMENTATION_TELEMETRY_ENABLED` - pub fn set_telemetry_enabled(&mut self, enabled: bool) -> &mut Self { - self.config.telemetry_enabled.set_code(enabled); - self - } - - /// Enable or disable log collection for telemetry. - /// - /// **Default**: `true` - /// - /// Env variable: `DD_TELEMETRY_LOG_COLLECTION_ENABLED` - pub fn set_telemetry_log_collection_enabled(&mut self, enabled: bool) -> &mut Self { - self.config - .telemetry_log_collection_enabled - .set_code(enabled); - self - } - /// Interval in seconds for sending telemetry heartbeat messages. /// /// **Default**: `60.0` @@ -1801,73 +1435,6 @@ impl ConfigBuilder { self } - /// Sets the hostname of the Datadog Agent. - /// - /// **Default**: `localhost` - /// - /// Env variable: `DD_AGENT_HOST` - pub fn set_agent_host(&mut self, host: String) -> &mut Self { - self.config - .agent_host - .set_code(Cow::Owned(host.to_string())); - self - } - - /// Sets the port of the Datadog Agent for trace collection. - /// - /// **Default**: `8126` - /// - /// Env variable: `DD_TRACE_AGENT_PORT` - pub fn set_trace_agent_port(&mut self, port: u32) -> &mut Self { - self.config.trace_agent_port.set_code(port); - self - } - - /// Sets the URL of the Datadog Agent. This takes precedence over `DD_AGENT_HOST` and - /// `DD_TRACE_AGENT_PORT`. - /// - /// **Default**: `http://localhost:8126` - /// - /// Env variable: `DD_TRACE_AGENT_URL` - pub fn set_trace_agent_url(&mut self, url: String) -> &mut Self { - self.config - .trace_agent_url - .set_code(Cow::Owned(url.to_string())); - self - } - - /// Enable or disable OpenTelemetry metrics export. - /// - /// **Default**: `false` - /// - /// Env variable: `DD_METRICS_OTEL_ENABLED` - pub fn set_metrics_otel_enabled(&mut self, enabled: bool) -> &mut Self { - self.config.metrics_otel_enabled.set_code(enabled); - self - } - - /// Set the OTLP metrics endpoint URL. - /// - /// **Default**: `(empty, falls back to OTEL_EXPORTER_OTLP_ENDPOINT or agent URL)` - /// - /// Env variable: `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` - pub fn set_otlp_metrics_endpoint(&mut self, endpoint: String) -> &mut Self { - self.config - .otlp_metrics_endpoint - .set_code(Cow::Owned(endpoint)); - self - } - - /// Set the OTLP general endpoint URL (fallback for metrics endpoint). - /// - /// **Default**: `(empty)` - /// - /// Env variable: `OTEL_EXPORTER_OTLP_ENDPOINT` - pub fn set_otlp_endpoint(&mut self, endpoint: String) -> &mut Self { - self.config.otlp_endpoint.set_code(Cow::Owned(endpoint)); - self - } - /// Set the OTLP metrics protocol (grpc, http/protobuf, http/json). /// /// **Default**: `(empty, defaults to grpc)` @@ -1894,26 +1461,6 @@ impl ConfigBuilder { self } - /// Set the OTLP metrics timeout in milliseconds. - /// - /// **Default**: `7500` - /// - /// Env variable: `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` - pub fn set_otlp_metrics_timeout(&mut self, timeout: u32) -> &mut Self { - self.config.otlp_metrics_timeout.set_code(timeout); - self - } - - /// Set the OTLP general timeout in milliseconds (fallback for metrics timeout). - /// - /// **Default**: `7500` - /// - /// Env variable: `OTEL_EXPORTER_OTLP_TIMEOUT` - pub fn set_otlp_timeout(&mut self, timeout: u32) -> &mut Self { - self.config.otlp_timeout.set_code(timeout); - self - } - /// Set the OTLP metrics temporality preference. /// /// **Default**: `Delta` @@ -1929,58 +1476,6 @@ impl ConfigBuilder { self } - /// Set the metric export interval in milliseconds. - /// - /// **Default**: `10000` - /// - /// Env variable: `OTEL_METRIC_EXPORT_INTERVAL` - pub fn set_metric_export_interval(&mut self, interval: u32) -> &mut Self { - self.config.metric_export_interval.set_code(interval); - self - } - - /// Set the metric export timeout in milliseconds. - /// - /// **Default**: `7500` - /// - /// Env variable: `OTEL_METRIC_EXPORT_TIMEOUT` - pub fn set_metric_export_timeout(&mut self, timeout: u32) -> &mut Self { - self.config.metric_export_timeout.set_code(timeout); - self - } - - /// Sets the hostname for DogStatsD metric collection. - /// - /// **Default**: `localhost` - /// - /// Env variable: `DD_DOGSTATSD_HOST` - pub fn set_dogstatsd_agent_host(&mut self, host: String) -> &mut Self { - self.config - .dogstatsd_agent_host - .set_code(Cow::Owned(host.to_string())); - self - } - - /// Sets the port for DogStatsD metric collection. - /// - /// **Default**: `8125` - /// - /// Env variable: `DD_DOGSTATSD_PORT` - pub fn set_dogstatsd_agent_port(&mut self, port: u32) -> &mut Self { - self.config.dogstatsd_agent_port.set_code(port); - self - } - - /// Enable partial flushing of traces. - /// - /// **Default**: `false` - /// - /// Env variable: `DD_TRACE_PARTIAL_FLUSH_ENABLED` - pub fn set_trace_partial_flush_enabled(&mut self, enabled: bool) -> &mut Self { - self.config.trace_partial_flush_enabled.set_code(enabled); - self - } - /// Minimum number of spans in a trace before partial flush is triggered. /// /// **Default**: `300` @@ -2060,26 +1555,6 @@ impl ConfigBuilder { self } - /// When set to `true`, stops extracting after the first successful trace context extraction. - /// - /// **Default**: `false` - /// - /// Env variable: `DD_TRACE_PROPAGATION_EXTRACT_FIRST` - pub fn set_trace_propagation_extract_first(&mut self, first: bool) -> &mut Self { - self.config.trace_propagation_extract_first.set_code(first); - self - } - - /// Set to `false` to disable tracing. - /// - /// **Default**: `true` - /// - /// Env variable: `DD_TRACE_ENABLED` - pub fn set_enabled(&mut self, enabled: bool) -> &mut Self { - self.config.enabled.set_code(enabled); - self - } - /// Sets the internal log level for the tracer. /// /// **Default**: `Error` @@ -2090,31 +1565,6 @@ impl ConfigBuilder { self } - /// Enable computation of trace statistics. - /// - /// **Default**: `true` - /// - /// Env variable: `DD_TRACE_STATS_COMPUTATION_ENABLED` - pub fn set_trace_stats_computation_enabled( - &mut self, - trace_stats_computation_enabled: bool, - ) -> &mut Self { - self.config - .trace_stats_computation_enabled - .set_code(trace_stats_computation_enabled); - self - } - - /// Enable or disable remote configuration. - /// - /// **Default**: `true` - /// - /// Env variable: `DD_REMOTE_CONFIGURATION_ENABLED` - pub fn set_remote_config_enabled(&mut self, enabled: bool) -> &mut Self { - self.config.remote_config_enabled.set_code(enabled); - self - } - /// Interval in seconds for polling remote configuration updates. /// /// **Default**: `5.0` diff --git a/datadog-opentelemetry/src/core/configuration/mod.rs b/datadog-opentelemetry/src/core/configuration/mod.rs index 257abcce..cf1b0eaf 100644 --- a/datadog-opentelemetry/src/core/configuration/mod.rs +++ b/datadog-opentelemetry/src/core/configuration/mod.rs @@ -23,7 +23,8 @@ mod configuration; pub(crate) mod remote_config; mod sources; -mod supported_configurations; pub use configuration::{Config, ConfigBuilder, SamplingRuleConfig, TracePropagationStyle}; -pub(crate) use configuration::{ConfigurationProvider, RemoteConfigUpdate}; +pub(crate) use configuration::{ + is_alias_deprecated, ConfigurationProvider, RemoteConfigUpdate, SupportedConfigurations, +}; diff --git a/datadog-opentelemetry/src/core/configuration/sources.rs b/datadog-opentelemetry/src/core/configuration/sources.rs index f99b7539..546abc0b 100644 --- a/datadog-opentelemetry/src/core/configuration/sources.rs +++ b/datadog-opentelemetry/src/core/configuration/sources.rs @@ -7,7 +7,7 @@ use libdd_telemetry::data::ConfigurationOrigin; use crate::dd_warn; -use super::supported_configurations::{is_alias_deprecated, SupportedConfigurations}; +use super::configuration::{is_alias_deprecated, SupportedConfigurations}; /// Source of a configuration value #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -266,7 +266,7 @@ mod tests { HashMapSource, }; use crate::core::configuration::sources::ConfigKey; - use crate::core::configuration::supported_configurations::SupportedConfigurations; + use crate::core::configuration::SupportedConfigurations; #[test] fn test_composite_source_single_origin() { diff --git a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs index b42f4074..5c9388fb 100644 --- a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs +++ b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs @@ -4,10 +4,17 @@ /// This file is generated by the scripts/local_config_map_generate.py script. /// Do not edit this file manually. To add a new configuration, /// add it to the supported-configurations.json file, then run this script. +use std::borrow::Cow; +use std::sync::{Arc, Mutex}; + +use rustc_version_runtime::version; + +use super::*; + #[allow(nonstandard_style)] #[derive(Debug, PartialEq, Copy, Clone)] #[non_exhaustive] -pub(crate) enum SupportedConfigurations { +pub enum SupportedConfigurations { DD_AGENT_HOST, DD_DOGSTATSD_HOST, DD_DOGSTATSD_PORT, @@ -181,7 +188,7 @@ impl SupportedConfigurations { } } -pub(crate) fn is_alias_deprecated(name: &str) -> bool { +pub fn is_alias_deprecated(name: &str) -> bool { match name { "DD_REMOTE_CONFIG_ENABLED" => true, #[cfg(test)] @@ -189,3 +196,409 @@ pub(crate) fn is_alias_deprecated(name: &str) -> bool { _ => false, } } + +#[allow(missing_docs)] +impl Config { + pub fn agent_host(&self) -> &str { + self.agent_host.value().as_ref() + } + + pub fn dogstatsd_agent_host(&self) -> &str { + self.dogstatsd_agent_host.value().as_ref() + } + + pub fn dogstatsd_agent_port(&self) -> u32 { + *self.dogstatsd_agent_port.value() + } + + pub fn telemetry_enabled(&self) -> bool { + *self.telemetry_enabled.value() + } + + pub fn metrics_otel_enabled(&self) -> bool { + *self.metrics_otel_enabled.value() + } + + pub fn remote_config_enabled(&self) -> bool { + *self.remote_config_enabled.value() + } + + pub fn telemetry_log_collection_enabled(&self) -> bool { + *self.telemetry_log_collection_enabled.value() + } + + pub fn trace_agent_port(&self) -> u32 { + *self.trace_agent_port.value() + } + + pub fn trace_agent_url(&self) -> &str { + self.trace_agent_url.value().as_ref() + } + + pub fn enabled(&self) -> bool { + *self.enabled.value() + } + + pub fn trace_partial_flush_enabled(&self) -> bool { + *self.trace_partial_flush_enabled.value() + } + + pub fn trace_propagation_extract_first(&self) -> bool { + *self.trace_propagation_extract_first.value() + } + + pub fn trace_stats_computation_enabled(&self) -> bool { + *self.trace_stats_computation_enabled.value() + } + + pub fn otlp_endpoint(&self) -> &str { + self.otlp_endpoint.value().as_ref() + } + + pub fn otlp_metrics_endpoint(&self) -> &str { + self.otlp_metrics_endpoint.value().as_ref() + } + + pub fn otlp_metrics_timeout(&self) -> u32 { + *self.otlp_metrics_timeout.value() + } + + pub fn otlp_timeout(&self) -> u32 { + *self.otlp_timeout.value() + } + + pub fn otel_metrics_exporter(&self) -> &str { + self.otel_metrics_exporter.value().as_ref() + } + + pub fn metric_export_interval(&self) -> u32 { + *self.metric_export_interval.value() + } + + pub fn metric_export_timeout(&self) -> u32 { + *self.metric_export_timeout.value() + } + + pub(crate) fn get_telemetry_configuration(&self) -> Vec<&dyn ConfigurationProvider> { + vec![ + &self.agent_host, + &self.dogstatsd_agent_host, + &self.dogstatsd_agent_port, + &self.dogstatsd_agent_url, + &self.env, + &self.telemetry_enabled, + &self.log_level_filter, + &self.metrics_otel_enabled, + &self.remote_config_enabled, + &self.remote_config_poll_interval, + &self.service, + &self.global_tags, + &self.telemetry_heartbeat_interval, + &self.telemetry_log_collection_enabled, + &self.trace_agent_port, + &self.trace_agent_url, + &self.enabled, + &self.trace_partial_flush_enabled, + &self.trace_partial_flush_min_spans, + &self.trace_propagation_extract_first, + &self.trace_propagation_style, + &self.trace_propagation_style_extract, + &self.trace_propagation_style_inject, + &self.trace_rate_limit, + &self.trace_sampling_rules, + &self.trace_stats_computation_enabled, + &self.datadog_tags_max_length, + &self.version, + &self.otlp_endpoint, + &self.otlp_headers, + &self.otlp_metrics_endpoint, + &self.otlp_metrics_headers, + &self.otlp_metrics_protocol, + &self.otel_metrics_temporality_preference, + &self.otlp_metrics_timeout, + &self.otlp_protocol, + &self.otlp_timeout, + &self.otel_metrics_exporter, + &self.metric_export_interval, + &self.metric_export_timeout, + &self.otel_resource_attributes, + ] + } +} + +#[allow(missing_docs)] +impl ConfigBuilder { + pub fn set_agent_host(&mut self, val: String) -> &mut Self { + self.config.agent_host.set_code(Cow::Owned(val)); + self + } + + pub fn set_dogstatsd_agent_host(&mut self, val: String) -> &mut Self { + self.config.dogstatsd_agent_host.set_code(Cow::Owned(val)); + self + } + + pub fn set_dogstatsd_agent_port(&mut self, val: u32) -> &mut Self { + self.config.dogstatsd_agent_port.set_code(val); + self + } + + pub fn set_telemetry_enabled(&mut self, val: bool) -> &mut Self { + self.config.telemetry_enabled.set_code(val); + self + } + + pub fn set_metrics_otel_enabled(&mut self, val: bool) -> &mut Self { + self.config.metrics_otel_enabled.set_code(val); + self + } + + pub fn set_remote_config_enabled(&mut self, val: bool) -> &mut Self { + self.config.remote_config_enabled.set_code(val); + self + } + + pub fn set_telemetry_log_collection_enabled(&mut self, val: bool) -> &mut Self { + self.config.telemetry_log_collection_enabled.set_code(val); + self + } + + pub fn set_trace_agent_port(&mut self, val: u32) -> &mut Self { + self.config.trace_agent_port.set_code(val); + self + } + + pub fn set_trace_agent_url(&mut self, val: String) -> &mut Self { + self.config.trace_agent_url.set_code(Cow::Owned(val)); + self + } + + pub fn set_enabled(&mut self, val: bool) -> &mut Self { + self.config.enabled.set_code(val); + self + } + + pub fn set_trace_partial_flush_enabled(&mut self, val: bool) -> &mut Self { + self.config.trace_partial_flush_enabled.set_code(val); + self + } + + pub fn set_trace_propagation_extract_first(&mut self, val: bool) -> &mut Self { + self.config.trace_propagation_extract_first.set_code(val); + self + } + + pub fn set_trace_stats_computation_enabled(&mut self, val: bool) -> &mut Self { + self.config.trace_stats_computation_enabled.set_code(val); + self + } + + pub fn set_otlp_endpoint(&mut self, val: String) -> &mut Self { + self.config.otlp_endpoint.set_code(Cow::Owned(val)); + self + } + + pub fn set_otlp_metrics_endpoint(&mut self, val: String) -> &mut Self { + self.config.otlp_metrics_endpoint.set_code(Cow::Owned(val)); + self + } + + pub fn set_otlp_metrics_timeout(&mut self, val: u32) -> &mut Self { + self.config.otlp_metrics_timeout.set_code(val); + self + } + + pub fn set_otlp_timeout(&mut self, val: u32) -> &mut Self { + self.config.otlp_timeout.set_code(val); + self + } + + pub fn set_otel_metrics_exporter(&mut self, val: String) -> &mut Self { + self.config.otel_metrics_exporter.set_code(Cow::Owned(val)); + self + } + + pub fn set_metric_export_interval(&mut self, val: u32) -> &mut Self { + self.config.metric_export_interval.set_code(val); + self + } + + pub fn set_metric_export_timeout(&mut self, val: u32) -> &mut Self { + self.config.metric_export_timeout.set_code(val); + self + } +} + +pub(super) fn default_config() -> Config { + use SupportedConfigurations as S; + Config { + runtime_id: Config::process_runtime_id(), + tracer_version: TRACER_VERSION, + language: "rust", + language_version: version().to_string(), + #[cfg(feature = "test-utils")] + wait_agent_info_ready: false, + extra_services_tracker: ExtraServicesTracker::new(), + remote_config_callbacks: Arc::new(Mutex::new(RemoteConfigCallbacks::new())), + agent_host: ConfigItem::new(S::DD_AGENT_HOST, Cow::Borrowed("localhost")), + dogstatsd_agent_host: ConfigItem::new(S::DD_DOGSTATSD_HOST, Cow::Borrowed("localhost")), + dogstatsd_agent_port: ConfigItem::new(S::DD_DOGSTATSD_PORT, 8125), + dogstatsd_agent_url: ConfigItem::new(S::DD_DOGSTATSD_URL, Cow::Borrowed("")), + env: ConfigItem::new(S::DD_ENV, None), + telemetry_enabled: ConfigItem::new(S::DD_INSTRUMENTATION_TELEMETRY_ENABLED, true), + log_level_filter: ConfigItem::new(S::DD_LOG_LEVEL, LevelFilter::default()), + metrics_otel_enabled: ConfigItem::new(S::DD_METRICS_OTEL_ENABLED, true), + remote_config_enabled: ConfigItem::new(S::DD_REMOTE_CONFIGURATION_ENABLED, true), + remote_config_poll_interval: ConfigItem::new( + S::DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS, + 5.0, + ), + service: ConfigItemWithOverride::new_code(S::DD_SERVICE, ServiceName::Default), + global_tags: ConfigItem::new(S::DD_TAGS, Vec::new()), + telemetry_heartbeat_interval: ConfigItem::new(S::DD_TELEMETRY_HEARTBEAT_INTERVAL, 60.0), + telemetry_log_collection_enabled: ConfigItem::new( + S::DD_TELEMETRY_LOG_COLLECTION_ENABLED, + true, + ), + trace_agent_port: ConfigItem::new(S::DD_TRACE_AGENT_PORT, 8126), + trace_agent_url: ConfigItem::new(S::DD_TRACE_AGENT_URL, Cow::Borrowed("")), + enabled: ConfigItem::new(S::DD_TRACE_ENABLED, true), + trace_partial_flush_enabled: ConfigItem::new(S::DD_TRACE_PARTIAL_FLUSH_ENABLED, false), + trace_partial_flush_min_spans: ConfigItem::new( + S::DD_TRACE_PARTIAL_FLUSH_MIN_SPANS, + 300usize, + ), + trace_propagation_extract_first: ConfigItem::new( + S::DD_TRACE_PROPAGATION_EXTRACT_FIRST, + false, + ), + trace_propagation_style: ConfigItem::new( + S::DD_TRACE_PROPAGATION_STYLE, + Some(vec![ + TracePropagationStyle::Datadog, + TracePropagationStyle::TraceContext, + ]), + ), + trace_propagation_style_extract: ConfigItem::new( + S::DD_TRACE_PROPAGATION_STYLE_EXTRACT, + None, + ), + trace_propagation_style_inject: ConfigItem::new(S::DD_TRACE_PROPAGATION_STYLE_INJECT, None), + trace_rate_limit: ConfigItem::new(S::DD_TRACE_RATE_LIMIT, 100i32), + trace_sampling_rules: ConfigItemWithOverride::new_rc( + S::DD_TRACE_SAMPLING_RULES, + ParsedSamplingRules::default(), + ), + trace_stats_computation_enabled: ConfigItem::new( + S::DD_TRACE_STATS_COMPUTATION_ENABLED, + true, + ), + datadog_tags_max_length: ConfigItem::new(S::DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH, 512usize), + version: ConfigItem::new(S::DD_VERSION, None), + otlp_endpoint: ConfigItem::new(S::OTEL_EXPORTER_OTLP_ENDPOINT, Cow::Borrowed("")), + otlp_headers: ConfigItem::new(S::OTEL_EXPORTER_OTLP_HEADERS, Cow::Borrowed("")), + otlp_metrics_endpoint: ConfigItem::new( + S::OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, + Cow::Borrowed(""), + ), + otlp_metrics_headers: ConfigItem::new( + S::OTEL_EXPORTER_OTLP_METRICS_HEADERS, + Cow::Borrowed(""), + ), + otlp_metrics_protocol: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_PROTOCOL, None), + otel_metrics_temporality_preference: ConfigItem::new( + S::OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, + Some(opentelemetry_sdk::metrics::Temporality::Delta), + ), + otlp_metrics_timeout: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_TIMEOUT, 0), + otlp_protocol: ConfigItem::new(S::OTEL_EXPORTER_OTLP_PROTOCOL, None), + otlp_timeout: ConfigItem::new(S::OTEL_EXPORTER_OTLP_TIMEOUT, 10000), + otel_metrics_exporter: ConfigItem::new(S::OTEL_METRICS_EXPORTER, Cow::Borrowed("otlp")), + metric_export_interval: ConfigItem::new(S::OTEL_METRIC_EXPORT_INTERVAL, 10000), + metric_export_timeout: ConfigItem::new(S::OTEL_METRIC_EXPORT_TIMEOUT, 7500), + otel_resource_attributes: ConfigItem::new(S::OTEL_RESOURCE_ATTRIBUTES, Vec::new()), + } +} + +impl std::fmt::Debug for Config { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Config") + .field("runtime_id", &self.runtime_id) + .field("tracer_version", &self.tracer_version) + .field("language_version", &self.language_version) + .field("agent_host", &self.agent_host) + .field("dogstatsd_agent_host", &self.dogstatsd_agent_host) + .field("dogstatsd_agent_port", &self.dogstatsd_agent_port) + .field("dogstatsd_agent_url", &self.dogstatsd_agent_url) + .field("env", &self.env) + .field("telemetry_enabled", &self.telemetry_enabled) + .field("log_level_filter", &self.log_level_filter) + .field("metrics_otel_enabled", &self.metrics_otel_enabled) + .field("remote_config_enabled", &self.remote_config_enabled) + .field( + "remote_config_poll_interval", + &self.remote_config_poll_interval, + ) + .field("service", &self.service) + .field("global_tags", &self.global_tags) + .field( + "telemetry_heartbeat_interval", + &self.telemetry_heartbeat_interval, + ) + .field( + "telemetry_log_collection_enabled", + &self.telemetry_log_collection_enabled, + ) + .field("trace_agent_port", &self.trace_agent_port) + .field("trace_agent_url", &self.trace_agent_url) + .field("enabled", &self.enabled) + .field( + "trace_partial_flush_enabled", + &self.trace_partial_flush_enabled, + ) + .field( + "trace_partial_flush_min_spans", + &self.trace_partial_flush_min_spans, + ) + .field( + "trace_propagation_extract_first", + &self.trace_propagation_extract_first, + ) + .field("trace_propagation_style", &self.trace_propagation_style) + .field( + "trace_propagation_style_extract", + &self.trace_propagation_style_extract, + ) + .field( + "trace_propagation_style_inject", + &self.trace_propagation_style_inject, + ) + .field("trace_rate_limit", &self.trace_rate_limit) + .field("trace_sampling_rules", &self.trace_sampling_rules) + .field( + "trace_stats_computation_enabled", + &self.trace_stats_computation_enabled, + ) + .field("datadog_tags_max_length", &self.datadog_tags_max_length) + .field("version", &self.version) + .field("otlp_endpoint", &self.otlp_endpoint) + .field("otlp_headers", &self.otlp_headers) + .field("otlp_metrics_endpoint", &self.otlp_metrics_endpoint) + .field("otlp_metrics_headers", &self.otlp_metrics_headers) + .field("otlp_metrics_protocol", &self.otlp_metrics_protocol) + .field( + "otel_metrics_temporality_preference", + &self.otel_metrics_temporality_preference, + ) + .field("otlp_metrics_timeout", &self.otlp_metrics_timeout) + .field("otlp_protocol", &self.otlp_protocol) + .field("otlp_timeout", &self.otlp_timeout) + .field("otel_metrics_exporter", &self.otel_metrics_exporter) + .field("metric_export_interval", &self.metric_export_interval) + .field("metric_export_timeout", &self.metric_export_timeout) + .field("otel_resource_attributes", &self.otel_resource_attributes) + .field("extra_services_tracker", &self.extra_services_tracker) + .field("remote_config_callbacks", &self.remote_config_callbacks) + .finish() + } +} diff --git a/scripts/local_config_map_generate.py b/scripts/local_config_map_generate.py index 756fb3fb..f672fb4c 100644 --- a/scripts/local_config_map_generate.py +++ b/scripts/local_config_map_generate.py @@ -12,7 +12,10 @@ "deprecated": False, }, "DD_NONEXISTANT_CONFIGURATION": { - "aliases": ["DD_NONEXISTANT_CONFIGURATION_ALIAS", "DD_NONEXISTANT_CONFIGURATION_DEPRECATED_ALIAS"], + "aliases": [ + "DD_NONEXISTANT_CONFIGURATION_ALIAS", + "DD_NONEXISTANT_CONFIGURATION_DEPRECATED_ALIAS", + ], "deprecated": False, }, "DD_NONEXISTANT_CONFIGURATION_ALIAS": { @@ -25,55 +28,205 @@ }, } +# JSON type → Rust type +TYPE_MAP = { + "string": "Cow<'static, str>", + "int": "u32", + "decimal": "f64", + "boolean": "bool", + "map": "Vec<(String, String)>", + "array": "Option>", +} + +# ── Build blocks from JSON ─────────────────────────────────────────────────── + enum_block = "" as_str_block = "" aliases_block = [] alias_deprecated_block = [] deprecated_block = [] -for i, key in enumerate(supported_configurations["supportedConfigurations"].keys()): +getter_lines = [] +setter_lines = [] +telemetry_lines = [] +debug_lines = [] +default_config_lines = [] + +for i, (key, versions) in enumerate( + supported_configurations["supportedConfigurations"].items() +): if i != 0: enum_block += "\n" as_str_block += "\n" - enum_block += f" {key}," - as_str_block += f" SupportedConfigurations::{key} => \"{key}\"," + + enum_block += " {},".format(key) + as_str_block += ' SupportedConfigurations::{} => "{}",'.format(key, key) + + json_type = versions[0]["type"] + default_val = versions[0].get("default") + property_keys = versions[0].get("propertyKeys", []) + field_name = property_keys[0] if property_keys else None + skip = versions[0].get("skip_default_generation", False) + + # Build getter/setter lines for simple types + if not skip and field_name and json_type in ("string", "int", "decimal", "boolean"): + if json_type == "string": + getter_lines.append( + " pub fn {}(&self) -> &str {{ self.{}.value().as_ref() }}".format( + field_name, field_name + ) + ) + setter_lines.append( + " pub fn set_{}(&mut self, val: String) -> &mut Self {{ self.config.{}.set_code(Cow::Owned(val)); self }}".format( + field_name, field_name + ) + ) + elif json_type == "int": + getter_lines.append( + " pub fn {}(&self) -> u32 {{ *self.{}.value() }}".format( + field_name, field_name + ) + ) + setter_lines.append( + " pub fn set_{}(&mut self, val: u32) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + field_name, field_name + ) + ) + elif json_type == "decimal": + getter_lines.append( + " pub fn {}(&self) -> f64 {{ *self.{}.value() }}".format( + field_name, field_name + ) + ) + setter_lines.append( + " pub fn set_{}(&mut self, val: f64) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + field_name, field_name + ) + ) + elif json_type == "boolean": + getter_lines.append( + " pub fn {}(&self) -> bool {{ *self.{}.value() }}".format( + field_name, field_name + ) + ) + setter_lines.append( + " pub fn set_{}(&mut self, val: bool) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + field_name, field_name + ) + ) + + # Build default_config() field line + if field_name: + rust_value = versions[0].get("rust_value") + config_item_type = versions[0].get("config_item_type") + if rust_value is not None: + if config_item_type == "override_code": + default_config_lines.append( + " {}: ConfigItemWithOverride::new_code(S::{}, {}),".format( + field_name, key, rust_value + ) + ) + elif config_item_type == "override_rc": + default_config_lines.append( + " {}: ConfigItemWithOverride::new_rc(S::{}, {}),".format( + field_name, key, rust_value + ) + ) + else: + default_config_lines.append( + " {}: ConfigItem::new(S::{}, {}),".format( + field_name, key, rust_value + ) + ) + elif not skip: + rust_val = None + if json_type == "string": + rust_val = 'Cow::Borrowed("{}")'.format(default_val or "") + elif json_type == "int": + rust_val = str(int(default_val)) if default_val is not None else "0" + elif json_type == "decimal": + rust_val = str(float(default_val)) if default_val is not None else "0.0" + elif json_type == "boolean": + rust_val = ("true" if default_val == "true" else "false") if default_val is not None else "false" + elif json_type == "map": + rust_val = "Vec::new()" + if rust_val is not None: + default_config_lines.append( + " {}: ConfigItem::new(S::{}, {}),".format(field_name, key, rust_val) + ) + + # Build telemetry config and Debug lines for ALL configs with propertyKeys + if field_name: + telemetry_lines.append(" &self.{},".format(field_name)) + debug_lines.append( + ' .field("{}", &self.{})'.format(field_name, field_name) + ) + + # Aliases and deprecation aliases_accumulator = [] - deprecated = False - for version in supported_configurations["supportedConfigurations"][key]: + for version in versions: if "aliases" in version: for alias in version["aliases"]: aliases_accumulator.append(alias) - if alias not in supported_configurations["supportedConfigurations"].keys(): - alias_deprecated_block.append(f"\"{alias}\" => true,") + if alias not in supported_configurations["supportedConfigurations"]: + alias_deprecated_block.append('"{}" => true,'.format(alias)) if "deprecated" in version and version["deprecated"]: - deprecated_block.append(f"SupportedConfigurations::{key} => true,") - if len(aliases_accumulator) > 0: - aliases_block.append(f"SupportedConfigurations::{key} => &[{', '.join(f'\"{a}\"' for a in aliases_accumulator)}],") - + deprecated_block.append( + "SupportedConfigurations::{} => true,".format(key) + ) + if aliases_accumulator: + quoted = ", ".join('"{}"'.format(a) for a in aliases_accumulator) + aliases_block.append( + "SupportedConfigurations::{} => &[{}],".format(key, quoted) + ) -if len(undocumented_configurations) > 0: +# Undocumented test configurations +if undocumented_configurations: enum_block += "\n\n /// Used for testing purposes only" -for i, key in enumerate(undocumented_configurations): - enum_block += f"\n #[cfg(test)]\n #[allow(unused)]\n {key}," - as_str_block += f"\n #[cfg(test)]\n SupportedConfigurations::{key} => \"{key}\"," - if len(undocumented_configurations[key]["aliases"]) > 0: - aliases_block.append(f"#[cfg(test)]\n SupportedConfigurations::{key} => &[{', '.join(f'\"{a}\"' for a in undocumented_configurations[key]["aliases"])}],") - if undocumented_configurations[key]["deprecated"]: - deprecated_block.append(f"#[cfg(test)]\n SupportedConfigurations::{key} => true,") - for alias in undocumented_configurations[key]["aliases"]: - if alias not in undocumented_configurations.keys(): - alias_deprecated_block.append(f"#[cfg(test)]\n \"{alias}\" => true,") - -result = f"""\ +for key in undocumented_configurations: + conf = undocumented_configurations[key] + enum_block += "\n #[cfg(test)]\n #[allow(unused)]\n {},".format(key) + as_str_block += '\n #[cfg(test)]\n SupportedConfigurations::{} => "{}",'.format( + key, key + ) + if conf["aliases"]: + quoted = ", ".join('"{}"'.format(a) for a in conf["aliases"]) + aliases_block.append( + "#[cfg(test)]\n SupportedConfigurations::{} => &[{}],".format( + key, quoted + ) + ) + if conf["deprecated"]: + deprecated_block.append( + "#[cfg(test)]\n SupportedConfigurations::{} => true,".format(key) + ) + for alias in conf["aliases"]: + if alias not in undocumented_configurations: + alias_deprecated_block.append( + '#[cfg(test)]\n "{}" => true,'.format(alias) + ) + +# ── Assemble template ──────────────────────────────────────────────────────── + +NL = "\n " + +result = """\ // Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 /// This file is generated by the scripts/local_config_map_generate.py script. /// Do not edit this file manually. To add a new configuration, /// add it to the supported-configurations.json file, then run this script. +use std::borrow::Cow; +use std::sync::{{Arc, Mutex}}; + +use rustc_version_runtime::version; + +use super::*; + #[allow(nonstandard_style)] #[derive(Debug, PartialEq, Copy, Clone)] #[non_exhaustive] -pub(crate) enum SupportedConfigurations {{ +pub enum SupportedConfigurations {{ {enum_block} }} @@ -86,29 +239,85 @@ pub fn aliases(&self) -> &[&'static str] {{ match self {{ - {"\n ".join(aliases_block)} + {aliases_joined} _ => &[], }} }} pub fn is_deprecated(&self) -> bool {{ match self {{ - {"\n ".join(deprecated_block)} + {deprecated_joined} _ => false, }} }} }} -pub(crate) fn is_alias_deprecated(name: &str) -> bool {{ +pub fn is_alias_deprecated(name: &str) -> bool {{ match name {{ - {"\n ".join(alias_deprecated_block)} + {alias_deprecated_joined} _ => false, }} }} -""" -with open("datadog-opentelemetry/src/core/configuration/supported_configurations.rs", "w") as f: +#[allow(missing_docs)] +impl Config {{ +{getters_block} + + pub(crate) fn get_telemetry_configuration(&self) -> Vec<&dyn ConfigurationProvider> {{ + vec![ +{telemetry_block} + ] + }} +}} + +#[allow(missing_docs)] +impl ConfigBuilder {{ +{setters_block} +}} + +pub(super) fn default_config() -> Config {{ + use SupportedConfigurations as S; + Config {{ + runtime_id: Config::process_runtime_id(), + tracer_version: TRACER_VERSION, + language: "rust", + language_version: version().to_string(), + #[cfg(feature = "test-utils")] + wait_agent_info_ready: false, + extra_services_tracker: ExtraServicesTracker::new(), + remote_config_callbacks: Arc::new(Mutex::new(RemoteConfigCallbacks::new())), +{default_config_block} + }} +}} + +impl std::fmt::Debug for Config {{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {{ + f.debug_struct("Config") + .field("runtime_id", &self.runtime_id) + .field("tracer_version", &self.tracer_version) + .field("language_version", &self.language_version) +{debug_block} + .field("extra_services_tracker", &self.extra_services_tracker) + .field("remote_config_callbacks", &self.remote_config_callbacks) + .finish() + }} +}} +""".format( + enum_block=enum_block, + as_str_block=as_str_block, + aliases_joined=NL.join(aliases_block), + deprecated_joined=NL.join(deprecated_block), + alias_deprecated_joined=NL.join(alias_deprecated_block), + default_config_block="\n".join(default_config_lines), + getters_block="\n\n".join(getter_lines), + setters_block="\n\n".join(setter_lines), + telemetry_block="\n".join(telemetry_lines), + debug_block="\n".join(debug_lines), +) + +OUTPUT = "datadog-opentelemetry/src/core/configuration/supported_configurations.rs" +with open(OUTPUT, "w") as f: f.write(result) -# run cargo fmt -subprocess.run(["rustfmt", "datadog-opentelemetry/src/core/configuration/supported_configurations.rs"]) +subprocess.run(["rustfmt", OUTPUT]) +print("Done.") diff --git a/supported-configurations.json b/supported-configurations.json index b21498f4..7c36ef50 100644 --- a/supported-configurations.json +++ b/supported-configurations.json @@ -31,7 +31,9 @@ "version": "A", "type": "string", "default": "http://localhost:8125", - "propertyKeys": ["dogstatsd_agent_url"] + "propertyKeys": ["dogstatsd_agent_url"], + "skip_default_generation": true, + "rust_value": "Cow::Borrowed(\"\")" } ], "DD_ENV": [ @@ -39,7 +41,9 @@ "version": "A", "type": "string", "default": "", - "propertyKeys": ["env"] + "propertyKeys": ["env"], + "skip_default_generation": true, + "rust_value": "None" } ], "DD_INSTRUMENTATION_TELEMETRY_ENABLED": [ @@ -55,7 +59,9 @@ "version": "A", "type": "string", "default": "ERROR", - "propertyKeys": ["log_level_filter"] + "propertyKeys": ["log_level_filter"], + "skip_default_generation": true, + "rust_value": "LevelFilter::default()" } ], "DD_METRICS_OTEL_ENABLED": [ @@ -80,7 +86,9 @@ "version": "A", "type": "decimal", "default": "5.0", - "propertyKeys": ["remote_config_poll_interval"] + "propertyKeys": ["remote_config_poll_interval"], + "skip_default_generation": true, + "rust_value": "5.0" } ], "DD_SERVICE": [ @@ -88,7 +96,10 @@ "version": "C", "type": "string", "default": "unnamed-rust-service", - "propertyKeys": ["service"] + "propertyKeys": ["service"], + "skip_default_generation": true, + "rust_value": "ServiceName::Default", + "config_item_type": "override_code" } ], "DD_TAGS": [ @@ -104,7 +115,9 @@ "version": "B", "type": "decimal", "default": "60.0", - "propertyKeys": ["telemetry_heartbeat_interval"] + "propertyKeys": ["telemetry_heartbeat_interval"], + "skip_default_generation": true, + "rust_value": "60.0" } ], "DD_TELEMETRY_LOG_COLLECTION_ENABLED": [ @@ -144,7 +157,7 @@ "version": "A", "type": "boolean", "default": "false", - "propertyKeys": ["trace_partial_flushed_enabled"] + "propertyKeys": ["trace_partial_flush_enabled"] } ], "DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": [ @@ -152,7 +165,9 @@ "version": "A", "type": "int", "default": "300", - "propertyKeys": ["trace_partial_flushed_min_spans"] + "propertyKeys": ["trace_partial_flush_min_spans"], + "skip_default_generation": true, + "rust_value": "300usize" } ], "DD_TRACE_PROPAGATION_EXTRACT_FIRST": [ @@ -168,7 +183,9 @@ "version": "A", "type": "array", "default": "datadog,tracecontext", - "propertyKeys": ["trace_propagation_style"] + "propertyKeys": ["trace_propagation_style"], + "skip_default_generation": true, + "rust_value": "Some(vec![TracePropagationStyle::Datadog, TracePropagationStyle::TraceContext])" } ], "DD_TRACE_PROPAGATION_STYLE_EXTRACT": [ @@ -176,7 +193,9 @@ "version": "A", "type": "array", "default": "", - "propertyKeys": ["trace_propagation_style_extract"] + "propertyKeys": ["trace_propagation_style_extract"], + "skip_default_generation": true, + "rust_value": "None" } ], "DD_TRACE_PROPAGATION_STYLE_INJECT": [ @@ -184,7 +203,9 @@ "version": "A", "type": "array", "default": "", - "propertyKeys": ["trace_propagation_style_inject"] + "propertyKeys": ["trace_propagation_style_inject"], + "skip_default_generation": true, + "rust_value": "None" } ], "DD_TRACE_RATE_LIMIT": [ @@ -192,7 +213,9 @@ "version": "A", "type": "int", "default": "100", - "propertyKeys": ["trace_rate_limit"] + "propertyKeys": ["trace_rate_limit"], + "skip_default_generation": true, + "rust_value": "100i32" } ], "DD_TRACE_SAMPLING_RULES": [ @@ -200,7 +223,10 @@ "version": "A", "type": "array", "default": "", - "propertyKeys": ["trace_sampling_rules"] + "propertyKeys": ["trace_sampling_rules"], + "skip_default_generation": true, + "rust_value": "ParsedSamplingRules::default()", + "config_item_type": "override_rc" } ], "DD_TRACE_STATS_COMPUTATION_ENABLED": [ @@ -216,7 +242,9 @@ "version": "A", "type": "int", "default": "512", - "propertyKeys": ["datadog_tags_max_length"] + "propertyKeys": ["datadog_tags_max_length"], + "skip_default_generation": true, + "rust_value": "512usize" } ], "DD_VERSION": [ @@ -224,7 +252,9 @@ "version": "A", "type": "string", "default": "", - "propertyKeys": ["version"] + "propertyKeys": ["version"], + "skip_default_generation": true, + "rust_value": "None" } ], "OTEL_EXPORTER_OTLP_ENDPOINT": [ @@ -240,7 +270,9 @@ "version": "A", "type": "map", "default": "", - "propertyKeys": ["otlp_headers"] + "propertyKeys": ["otlp_headers"], + "skip_default_generation": true, + "rust_value": "Cow::Borrowed(\"\")" } ], "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT": [ @@ -256,7 +288,9 @@ "version": "A", "type": "map", "default": null, - "propertyKeys": ["otlp_metrics_headers"] + "propertyKeys": ["otlp_metrics_headers"], + "skip_default_generation": true, + "rust_value": "Cow::Borrowed(\"\")" } ], "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL": [ @@ -264,7 +298,9 @@ "version": "A", "type": "string", "default": null, - "propertyKeys": ["otlp_metrics_protocol"] + "propertyKeys": ["otlp_metrics_protocol"], + "skip_default_generation": true, + "rust_value": "None" } ], "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE": [ @@ -272,7 +308,9 @@ "version": "A", "type": "string", "default": "delta", - "propertyKeys": ["otel_metrics_temporality_preference"] + "propertyKeys": ["otel_metrics_temporality_preference"], + "skip_default_generation": true, + "rust_value": "Some(opentelemetry_sdk::metrics::Temporality::Delta)" } ], "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": [ @@ -288,7 +326,9 @@ "version": "C", "type": "string", "default": "grpc", - "propertyKeys": ["otlp_protocol"] + "propertyKeys": ["otlp_protocol"], + "skip_default_generation": true, + "rust_value": "None" } ], "OTEL_EXPORTER_OTLP_TIMEOUT": [ @@ -327,8 +367,8 @@ { "version": "A", "type": "map", - "default_value": "", - "propertyKeys": [] +"default_value": "", + "propertyKeys": ["otel_resource_attributes"] } ] } From b30e968389c7d01951acff8ce4e6d21c56880427 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 27 Mar 2026 13:41:10 +0100 Subject: [PATCH 02/13] lint --- .../src/core/configuration/configuration.rs | 21 ++++++++----------- .../src/core/configuration/mod.rs | 6 +++--- .../src/core/configuration/remote_config.rs | 1 + 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/datadog-opentelemetry/src/core/configuration/configuration.rs b/datadog-opentelemetry/src/core/configuration/configuration.rs index e0c50ed2..4f672e16 100644 --- a/datadog-opentelemetry/src/core/configuration/configuration.rs +++ b/datadog-opentelemetry/src/core/configuration/configuration.rs @@ -8,17 +8,15 @@ use std::ops::Deref; use std::sync::{Arc, Mutex}; use std::{borrow::Cow, fmt::Display, str::FromStr, sync::OnceLock}; -use rustc_version_runtime::version; - use crate::core::configuration::sources::{ CompositeConfigSourceResult, CompositeSource, ConfigKey, ConfigSourceOrigin, }; #[path = "supported_configurations.rs"] mod supported_configurations; -pub(crate) use supported_configurations::{is_alias_deprecated, SupportedConfigurations}; use crate::core::log::LevelFilter; use crate::core::telemetry; use crate::{dd_error, dd_warn}; +pub(crate) use supported_configurations::{is_alias_deprecated, SupportedConfigurations}; /// Different types of remote configuration updates that can trigger callbacks #[derive(Debug, Clone)] @@ -1010,10 +1008,10 @@ impl Config { default.telemetry_heartbeat_interval, |interval: f64| interval.abs(), ), - trace_propagation_style: cisu.update_parsed_with_transform( - default.trace_propagation_style, - |DdTags(tags)| TracePropagationStyle::from_tags(Some(tags)), - ), + trace_propagation_style: cisu + .update_parsed_with_transform(default.trace_propagation_style, |DdTags(tags)| { + TracePropagationStyle::from_tags(Some(tags)) + }), trace_propagation_style_extract: cisu.update_parsed_with_transform( default.trace_propagation_style_extract, |DdTags(tags)| TracePropagationStyle::from_tags(Some(tags)), @@ -1032,10 +1030,10 @@ impl Config { |interval: f64| interval.abs().min(RC_DEFAULT_POLL_INTERVAL), ), remote_config_callbacks: Arc::new(Mutex::new(RemoteConfigCallbacks::new())), - datadog_tags_max_length: cisu.update_parsed_with_transform( - default.datadog_tags_max_length, - |max: usize| max.min(DATADOG_TAGS_MAX_LENGTH), - ), + datadog_tags_max_length: cisu + .update_parsed_with_transform(default.datadog_tags_max_length, |max: usize| { + max.min(DATADOG_TAGS_MAX_LENGTH) + }), otlp_metrics_protocol: cisu.update_string( default.otlp_metrics_protocol, crate::metrics_exporter::OtlpProtocol::parse_optional, @@ -1084,7 +1082,6 @@ impl Config { Self::builder_with_sources(&CompositeSource::default_sources()) } - /// Returns the unique runtime identifier for this process. pub fn runtime_id(&self) -> &str { self.runtime_id diff --git a/datadog-opentelemetry/src/core/configuration/mod.rs b/datadog-opentelemetry/src/core/configuration/mod.rs index cf1b0eaf..e39d4f71 100644 --- a/datadog-opentelemetry/src/core/configuration/mod.rs +++ b/datadog-opentelemetry/src/core/configuration/mod.rs @@ -24,7 +24,7 @@ mod configuration; pub(crate) mod remote_config; mod sources; +#[cfg(test)] +pub(crate) use configuration::SupportedConfigurations; pub use configuration::{Config, ConfigBuilder, SamplingRuleConfig, TracePropagationStyle}; -pub(crate) use configuration::{ - is_alias_deprecated, ConfigurationProvider, RemoteConfigUpdate, SupportedConfigurations, -}; +pub(crate) use configuration::{ConfigurationProvider, RemoteConfigUpdate}; diff --git a/datadog-opentelemetry/src/core/configuration/remote_config.rs b/datadog-opentelemetry/src/core/configuration/remote_config.rs index aff0bc38..d62a6766 100644 --- a/datadog-opentelemetry/src/core/configuration/remote_config.rs +++ b/datadog-opentelemetry/src/core/configuration/remote_config.rs @@ -426,6 +426,7 @@ struct RemoteConfigClient { impl RemoteConfigClient { /// Creates a new remote configuration client pub fn new(config: Arc) -> Result { + #[allow(clippy::unnecessary_to_owned)] let agent_url = hyper::Uri::from_maybe_shared(config.trace_agent_url().to_string()) .map_err(|_| RemoteConfigClientError::InvalidAgentUri)?; let mut parts = agent_url.into_parts(); From 6cb73fa001e6d8a92db92c6ae2521085a0c58b5b Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 27 Mar 2026 13:58:30 +0100 Subject: [PATCH 03/13] Fix default value --- .../src/core/configuration/supported_configurations.rs | 2 +- supported-configurations.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs index 5c9388fb..c2eef801 100644 --- a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs +++ b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs @@ -510,7 +510,7 @@ pub(super) fn default_config() -> Config { S::OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, Some(opentelemetry_sdk::metrics::Temporality::Delta), ), - otlp_metrics_timeout: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_TIMEOUT, 0), + otlp_metrics_timeout: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_TIMEOUT, 10000), otlp_protocol: ConfigItem::new(S::OTEL_EXPORTER_OTLP_PROTOCOL, None), otlp_timeout: ConfigItem::new(S::OTEL_EXPORTER_OTLP_TIMEOUT, 10000), otel_metrics_exporter: ConfigItem::new(S::OTEL_METRICS_EXPORTER, Cow::Borrowed("otlp")), diff --git a/supported-configurations.json b/supported-configurations.json index 7c36ef50..327fe679 100644 --- a/supported-configurations.json +++ b/supported-configurations.json @@ -317,7 +317,7 @@ { "version": "A", "type": "int", - "default": null, + "default": "10000", "propertyKeys": ["otlp_metrics_timeout"] } ], From 15f7d1aa563e97e21caf4741350e5c1f63757d64 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 27 Mar 2026 14:07:54 +0100 Subject: [PATCH 04/13] Granular generation deactivation --- scripts/local_config_map_generate.py | 86 +++++++++++++++++----------- supported-configurations.json | 40 ++++++------- 2 files changed, 70 insertions(+), 56 deletions(-) diff --git a/scripts/local_config_map_generate.py b/scripts/local_config_map_generate.py index f672fb4c..a1e15164 100644 --- a/scripts/local_config_map_generate.py +++ b/scripts/local_config_map_generate.py @@ -65,54 +65,70 @@ default_val = versions[0].get("default") property_keys = versions[0].get("propertyKeys", []) field_name = property_keys[0] if property_keys else None - skip = versions[0].get("skip_default_generation", False) + skip_raw = versions[0].get("skip_default_generation", "") + if skip_raw is True or skip_raw == "all": + skip_set = {"getter", "setter", "default"} + elif skip_raw: + skip_set = {s.strip() for s in skip_raw.split(",")} + else: + skip_set = set() # Build getter/setter lines for simple types - if not skip and field_name and json_type in ("string", "int", "decimal", "boolean"): + skip_getters = "getter" in skip_set + skip_setters = "setter" in skip_set + if field_name and json_type in ("string", "int", "decimal", "boolean"): if json_type == "string": - getter_lines.append( - " pub fn {}(&self) -> &str {{ self.{}.value().as_ref() }}".format( - field_name, field_name + if not skip_getters: + getter_lines.append( + " pub fn {}(&self) -> &str {{ self.{}.value().as_ref() }}".format( + field_name, field_name + ) ) - ) - setter_lines.append( - " pub fn set_{}(&mut self, val: String) -> &mut Self {{ self.config.{}.set_code(Cow::Owned(val)); self }}".format( - field_name, field_name + if not skip_setters: + setter_lines.append( + " pub fn set_{}(&mut self, val: String) -> &mut Self {{ self.config.{}.set_code(Cow::Owned(val)); self }}".format( + field_name, field_name + ) ) - ) elif json_type == "int": - getter_lines.append( - " pub fn {}(&self) -> u32 {{ *self.{}.value() }}".format( - field_name, field_name + if not skip_getters: + getter_lines.append( + " pub fn {}(&self) -> u32 {{ *self.{}.value() }}".format( + field_name, field_name + ) ) - ) - setter_lines.append( - " pub fn set_{}(&mut self, val: u32) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - field_name, field_name + if not skip_setters: + setter_lines.append( + " pub fn set_{}(&mut self, val: u32) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + field_name, field_name + ) ) - ) elif json_type == "decimal": - getter_lines.append( - " pub fn {}(&self) -> f64 {{ *self.{}.value() }}".format( - field_name, field_name + if not skip_getters: + getter_lines.append( + " pub fn {}(&self) -> f64 {{ *self.{}.value() }}".format( + field_name, field_name + ) ) - ) - setter_lines.append( - " pub fn set_{}(&mut self, val: f64) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - field_name, field_name + if not skip_setters: + setter_lines.append( + " pub fn set_{}(&mut self, val: f64) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + field_name, field_name + ) ) - ) elif json_type == "boolean": - getter_lines.append( - " pub fn {}(&self) -> bool {{ *self.{}.value() }}".format( - field_name, field_name + if not skip_getters: + getter_lines.append( + " pub fn {}(&self) -> bool {{ *self.{}.value() }}".format( + field_name, field_name + ) ) - ) - setter_lines.append( - " pub fn set_{}(&mut self, val: bool) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - field_name, field_name + if not skip_setters: + setter_lines.append( + " pub fn set_{}(&mut self, val: bool) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + field_name, field_name + ) ) - ) # Build default_config() field line if field_name: @@ -137,7 +153,7 @@ field_name, key, rust_value ) ) - elif not skip: + elif "default" not in skip_set: rust_val = None if json_type == "string": rust_val = 'Cow::Borrowed("{}")'.format(default_val or "") diff --git a/supported-configurations.json b/supported-configurations.json index 327fe679..f9d3cb08 100644 --- a/supported-configurations.json +++ b/supported-configurations.json @@ -32,7 +32,7 @@ "type": "string", "default": "http://localhost:8125", "propertyKeys": ["dogstatsd_agent_url"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "Cow::Borrowed(\"\")" } ], @@ -42,7 +42,7 @@ "type": "string", "default": "", "propertyKeys": ["env"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "None" } ], @@ -60,7 +60,7 @@ "type": "string", "default": "ERROR", "propertyKeys": ["log_level_filter"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "LevelFilter::default()" } ], @@ -87,8 +87,7 @@ "type": "decimal", "default": "5.0", "propertyKeys": ["remote_config_poll_interval"], - "skip_default_generation": true, - "rust_value": "5.0" + "skip_default_generation": "getter,setter" } ], "DD_SERVICE": [ @@ -97,7 +96,7 @@ "type": "string", "default": "unnamed-rust-service", "propertyKeys": ["service"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "ServiceName::Default", "config_item_type": "override_code" } @@ -116,8 +115,7 @@ "type": "decimal", "default": "60.0", "propertyKeys": ["telemetry_heartbeat_interval"], - "skip_default_generation": true, - "rust_value": "60.0" + "skip_default_generation": "getter,setter" } ], "DD_TELEMETRY_LOG_COLLECTION_ENABLED": [ @@ -166,7 +164,7 @@ "type": "int", "default": "300", "propertyKeys": ["trace_partial_flush_min_spans"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "300usize" } ], @@ -184,7 +182,7 @@ "type": "array", "default": "datadog,tracecontext", "propertyKeys": ["trace_propagation_style"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "Some(vec![TracePropagationStyle::Datadog, TracePropagationStyle::TraceContext])" } ], @@ -194,7 +192,7 @@ "type": "array", "default": "", "propertyKeys": ["trace_propagation_style_extract"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "None" } ], @@ -204,7 +202,7 @@ "type": "array", "default": "", "propertyKeys": ["trace_propagation_style_inject"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "None" } ], @@ -214,7 +212,7 @@ "type": "int", "default": "100", "propertyKeys": ["trace_rate_limit"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "100i32" } ], @@ -224,7 +222,7 @@ "type": "array", "default": "", "propertyKeys": ["trace_sampling_rules"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "ParsedSamplingRules::default()", "config_item_type": "override_rc" } @@ -243,7 +241,7 @@ "type": "int", "default": "512", "propertyKeys": ["datadog_tags_max_length"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "512usize" } ], @@ -253,7 +251,7 @@ "type": "string", "default": "", "propertyKeys": ["version"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "None" } ], @@ -271,7 +269,7 @@ "type": "map", "default": "", "propertyKeys": ["otlp_headers"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "Cow::Borrowed(\"\")" } ], @@ -289,7 +287,7 @@ "type": "map", "default": null, "propertyKeys": ["otlp_metrics_headers"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "Cow::Borrowed(\"\")" } ], @@ -299,7 +297,7 @@ "type": "string", "default": null, "propertyKeys": ["otlp_metrics_protocol"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "None" } ], @@ -309,7 +307,7 @@ "type": "string", "default": "delta", "propertyKeys": ["otel_metrics_temporality_preference"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "Some(opentelemetry_sdk::metrics::Temporality::Delta)" } ], @@ -327,7 +325,7 @@ "type": "string", "default": "grpc", "propertyKeys": ["otlp_protocol"], - "skip_default_generation": true, + "skip_default_generation": "all", "rust_value": "None" } ], From 467a690d0d2450078542913217379d1cb68bc9e8 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 27 Mar 2026 14:21:26 +0100 Subject: [PATCH 05/13] Auto generation of struct Config --- .../src/core/configuration/configuration.rs | 138 +----------------- .../configuration/supported_configurations.rs | 67 +++++++++ scripts/local_config_map_generate.py | 41 ++++++ supported-configurations.json | 13 ++ 4 files changed, 122 insertions(+), 137 deletions(-) diff --git a/datadog-opentelemetry/src/core/configuration/configuration.rs b/datadog-opentelemetry/src/core/configuration/configuration.rs index 4f672e16..a92fe9b5 100644 --- a/datadog-opentelemetry/src/core/configuration/configuration.rs +++ b/datadog-opentelemetry/src/core/configuration/configuration.rs @@ -16,6 +16,7 @@ mod supported_configurations; use crate::core::log::LevelFilter; use crate::core::telemetry; use crate::{dd_error, dd_warn}; +pub use supported_configurations::Config; pub(crate) use supported_configurations::{is_alias_deprecated, SupportedConfigurations}; /// Different types of remote configuration updates that can trigger callbacks @@ -558,7 +559,6 @@ macro_rules! impl_config_value_provider { }; } -type SamplingRulesConfigItem = ConfigItemWithOverride; /// Manages extra services discovered at runtime /// This is used to track services beyond the main service for remote configuration @@ -792,142 +792,6 @@ impl ConfigurationValueProvider for Option, bool, u32, usize, i32, f64, ServiceName, LevelFilter, ParsedSamplingRules); impl_config_value_provider!(option: String); -#[derive(Clone)] -#[non_exhaustive] -/// Configuration for the Datadog Tracer -/// -/// # Usage -/// ``` -/// use datadog_opentelemetry::configuration::Config; -/// -/// -/// let config = Config::builder() // This pulls configuration from the environment and other sources -/// .set_service("my-service".to_string()) // Override service name -/// .set_version("1.0.0".to_string()) // Override version -/// .build(); -/// ``` -pub struct Config { - // # Global - runtime_id: &'static str, - - // # Tracer - tracer_version: &'static str, - language_version: String, - language: &'static str, - - // # Service tagging - service: ConfigItemWithOverride, - env: ConfigItem>, - version: ConfigItem>, - - // # Agent - /// A list of default tags to be added to every span - /// If DD_ENV or DD_VERSION is used, it overrides any env or version tag defined in DD_TAGS - global_tags: ConfigItem>, - /// OTEL resource attributes parsed from OTEL_RESOURCE_ATTRIBUTES env var - otel_resource_attributes: ConfigItem>, - /// OTEL metrics exporter type - otel_metrics_exporter: ConfigItem>, - /// OTEL metrics temporality preference - otel_metrics_temporality_preference: - ConfigItem>, - /// host of the trace agent - agent_host: ConfigItem>, - /// port of the trace agent - trace_agent_port: ConfigItem, - /// url of the trace agent - trace_agent_url: ConfigItem>, - /// host of the dogstatsd agent - dogstatsd_agent_host: ConfigItem>, - /// port of the dogstatsd agent - dogstatsd_agent_port: ConfigItem, - /// url of the dogstatsd agent - dogstatsd_agent_url: ConfigItem>, - - // # Sampling - /// A list of sampling rules. Each rule is matched against the root span of a trace - /// If a rule matches, the trace is sampled with the associated sample rate. - trace_sampling_rules: SamplingRulesConfigItem, - - /// Maximum number of spans to sample per second - /// Only applied if trace_sampling_rules are matched - trace_rate_limit: ConfigItem, - - /// Disables the library if this is false - enabled: ConfigItem, - /// The log level filter for the tracer - log_level_filter: ConfigItem, - - /// Whether to enable stats computation for the tracer - /// Results in dropped spans not being sent to the agent - trace_stats_computation_enabled: ConfigItem, - - /// Configurations for testing. Not exposed to customer - #[cfg(feature = "test-utils")] - wait_agent_info_ready: bool, - - // # Telemetry configuration - /// Disables telemetry if false - telemetry_enabled: ConfigItem, - /// Disables telemetry log collection if false. - telemetry_log_collection_enabled: ConfigItem, - /// Interval by which telemetry events are flushed (seconds) - telemetry_heartbeat_interval: ConfigItem, - - /// Partial flush - trace_partial_flush_enabled: ConfigItem, - trace_partial_flush_min_spans: ConfigItem, - - /// Trace propagation configuration - trace_propagation_style: ConfigItem>>, - trace_propagation_style_extract: ConfigItem>>, - trace_propagation_style_inject: ConfigItem>>, - trace_propagation_extract_first: ConfigItem, - - /// Whether remote configuration is enabled - remote_config_enabled: ConfigItem, - - /// Interval by with remote configuration is polled (seconds) - /// 5 seconds is the highest interval allowed by the spec - remote_config_poll_interval: ConfigItem, - - /// Tracks extra services discovered at runtime - /// Used for remote configuration to report all services - extra_services_tracker: ExtraServicesTracker, - - /// General callbacks to be called when configuration is updated from remote configuration - /// Allows components like the DatadogSampler to be updated without circular imports - remote_config_callbacks: Arc>, - - /// Max length of x-datadog-tags header. It only accepts values between 0 and 512. - /// The default value is 512 and x-datadog-tags header is not injected if value is 0. - datadog_tags_max_length: ConfigItem, - - // # OpenTelemetry Metrics - /// Enables OpenTelemetry metrics export - metrics_otel_enabled: ConfigItem, - /// OTLP metrics endpoint - otlp_metrics_endpoint: ConfigItem>, - /// OTLP general endpoint - otlp_endpoint: ConfigItem>, - /// OTLP general headers - otlp_headers: ConfigItem>, - /// OTLP metrics protocol (grpc, http/protobuf, http/json) - otlp_metrics_protocol: ConfigItem>, - /// OTLP metrics headers - otlp_metrics_headers: ConfigItem>, - /// OTLP general protocol (fallback for metrics protocol) - otlp_protocol: ConfigItem>, - /// OTLP metrics timeout in milliseconds - otlp_metrics_timeout: ConfigItem, - /// OTLP general timeout - otlp_timeout: ConfigItem, - /// Metric export interval in milliseconds - metric_export_interval: ConfigItem, - /// Metric export timeout in milliseconds - metric_export_timeout: ConfigItem, -} - impl Config { fn from_sources(sources: &CompositeSource) -> Self { use SupportedConfigurations as S; diff --git a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs index c2eef801..73878641 100644 --- a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs +++ b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs @@ -197,6 +197,73 @@ pub fn is_alias_deprecated(name: &str) -> bool { } } +/// Configuration for the Datadog Tracer +/// +/// # Usage +/// ``` +/// use datadog_opentelemetry::configuration::Config; +/// +/// +/// let config = Config::builder() // This pulls configuration from the environment and other sources +/// .set_service("my-service".to_string()) // Override service name +/// .set_version("1.0.0".to_string()) // Override version +/// .build(); +/// ``` +#[derive(Clone)] +#[non_exhaustive] +pub struct Config { + pub(super) runtime_id: &'static str, + pub(super) tracer_version: &'static str, + pub(super) language_version: String, + pub(super) language: &'static str, + pub(super) agent_host: ConfigItem>, + pub(super) dogstatsd_agent_host: ConfigItem>, + pub(super) dogstatsd_agent_port: ConfigItem, + pub(super) dogstatsd_agent_url: ConfigItem>, + pub(super) env: ConfigItem>, + pub(super) telemetry_enabled: ConfigItem, + pub(super) log_level_filter: ConfigItem, + pub(super) metrics_otel_enabled: ConfigItem, + pub(super) remote_config_enabled: ConfigItem, + pub(super) remote_config_poll_interval: ConfigItem, + pub(super) service: ConfigItemWithOverride, + pub(super) global_tags: ConfigItem>, + pub(super) telemetry_heartbeat_interval: ConfigItem, + pub(super) telemetry_log_collection_enabled: ConfigItem, + pub(super) trace_agent_port: ConfigItem, + pub(super) trace_agent_url: ConfigItem>, + pub(super) enabled: ConfigItem, + pub(super) trace_partial_flush_enabled: ConfigItem, + pub(super) trace_partial_flush_min_spans: ConfigItem, + pub(super) trace_propagation_extract_first: ConfigItem, + pub(super) trace_propagation_style: ConfigItem>>, + pub(super) trace_propagation_style_extract: ConfigItem>>, + pub(super) trace_propagation_style_inject: ConfigItem>>, + pub(super) trace_rate_limit: ConfigItem, + pub(super) trace_sampling_rules: ConfigItemWithOverride, + pub(super) trace_stats_computation_enabled: ConfigItem, + pub(super) datadog_tags_max_length: ConfigItem, + pub(super) version: ConfigItem>, + pub(super) otlp_endpoint: ConfigItem>, + pub(super) otlp_headers: ConfigItem>, + pub(super) otlp_metrics_endpoint: ConfigItem>, + pub(super) otlp_metrics_headers: ConfigItem>, + pub(super) otlp_metrics_protocol: ConfigItem>, + pub(super) otel_metrics_temporality_preference: + ConfigItem>, + pub(super) otlp_metrics_timeout: ConfigItem, + pub(super) otlp_protocol: ConfigItem>, + pub(super) otlp_timeout: ConfigItem, + pub(super) otel_metrics_exporter: ConfigItem>, + pub(super) metric_export_interval: ConfigItem, + pub(super) metric_export_timeout: ConfigItem, + pub(super) otel_resource_attributes: ConfigItem>, + #[cfg(feature = "test-utils")] + pub(super) wait_agent_info_ready: bool, + pub(super) extra_services_tracker: ExtraServicesTracker, + pub(super) remote_config_callbacks: Arc>, +} + #[allow(missing_docs)] impl Config { pub fn agent_host(&self) -> &str { diff --git a/scripts/local_config_map_generate.py b/scripts/local_config_map_generate.py index a1e15164..4556050a 100644 --- a/scripts/local_config_map_generate.py +++ b/scripts/local_config_map_generate.py @@ -45,6 +45,7 @@ aliases_block = [] alias_deprecated_block = [] deprecated_block = [] +struct_field_lines = [] getter_lines = [] setter_lines = [] telemetry_lines = [] @@ -73,6 +74,19 @@ else: skip_set = set() + # Build struct field line + if field_name: + rust_type = versions[0].get("rust_type", TYPE_MAP.get(json_type)) + config_item_type = versions[0].get("config_item_type") + if config_item_type in ("override_code", "override_rc"): + struct_field_lines.append( + " pub(super) {}: ConfigItemWithOverride<{}>,".format(field_name, rust_type) + ) + else: + struct_field_lines.append( + " pub(super) {}: ConfigItem<{}>,".format(field_name, rust_type) + ) + # Build getter/setter lines for simple types skip_getters = "getter" in skip_set skip_setters = "setter" in skip_set @@ -275,6 +289,32 @@ }} }} +/// Configuration for the Datadog Tracer +/// +/// # Usage +/// ``` +/// use datadog_opentelemetry::configuration::Config; +/// +/// +/// let config = Config::builder() // This pulls configuration from the environment and other sources +/// .set_service("my-service".to_string()) // Override service name +/// .set_version("1.0.0".to_string()) // Override version +/// .build(); +/// ``` +#[derive(Clone)] +#[non_exhaustive] +pub struct Config {{ + pub(super) runtime_id: &'static str, + pub(super) tracer_version: &'static str, + pub(super) language_version: String, + pub(super) language: &'static str, +{struct_fields_block} + #[cfg(feature = "test-utils")] + pub(super) wait_agent_info_ready: bool, + pub(super) extra_services_tracker: ExtraServicesTracker, + pub(super) remote_config_callbacks: Arc>, +}} + #[allow(missing_docs)] impl Config {{ {getters_block} @@ -324,6 +364,7 @@ aliases_joined=NL.join(aliases_block), deprecated_joined=NL.join(deprecated_block), alias_deprecated_joined=NL.join(alias_deprecated_block), + struct_fields_block="\n".join(struct_field_lines), default_config_block="\n".join(default_config_lines), getters_block="\n\n".join(getter_lines), setters_block="\n\n".join(setter_lines), diff --git a/supported-configurations.json b/supported-configurations.json index f9d3cb08..ef8e965e 100644 --- a/supported-configurations.json +++ b/supported-configurations.json @@ -42,6 +42,7 @@ "type": "string", "default": "", "propertyKeys": ["env"], + "rust_type": "Option", "skip_default_generation": "all", "rust_value": "None" } @@ -60,6 +61,7 @@ "type": "string", "default": "ERROR", "propertyKeys": ["log_level_filter"], + "rust_type": "LevelFilter", "skip_default_generation": "all", "rust_value": "LevelFilter::default()" } @@ -96,6 +98,7 @@ "type": "string", "default": "unnamed-rust-service", "propertyKeys": ["service"], + "rust_type": "ServiceName", "skip_default_generation": "all", "rust_value": "ServiceName::Default", "config_item_type": "override_code" @@ -164,6 +167,7 @@ "type": "int", "default": "300", "propertyKeys": ["trace_partial_flush_min_spans"], + "rust_type": "usize", "skip_default_generation": "all", "rust_value": "300usize" } @@ -212,6 +216,7 @@ "type": "int", "default": "100", "propertyKeys": ["trace_rate_limit"], + "rust_type": "i32", "skip_default_generation": "all", "rust_value": "100i32" } @@ -222,6 +227,7 @@ "type": "array", "default": "", "propertyKeys": ["trace_sampling_rules"], + "rust_type": "ParsedSamplingRules", "skip_default_generation": "all", "rust_value": "ParsedSamplingRules::default()", "config_item_type": "override_rc" @@ -241,6 +247,7 @@ "type": "int", "default": "512", "propertyKeys": ["datadog_tags_max_length"], + "rust_type": "usize", "skip_default_generation": "all", "rust_value": "512usize" } @@ -251,6 +258,7 @@ "type": "string", "default": "", "propertyKeys": ["version"], + "rust_type": "Option", "skip_default_generation": "all", "rust_value": "None" } @@ -269,6 +277,7 @@ "type": "map", "default": "", "propertyKeys": ["otlp_headers"], + "rust_type": "Cow<'static, str>", "skip_default_generation": "all", "rust_value": "Cow::Borrowed(\"\")" } @@ -287,6 +296,7 @@ "type": "map", "default": null, "propertyKeys": ["otlp_metrics_headers"], + "rust_type": "Cow<'static, str>", "skip_default_generation": "all", "rust_value": "Cow::Borrowed(\"\")" } @@ -297,6 +307,7 @@ "type": "string", "default": null, "propertyKeys": ["otlp_metrics_protocol"], + "rust_type": "Option", "skip_default_generation": "all", "rust_value": "None" } @@ -307,6 +318,7 @@ "type": "string", "default": "delta", "propertyKeys": ["otel_metrics_temporality_preference"], + "rust_type": "Option", "skip_default_generation": "all", "rust_value": "Some(opentelemetry_sdk::metrics::Temporality::Delta)" } @@ -325,6 +337,7 @@ "type": "string", "default": "grpc", "propertyKeys": ["otlp_protocol"], + "rust_type": "Option", "skip_default_generation": "all", "rust_value": "None" } From 8ff8b8ad70371eae7f034bac3bcfd3e2c83fde90 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 27 Mar 2026 14:41:44 +0100 Subject: [PATCH 06/13] Format --- datadog-opentelemetry/src/core/configuration/configuration.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/datadog-opentelemetry/src/core/configuration/configuration.rs b/datadog-opentelemetry/src/core/configuration/configuration.rs index a92fe9b5..d324c2a6 100644 --- a/datadog-opentelemetry/src/core/configuration/configuration.rs +++ b/datadog-opentelemetry/src/core/configuration/configuration.rs @@ -559,7 +559,6 @@ macro_rules! impl_config_value_provider { }; } - /// Manages extra services discovered at runtime /// This is used to track services beyond the main service for remote configuration #[derive(Debug, Clone)] From 5fe1ca6bbe01b59660871d0dfd193549445f9bef Mon Sep 17 00:00:00 2001 From: "gh-worker-engraver-d31c25[bot]" <244855179+gh-worker-engraver-d31c25[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 10:54:40 +0200 Subject: [PATCH 07/13] fix(ci): migrate deprecated GitLab runner tags (#201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Migrates deprecated GitLab runner tags to new architecture-specific tags. ## Changes - `runner:main` → `arch:amd64` - `runner:docker` → `docker-in-docker:amd64` ## Background The `runner:main` and `runner:docker` tags are deprecated. See [announcement](https://docs.google.com/document/d/1TAuhD6_FSojKryNSK7xTjpGaLK2Zym09gBwnvXWZ3OE/edit?tab=t.0#heading=h.h0ndlf2g7dgx). ## Validation - Verified YAML syntax remains valid - No other changes made Co-authored-by: gh-worker-engraver-d31c25[bot] <244855179+gh-worker-engraver-d31c25[bot]@users.noreply.github.com> --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa1bb3ad..c37e0129 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ variables: REPO_NOTIFICATION_CHANNEL: "#dd-trace-rs-alerts" default: - tags: ["runner:main", "size:large"] + tags: ["arch:amd64"] # Config inversion CI steps validate_supported_configurations_v2_local_file: From 017f91fd5c595c4b7dff8c8e70cc951d239e5eff Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Mon, 13 Apr 2026 09:23:06 +0000 Subject: [PATCH 08/13] chore(ci): add id-token permission to system-tests subworkflow --- .github/workflows/test.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7bc4ada5..cfd854fd 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -167,9 +167,14 @@ jobs: - build-artifacts uses: DataDog/system-tests/.github/workflows/run-parametric.yml@8a65f66d74ca77f34e7e5a2f737e963ce9cec563 # main secrets: inherit + permissions: + contents: read + id-token: write + packages: write with: library: rust binaries_artifact: system_tests_binaries job_count: 2 job_matrix: '[1,2]' ref: 8a65f66d74ca77f34e7e5a2f737e963ce9cec563 # main + push_to_test_optimization: true From 428605effa2bce9dbfb9a8fb2ce9ce5317d26350 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 17 Apr 2026 09:04:16 +0000 Subject: [PATCH 09/13] Add env var, default and alias doc comments to generated Config fields --- .../configuration/supported_configurations.rs | 42 +++++++++++++++++++ scripts/local_config_map_generate.py | 15 +++++++ 2 files changed, 57 insertions(+) diff --git a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs index 73878641..c3ee187c 100644 --- a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs +++ b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs @@ -216,47 +216,89 @@ pub struct Config { pub(super) tracer_version: &'static str, pub(super) language_version: String, pub(super) language: &'static str, + /// Configured via `DD_AGENT_HOST`, default: `localhost` pub(super) agent_host: ConfigItem>, + /// Configured via `DD_DOGSTATSD_HOST`, default: `localhost` pub(super) dogstatsd_agent_host: ConfigItem>, + /// Configured via `DD_DOGSTATSD_PORT`, default: `8125` pub(super) dogstatsd_agent_port: ConfigItem, + /// Configured via `DD_DOGSTATSD_URL`, default: `http://localhost:8125` pub(super) dogstatsd_agent_url: ConfigItem>, + /// Configured via `DD_ENV`, default: `` pub(super) env: ConfigItem>, + /// Configured via `DD_INSTRUMENTATION_TELEMETRY_ENABLED`, default: `true` pub(super) telemetry_enabled: ConfigItem, + /// Configured via `DD_LOG_LEVEL`, default: `ERROR` pub(super) log_level_filter: ConfigItem, + /// Configured via `DD_METRICS_OTEL_ENABLED`, default: `true` pub(super) metrics_otel_enabled: ConfigItem, + /// Configured via `DD_REMOTE_CONFIGURATION_ENABLED`, default: `true` + /// Aliases: `DD_REMOTE_CONFIG_ENABLED` pub(super) remote_config_enabled: ConfigItem, + /// Configured via `DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS`, default: `5.0` pub(super) remote_config_poll_interval: ConfigItem, + /// Configured via `DD_SERVICE`, default: `unnamed-rust-service` pub(super) service: ConfigItemWithOverride, + /// Configured via `DD_TAGS`, default: `` pub(super) global_tags: ConfigItem>, + /// Configured via `DD_TELEMETRY_HEARTBEAT_INTERVAL`, default: `60.0` pub(super) telemetry_heartbeat_interval: ConfigItem, + /// Configured via `DD_TELEMETRY_LOG_COLLECTION_ENABLED`, default: `true` pub(super) telemetry_log_collection_enabled: ConfigItem, + /// Configured via `DD_TRACE_AGENT_PORT`, default: `8126` pub(super) trace_agent_port: ConfigItem, + /// Configured via `DD_TRACE_AGENT_URL`, default: `` pub(super) trace_agent_url: ConfigItem>, + /// Configured via `DD_TRACE_ENABLED`, default: `true` pub(super) enabled: ConfigItem, + /// Configured via `DD_TRACE_PARTIAL_FLUSH_ENABLED`, default: `false` pub(super) trace_partial_flush_enabled: ConfigItem, + /// Configured via `DD_TRACE_PARTIAL_FLUSH_MIN_SPANS`, default: `300` pub(super) trace_partial_flush_min_spans: ConfigItem, + /// Configured via `DD_TRACE_PROPAGATION_EXTRACT_FIRST`, default: `false` pub(super) trace_propagation_extract_first: ConfigItem, + /// Configured via `DD_TRACE_PROPAGATION_STYLE`, default: `datadog,tracecontext` pub(super) trace_propagation_style: ConfigItem>>, + /// Configured via `DD_TRACE_PROPAGATION_STYLE_EXTRACT`, default: `` pub(super) trace_propagation_style_extract: ConfigItem>>, + /// Configured via `DD_TRACE_PROPAGATION_STYLE_INJECT`, default: `` pub(super) trace_propagation_style_inject: ConfigItem>>, + /// Configured via `DD_TRACE_RATE_LIMIT`, default: `100` pub(super) trace_rate_limit: ConfigItem, + /// Configured via `DD_TRACE_SAMPLING_RULES`, default: `` pub(super) trace_sampling_rules: ConfigItemWithOverride, + /// Configured via `DD_TRACE_STATS_COMPUTATION_ENABLED`, default: `true` pub(super) trace_stats_computation_enabled: ConfigItem, + /// Configured via `DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH`, default: `512` pub(super) datadog_tags_max_length: ConfigItem, + /// Configured via `DD_VERSION`, default: `` pub(super) version: ConfigItem>, + /// Configured via `OTEL_EXPORTER_OTLP_ENDPOINT` pub(super) otlp_endpoint: ConfigItem>, + /// Configured via `OTEL_EXPORTER_OTLP_HEADERS`, default: `` pub(super) otlp_headers: ConfigItem>, + /// Configured via `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` pub(super) otlp_metrics_endpoint: ConfigItem>, + /// Configured via `OTEL_EXPORTER_OTLP_METRICS_HEADERS` pub(super) otlp_metrics_headers: ConfigItem>, + /// Configured via `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` pub(super) otlp_metrics_protocol: ConfigItem>, + /// Configured via `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE`, default: `delta` pub(super) otel_metrics_temporality_preference: ConfigItem>, + /// Configured via `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT`, default: `10000` pub(super) otlp_metrics_timeout: ConfigItem, + /// Configured via `OTEL_EXPORTER_OTLP_PROTOCOL`, default: `grpc` pub(super) otlp_protocol: ConfigItem>, + /// Configured via `OTEL_EXPORTER_OTLP_TIMEOUT`, default: `10000` pub(super) otlp_timeout: ConfigItem, + /// Configured via `OTEL_METRICS_EXPORTER`, default: `otlp` pub(super) otel_metrics_exporter: ConfigItem>, + /// Configured via `OTEL_METRIC_EXPORT_INTERVAL`, default: `10000` pub(super) metric_export_interval: ConfigItem, + /// Configured via `OTEL_METRIC_EXPORT_TIMEOUT`, default: `7500` pub(super) metric_export_timeout: ConfigItem, + /// Configured via `OTEL_RESOURCE_ATTRIBUTES` pub(super) otel_resource_attributes: ConfigItem>, #[cfg(feature = "test-utils")] pub(super) wait_agent_info_ready: bool, diff --git a/scripts/local_config_map_generate.py b/scripts/local_config_map_generate.py index 4556050a..05470c36 100644 --- a/scripts/local_config_map_generate.py +++ b/scripts/local_config_map_generate.py @@ -78,6 +78,21 @@ if field_name: rust_type = versions[0].get("rust_type", TYPE_MAP.get(json_type)) config_item_type = versions[0].get("config_item_type") + + # Doc comment: env var + default + default_display = versions[0].get("default") + doc = " /// Configured via `{}`".format(key) + if default_display is not None: + doc += ", default: `{}`".format(default_display) + struct_field_lines.append(doc) + + # Doc comment: aliases + all_aliases = [a for v in versions for a in v.get("aliases", [])] + if all_aliases: + struct_field_lines.append( + " /// Aliases: {}".format(", ".join("`{}`".format(a) for a in all_aliases)) + ) + if config_item_type in ("override_code", "override_rc"): struct_field_lines.append( " pub(super) {}: ConfigItemWithOverride<{}>,".format(field_name, rust_type) From 38cb8b31bb5c015a42648c17e4842704f1107037 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 17 Apr 2026 09:09:20 +0000 Subject: [PATCH 10/13] Move doc comments from struct fields to public getters and setters --- .../configuration/supported_configurations.rs | 86 +++++++++---------- scripts/local_config_map_generate.py | 59 ++++++------- 2 files changed, 70 insertions(+), 75 deletions(-) diff --git a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs index c3ee187c..59a5ba89 100644 --- a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs +++ b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs @@ -216,89 +216,47 @@ pub struct Config { pub(super) tracer_version: &'static str, pub(super) language_version: String, pub(super) language: &'static str, - /// Configured via `DD_AGENT_HOST`, default: `localhost` pub(super) agent_host: ConfigItem>, - /// Configured via `DD_DOGSTATSD_HOST`, default: `localhost` pub(super) dogstatsd_agent_host: ConfigItem>, - /// Configured via `DD_DOGSTATSD_PORT`, default: `8125` pub(super) dogstatsd_agent_port: ConfigItem, - /// Configured via `DD_DOGSTATSD_URL`, default: `http://localhost:8125` pub(super) dogstatsd_agent_url: ConfigItem>, - /// Configured via `DD_ENV`, default: `` pub(super) env: ConfigItem>, - /// Configured via `DD_INSTRUMENTATION_TELEMETRY_ENABLED`, default: `true` pub(super) telemetry_enabled: ConfigItem, - /// Configured via `DD_LOG_LEVEL`, default: `ERROR` pub(super) log_level_filter: ConfigItem, - /// Configured via `DD_METRICS_OTEL_ENABLED`, default: `true` pub(super) metrics_otel_enabled: ConfigItem, - /// Configured via `DD_REMOTE_CONFIGURATION_ENABLED`, default: `true` - /// Aliases: `DD_REMOTE_CONFIG_ENABLED` pub(super) remote_config_enabled: ConfigItem, - /// Configured via `DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS`, default: `5.0` pub(super) remote_config_poll_interval: ConfigItem, - /// Configured via `DD_SERVICE`, default: `unnamed-rust-service` pub(super) service: ConfigItemWithOverride, - /// Configured via `DD_TAGS`, default: `` pub(super) global_tags: ConfigItem>, - /// Configured via `DD_TELEMETRY_HEARTBEAT_INTERVAL`, default: `60.0` pub(super) telemetry_heartbeat_interval: ConfigItem, - /// Configured via `DD_TELEMETRY_LOG_COLLECTION_ENABLED`, default: `true` pub(super) telemetry_log_collection_enabled: ConfigItem, - /// Configured via `DD_TRACE_AGENT_PORT`, default: `8126` pub(super) trace_agent_port: ConfigItem, - /// Configured via `DD_TRACE_AGENT_URL`, default: `` pub(super) trace_agent_url: ConfigItem>, - /// Configured via `DD_TRACE_ENABLED`, default: `true` pub(super) enabled: ConfigItem, - /// Configured via `DD_TRACE_PARTIAL_FLUSH_ENABLED`, default: `false` pub(super) trace_partial_flush_enabled: ConfigItem, - /// Configured via `DD_TRACE_PARTIAL_FLUSH_MIN_SPANS`, default: `300` pub(super) trace_partial_flush_min_spans: ConfigItem, - /// Configured via `DD_TRACE_PROPAGATION_EXTRACT_FIRST`, default: `false` pub(super) trace_propagation_extract_first: ConfigItem, - /// Configured via `DD_TRACE_PROPAGATION_STYLE`, default: `datadog,tracecontext` pub(super) trace_propagation_style: ConfigItem>>, - /// Configured via `DD_TRACE_PROPAGATION_STYLE_EXTRACT`, default: `` pub(super) trace_propagation_style_extract: ConfigItem>>, - /// Configured via `DD_TRACE_PROPAGATION_STYLE_INJECT`, default: `` pub(super) trace_propagation_style_inject: ConfigItem>>, - /// Configured via `DD_TRACE_RATE_LIMIT`, default: `100` pub(super) trace_rate_limit: ConfigItem, - /// Configured via `DD_TRACE_SAMPLING_RULES`, default: `` pub(super) trace_sampling_rules: ConfigItemWithOverride, - /// Configured via `DD_TRACE_STATS_COMPUTATION_ENABLED`, default: `true` pub(super) trace_stats_computation_enabled: ConfigItem, - /// Configured via `DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH`, default: `512` pub(super) datadog_tags_max_length: ConfigItem, - /// Configured via `DD_VERSION`, default: `` pub(super) version: ConfigItem>, - /// Configured via `OTEL_EXPORTER_OTLP_ENDPOINT` pub(super) otlp_endpoint: ConfigItem>, - /// Configured via `OTEL_EXPORTER_OTLP_HEADERS`, default: `` pub(super) otlp_headers: ConfigItem>, - /// Configured via `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` pub(super) otlp_metrics_endpoint: ConfigItem>, - /// Configured via `OTEL_EXPORTER_OTLP_METRICS_HEADERS` pub(super) otlp_metrics_headers: ConfigItem>, - /// Configured via `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` pub(super) otlp_metrics_protocol: ConfigItem>, - /// Configured via `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE`, default: `delta` pub(super) otel_metrics_temporality_preference: ConfigItem>, - /// Configured via `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT`, default: `10000` pub(super) otlp_metrics_timeout: ConfigItem, - /// Configured via `OTEL_EXPORTER_OTLP_PROTOCOL`, default: `grpc` pub(super) otlp_protocol: ConfigItem>, - /// Configured via `OTEL_EXPORTER_OTLP_TIMEOUT`, default: `10000` pub(super) otlp_timeout: ConfigItem, - /// Configured via `OTEL_METRICS_EXPORTER`, default: `otlp` pub(super) otel_metrics_exporter: ConfigItem>, - /// Configured via `OTEL_METRIC_EXPORT_INTERVAL`, default: `10000` pub(super) metric_export_interval: ConfigItem, - /// Configured via `OTEL_METRIC_EXPORT_TIMEOUT`, default: `7500` pub(super) metric_export_timeout: ConfigItem, - /// Configured via `OTEL_RESOURCE_ATTRIBUTES` pub(super) otel_resource_attributes: ConfigItem>, #[cfg(feature = "test-utils")] pub(super) wait_agent_info_ready: bool, @@ -306,84 +264,104 @@ pub struct Config { pub(super) remote_config_callbacks: Arc>, } -#[allow(missing_docs)] impl Config { + /// Returns `DD_AGENT_HOST` — default: `localhost` pub fn agent_host(&self) -> &str { self.agent_host.value().as_ref() } + /// Returns `DD_DOGSTATSD_HOST` — default: `localhost` pub fn dogstatsd_agent_host(&self) -> &str { self.dogstatsd_agent_host.value().as_ref() } + /// Returns `DD_DOGSTATSD_PORT` — default: `8125` pub fn dogstatsd_agent_port(&self) -> u32 { *self.dogstatsd_agent_port.value() } + /// Returns `DD_INSTRUMENTATION_TELEMETRY_ENABLED` — default: `true` pub fn telemetry_enabled(&self) -> bool { *self.telemetry_enabled.value() } + /// Returns `DD_METRICS_OTEL_ENABLED` — default: `true` pub fn metrics_otel_enabled(&self) -> bool { *self.metrics_otel_enabled.value() } + /// Returns `DD_REMOTE_CONFIGURATION_ENABLED` — default: `true` + /// Aliases: `DD_REMOTE_CONFIG_ENABLED` pub fn remote_config_enabled(&self) -> bool { *self.remote_config_enabled.value() } + /// Returns `DD_TELEMETRY_LOG_COLLECTION_ENABLED` — default: `true` pub fn telemetry_log_collection_enabled(&self) -> bool { *self.telemetry_log_collection_enabled.value() } + /// Returns `DD_TRACE_AGENT_PORT` — default: `8126` pub fn trace_agent_port(&self) -> u32 { *self.trace_agent_port.value() } + /// Returns `DD_TRACE_AGENT_URL` — default: `` pub fn trace_agent_url(&self) -> &str { self.trace_agent_url.value().as_ref() } + /// Returns `DD_TRACE_ENABLED` — default: `true` pub fn enabled(&self) -> bool { *self.enabled.value() } + /// Returns `DD_TRACE_PARTIAL_FLUSH_ENABLED` — default: `false` pub fn trace_partial_flush_enabled(&self) -> bool { *self.trace_partial_flush_enabled.value() } + /// Returns `DD_TRACE_PROPAGATION_EXTRACT_FIRST` — default: `false` pub fn trace_propagation_extract_first(&self) -> bool { *self.trace_propagation_extract_first.value() } + /// Returns `DD_TRACE_STATS_COMPUTATION_ENABLED` — default: `true` pub fn trace_stats_computation_enabled(&self) -> bool { *self.trace_stats_computation_enabled.value() } + /// Returns `OTEL_EXPORTER_OTLP_ENDPOINT` pub fn otlp_endpoint(&self) -> &str { self.otlp_endpoint.value().as_ref() } + /// Returns `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` pub fn otlp_metrics_endpoint(&self) -> &str { self.otlp_metrics_endpoint.value().as_ref() } + /// Returns `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` — default: `10000` pub fn otlp_metrics_timeout(&self) -> u32 { *self.otlp_metrics_timeout.value() } + /// Returns `OTEL_EXPORTER_OTLP_TIMEOUT` — default: `10000` pub fn otlp_timeout(&self) -> u32 { *self.otlp_timeout.value() } + /// Returns `OTEL_METRICS_EXPORTER` — default: `otlp` pub fn otel_metrics_exporter(&self) -> &str { self.otel_metrics_exporter.value().as_ref() } + /// Returns `OTEL_METRIC_EXPORT_INTERVAL` — default: `10000` pub fn metric_export_interval(&self) -> u32 { *self.metric_export_interval.value() } + /// Returns `OTEL_METRIC_EXPORT_TIMEOUT` — default: `7500` pub fn metric_export_timeout(&self) -> u32 { *self.metric_export_timeout.value() } @@ -435,103 +413,123 @@ impl Config { } } -#[allow(missing_docs)] impl ConfigBuilder { + /// Sets `DD_AGENT_HOST` — default: `localhost` pub fn set_agent_host(&mut self, val: String) -> &mut Self { self.config.agent_host.set_code(Cow::Owned(val)); self } + /// Sets `DD_DOGSTATSD_HOST` — default: `localhost` pub fn set_dogstatsd_agent_host(&mut self, val: String) -> &mut Self { self.config.dogstatsd_agent_host.set_code(Cow::Owned(val)); self } + /// Sets `DD_DOGSTATSD_PORT` — default: `8125` pub fn set_dogstatsd_agent_port(&mut self, val: u32) -> &mut Self { self.config.dogstatsd_agent_port.set_code(val); self } + /// Sets `DD_INSTRUMENTATION_TELEMETRY_ENABLED` — default: `true` pub fn set_telemetry_enabled(&mut self, val: bool) -> &mut Self { self.config.telemetry_enabled.set_code(val); self } + /// Sets `DD_METRICS_OTEL_ENABLED` — default: `true` pub fn set_metrics_otel_enabled(&mut self, val: bool) -> &mut Self { self.config.metrics_otel_enabled.set_code(val); self } + /// Sets `DD_REMOTE_CONFIGURATION_ENABLED` — default: `true` + /// Aliases: `DD_REMOTE_CONFIG_ENABLED` pub fn set_remote_config_enabled(&mut self, val: bool) -> &mut Self { self.config.remote_config_enabled.set_code(val); self } + /// Sets `DD_TELEMETRY_LOG_COLLECTION_ENABLED` — default: `true` pub fn set_telemetry_log_collection_enabled(&mut self, val: bool) -> &mut Self { self.config.telemetry_log_collection_enabled.set_code(val); self } + /// Sets `DD_TRACE_AGENT_PORT` — default: `8126` pub fn set_trace_agent_port(&mut self, val: u32) -> &mut Self { self.config.trace_agent_port.set_code(val); self } + /// Sets `DD_TRACE_AGENT_URL` — default: `` pub fn set_trace_agent_url(&mut self, val: String) -> &mut Self { self.config.trace_agent_url.set_code(Cow::Owned(val)); self } + /// Sets `DD_TRACE_ENABLED` — default: `true` pub fn set_enabled(&mut self, val: bool) -> &mut Self { self.config.enabled.set_code(val); self } + /// Sets `DD_TRACE_PARTIAL_FLUSH_ENABLED` — default: `false` pub fn set_trace_partial_flush_enabled(&mut self, val: bool) -> &mut Self { self.config.trace_partial_flush_enabled.set_code(val); self } + /// Sets `DD_TRACE_PROPAGATION_EXTRACT_FIRST` — default: `false` pub fn set_trace_propagation_extract_first(&mut self, val: bool) -> &mut Self { self.config.trace_propagation_extract_first.set_code(val); self } + /// Sets `DD_TRACE_STATS_COMPUTATION_ENABLED` — default: `true` pub fn set_trace_stats_computation_enabled(&mut self, val: bool) -> &mut Self { self.config.trace_stats_computation_enabled.set_code(val); self } + /// Sets `OTEL_EXPORTER_OTLP_ENDPOINT` pub fn set_otlp_endpoint(&mut self, val: String) -> &mut Self { self.config.otlp_endpoint.set_code(Cow::Owned(val)); self } + /// Sets `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` pub fn set_otlp_metrics_endpoint(&mut self, val: String) -> &mut Self { self.config.otlp_metrics_endpoint.set_code(Cow::Owned(val)); self } + /// Sets `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` — default: `10000` pub fn set_otlp_metrics_timeout(&mut self, val: u32) -> &mut Self { self.config.otlp_metrics_timeout.set_code(val); self } + /// Sets `OTEL_EXPORTER_OTLP_TIMEOUT` — default: `10000` pub fn set_otlp_timeout(&mut self, val: u32) -> &mut Self { self.config.otlp_timeout.set_code(val); self } + /// Sets `OTEL_METRICS_EXPORTER` — default: `otlp` pub fn set_otel_metrics_exporter(&mut self, val: String) -> &mut Self { self.config.otel_metrics_exporter.set_code(Cow::Owned(val)); self } + /// Sets `OTEL_METRIC_EXPORT_INTERVAL` — default: `10000` pub fn set_metric_export_interval(&mut self, val: u32) -> &mut Self { self.config.metric_export_interval.set_code(val); self } + /// Sets `OTEL_METRIC_EXPORT_TIMEOUT` — default: `7500` pub fn set_metric_export_timeout(&mut self, val: u32) -> &mut Self { self.config.metric_export_timeout.set_code(val); self diff --git a/scripts/local_config_map_generate.py b/scripts/local_config_map_generate.py index 05470c36..07512ae6 100644 --- a/scripts/local_config_map_generate.py +++ b/scripts/local_config_map_generate.py @@ -78,21 +78,6 @@ if field_name: rust_type = versions[0].get("rust_type", TYPE_MAP.get(json_type)) config_item_type = versions[0].get("config_item_type") - - # Doc comment: env var + default - default_display = versions[0].get("default") - doc = " /// Configured via `{}`".format(key) - if default_display is not None: - doc += ", default: `{}`".format(default_display) - struct_field_lines.append(doc) - - # Doc comment: aliases - all_aliases = [a for v in versions for a in v.get("aliases", [])] - if all_aliases: - struct_field_lines.append( - " /// Aliases: {}".format(", ".join("`{}`".format(a) for a in all_aliases)) - ) - if config_item_type in ("override_code", "override_rc"): struct_field_lines.append( " pub(super) {}: ConfigItemWithOverride<{}>,".format(field_name, rust_type) @@ -102,6 +87,18 @@ " pub(super) {}: ConfigItem<{}>,".format(field_name, rust_type) ) + # Build doc comment shared by getter and setter + default_display = versions[0].get("default") + all_aliases = [a for v in versions for a in v.get("aliases", [])] + + def make_doc(prefix): + doc = " /// {} `{}`".format(prefix, key) + if default_display is not None: + doc += " — default: `{}`".format(default_display) + if all_aliases: + doc += "\n /// Aliases: {}".format(", ".join("`{}`".format(a) for a in all_aliases)) + return doc + # Build getter/setter lines for simple types skip_getters = "getter" in skip_set skip_setters = "setter" in skip_set @@ -109,53 +106,53 @@ if json_type == "string": if not skip_getters: getter_lines.append( - " pub fn {}(&self) -> &str {{ self.{}.value().as_ref() }}".format( - field_name, field_name + "{}\n pub fn {}(&self) -> &str {{ self.{}.value().as_ref() }}".format( + make_doc("Returns"), field_name, field_name ) ) if not skip_setters: setter_lines.append( - " pub fn set_{}(&mut self, val: String) -> &mut Self {{ self.config.{}.set_code(Cow::Owned(val)); self }}".format( - field_name, field_name + "{}\n pub fn set_{}(&mut self, val: String) -> &mut Self {{ self.config.{}.set_code(Cow::Owned(val)); self }}".format( + make_doc("Sets"), field_name, field_name ) ) elif json_type == "int": if not skip_getters: getter_lines.append( - " pub fn {}(&self) -> u32 {{ *self.{}.value() }}".format( - field_name, field_name + "{}\n pub fn {}(&self) -> u32 {{ *self.{}.value() }}".format( + make_doc("Returns"), field_name, field_name ) ) if not skip_setters: setter_lines.append( - " pub fn set_{}(&mut self, val: u32) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - field_name, field_name + "{}\n pub fn set_{}(&mut self, val: u32) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + make_doc("Sets"), field_name, field_name ) ) elif json_type == "decimal": if not skip_getters: getter_lines.append( - " pub fn {}(&self) -> f64 {{ *self.{}.value() }}".format( - field_name, field_name + "{}\n pub fn {}(&self) -> f64 {{ *self.{}.value() }}".format( + make_doc("Returns"), field_name, field_name ) ) if not skip_setters: setter_lines.append( - " pub fn set_{}(&mut self, val: f64) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - field_name, field_name + "{}\n pub fn set_{}(&mut self, val: f64) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + make_doc("Sets"), field_name, field_name ) ) elif json_type == "boolean": if not skip_getters: getter_lines.append( - " pub fn {}(&self) -> bool {{ *self.{}.value() }}".format( - field_name, field_name + "{}\n pub fn {}(&self) -> bool {{ *self.{}.value() }}".format( + make_doc("Returns"), field_name, field_name ) ) if not skip_setters: setter_lines.append( - " pub fn set_{}(&mut self, val: bool) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - field_name, field_name + "{}\n pub fn set_{}(&mut self, val: bool) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( + make_doc("Sets"), field_name, field_name ) ) From a6cbef4550eadd3d56a88e66a9c0478334ae5ba0 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 17 Apr 2026 09:13:41 +0000 Subject: [PATCH 11/13] Match old doc comment format on getters and setters --- .../configuration/supported_configurations.rs | 157 +++++++++++++----- scripts/local_config_map_generate.py | 30 ++-- 2 files changed, 133 insertions(+), 54 deletions(-) diff --git a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs index 59a5ba89..6584c000 100644 --- a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs +++ b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs @@ -265,103 +265,102 @@ pub struct Config { } impl Config { - /// Returns `DD_AGENT_HOST` — default: `localhost` + /// Returns the value of `DD_AGENT_HOST`. pub fn agent_host(&self) -> &str { self.agent_host.value().as_ref() } - /// Returns `DD_DOGSTATSD_HOST` — default: `localhost` + /// Returns the value of `DD_DOGSTATSD_HOST`. pub fn dogstatsd_agent_host(&self) -> &str { self.dogstatsd_agent_host.value().as_ref() } - /// Returns `DD_DOGSTATSD_PORT` — default: `8125` + /// Returns the value of `DD_DOGSTATSD_PORT`. pub fn dogstatsd_agent_port(&self) -> u32 { *self.dogstatsd_agent_port.value() } - /// Returns `DD_INSTRUMENTATION_TELEMETRY_ENABLED` — default: `true` + /// Returns the value of `DD_INSTRUMENTATION_TELEMETRY_ENABLED`. pub fn telemetry_enabled(&self) -> bool { *self.telemetry_enabled.value() } - /// Returns `DD_METRICS_OTEL_ENABLED` — default: `true` + /// Returns the value of `DD_METRICS_OTEL_ENABLED`. pub fn metrics_otel_enabled(&self) -> bool { *self.metrics_otel_enabled.value() } - /// Returns `DD_REMOTE_CONFIGURATION_ENABLED` — default: `true` - /// Aliases: `DD_REMOTE_CONFIG_ENABLED` + /// Returns the value of `DD_REMOTE_CONFIGURATION_ENABLED`. pub fn remote_config_enabled(&self) -> bool { *self.remote_config_enabled.value() } - /// Returns `DD_TELEMETRY_LOG_COLLECTION_ENABLED` — default: `true` + /// Returns the value of `DD_TELEMETRY_LOG_COLLECTION_ENABLED`. pub fn telemetry_log_collection_enabled(&self) -> bool { *self.telemetry_log_collection_enabled.value() } - /// Returns `DD_TRACE_AGENT_PORT` — default: `8126` + /// Returns the value of `DD_TRACE_AGENT_PORT`. pub fn trace_agent_port(&self) -> u32 { *self.trace_agent_port.value() } - /// Returns `DD_TRACE_AGENT_URL` — default: `` + /// Returns the value of `DD_TRACE_AGENT_URL`. pub fn trace_agent_url(&self) -> &str { self.trace_agent_url.value().as_ref() } - /// Returns `DD_TRACE_ENABLED` — default: `true` + /// Returns the value of `DD_TRACE_ENABLED`. pub fn enabled(&self) -> bool { *self.enabled.value() } - /// Returns `DD_TRACE_PARTIAL_FLUSH_ENABLED` — default: `false` + /// Returns the value of `DD_TRACE_PARTIAL_FLUSH_ENABLED`. pub fn trace_partial_flush_enabled(&self) -> bool { *self.trace_partial_flush_enabled.value() } - /// Returns `DD_TRACE_PROPAGATION_EXTRACT_FIRST` — default: `false` + /// Returns the value of `DD_TRACE_PROPAGATION_EXTRACT_FIRST`. pub fn trace_propagation_extract_first(&self) -> bool { *self.trace_propagation_extract_first.value() } - /// Returns `DD_TRACE_STATS_COMPUTATION_ENABLED` — default: `true` + /// Returns the value of `DD_TRACE_STATS_COMPUTATION_ENABLED`. pub fn trace_stats_computation_enabled(&self) -> bool { *self.trace_stats_computation_enabled.value() } - /// Returns `OTEL_EXPORTER_OTLP_ENDPOINT` + /// Returns the value of `OTEL_EXPORTER_OTLP_ENDPOINT`. pub fn otlp_endpoint(&self) -> &str { self.otlp_endpoint.value().as_ref() } - /// Returns `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` + /// Returns the value of `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`. pub fn otlp_metrics_endpoint(&self) -> &str { self.otlp_metrics_endpoint.value().as_ref() } - /// Returns `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` — default: `10000` + /// Returns the value of `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT`. pub fn otlp_metrics_timeout(&self) -> u32 { *self.otlp_metrics_timeout.value() } - /// Returns `OTEL_EXPORTER_OTLP_TIMEOUT` — default: `10000` + /// Returns the value of `OTEL_EXPORTER_OTLP_TIMEOUT`. pub fn otlp_timeout(&self) -> u32 { *self.otlp_timeout.value() } - /// Returns `OTEL_METRICS_EXPORTER` — default: `otlp` + /// Returns the value of `OTEL_METRICS_EXPORTER`. pub fn otel_metrics_exporter(&self) -> &str { self.otel_metrics_exporter.value().as_ref() } - /// Returns `OTEL_METRIC_EXPORT_INTERVAL` — default: `10000` + /// Returns the value of `OTEL_METRIC_EXPORT_INTERVAL`. pub fn metric_export_interval(&self) -> u32 { *self.metric_export_interval.value() } - /// Returns `OTEL_METRIC_EXPORT_TIMEOUT` — default: `7500` + /// Returns the value of `OTEL_METRIC_EXPORT_TIMEOUT`. pub fn metric_export_timeout(&self) -> u32 { *self.metric_export_timeout.value() } @@ -414,122 +413,198 @@ impl Config { } impl ConfigBuilder { - /// Sets `DD_AGENT_HOST` — default: `localhost` + /// Sets the value of `DD_AGENT_HOST`. + /// + /// **Default**: `localhost` + /// + /// Env variable: `DD_AGENT_HOST` pub fn set_agent_host(&mut self, val: String) -> &mut Self { self.config.agent_host.set_code(Cow::Owned(val)); self } - /// Sets `DD_DOGSTATSD_HOST` — default: `localhost` + /// Sets the value of `DD_DOGSTATSD_HOST`. + /// + /// **Default**: `localhost` + /// + /// Env variable: `DD_DOGSTATSD_HOST` pub fn set_dogstatsd_agent_host(&mut self, val: String) -> &mut Self { self.config.dogstatsd_agent_host.set_code(Cow::Owned(val)); self } - /// Sets `DD_DOGSTATSD_PORT` — default: `8125` + /// Sets the value of `DD_DOGSTATSD_PORT`. + /// + /// **Default**: `8125` + /// + /// Env variable: `DD_DOGSTATSD_PORT` pub fn set_dogstatsd_agent_port(&mut self, val: u32) -> &mut Self { self.config.dogstatsd_agent_port.set_code(val); self } - /// Sets `DD_INSTRUMENTATION_TELEMETRY_ENABLED` — default: `true` + /// Sets the value of `DD_INSTRUMENTATION_TELEMETRY_ENABLED`. + /// + /// **Default**: `true` + /// + /// Env variable: `DD_INSTRUMENTATION_TELEMETRY_ENABLED` pub fn set_telemetry_enabled(&mut self, val: bool) -> &mut Self { self.config.telemetry_enabled.set_code(val); self } - /// Sets `DD_METRICS_OTEL_ENABLED` — default: `true` + /// Sets the value of `DD_METRICS_OTEL_ENABLED`. + /// + /// **Default**: `true` + /// + /// Env variable: `DD_METRICS_OTEL_ENABLED` pub fn set_metrics_otel_enabled(&mut self, val: bool) -> &mut Self { self.config.metrics_otel_enabled.set_code(val); self } - /// Sets `DD_REMOTE_CONFIGURATION_ENABLED` — default: `true` + /// Sets the value of `DD_REMOTE_CONFIGURATION_ENABLED`. + /// + /// **Default**: `true` + /// + /// Env variable: `DD_REMOTE_CONFIGURATION_ENABLED` /// Aliases: `DD_REMOTE_CONFIG_ENABLED` pub fn set_remote_config_enabled(&mut self, val: bool) -> &mut Self { self.config.remote_config_enabled.set_code(val); self } - /// Sets `DD_TELEMETRY_LOG_COLLECTION_ENABLED` — default: `true` + /// Sets the value of `DD_TELEMETRY_LOG_COLLECTION_ENABLED`. + /// + /// **Default**: `true` + /// + /// Env variable: `DD_TELEMETRY_LOG_COLLECTION_ENABLED` pub fn set_telemetry_log_collection_enabled(&mut self, val: bool) -> &mut Self { self.config.telemetry_log_collection_enabled.set_code(val); self } - /// Sets `DD_TRACE_AGENT_PORT` — default: `8126` + /// Sets the value of `DD_TRACE_AGENT_PORT`. + /// + /// **Default**: `8126` + /// + /// Env variable: `DD_TRACE_AGENT_PORT` pub fn set_trace_agent_port(&mut self, val: u32) -> &mut Self { self.config.trace_agent_port.set_code(val); self } - /// Sets `DD_TRACE_AGENT_URL` — default: `` + /// Sets the value of `DD_TRACE_AGENT_URL`. + /// + /// **Default**: `` + /// + /// Env variable: `DD_TRACE_AGENT_URL` pub fn set_trace_agent_url(&mut self, val: String) -> &mut Self { self.config.trace_agent_url.set_code(Cow::Owned(val)); self } - /// Sets `DD_TRACE_ENABLED` — default: `true` + /// Sets the value of `DD_TRACE_ENABLED`. + /// + /// **Default**: `true` + /// + /// Env variable: `DD_TRACE_ENABLED` pub fn set_enabled(&mut self, val: bool) -> &mut Self { self.config.enabled.set_code(val); self } - /// Sets `DD_TRACE_PARTIAL_FLUSH_ENABLED` — default: `false` + /// Sets the value of `DD_TRACE_PARTIAL_FLUSH_ENABLED`. + /// + /// **Default**: `false` + /// + /// Env variable: `DD_TRACE_PARTIAL_FLUSH_ENABLED` pub fn set_trace_partial_flush_enabled(&mut self, val: bool) -> &mut Self { self.config.trace_partial_flush_enabled.set_code(val); self } - /// Sets `DD_TRACE_PROPAGATION_EXTRACT_FIRST` — default: `false` + /// Sets the value of `DD_TRACE_PROPAGATION_EXTRACT_FIRST`. + /// + /// **Default**: `false` + /// + /// Env variable: `DD_TRACE_PROPAGATION_EXTRACT_FIRST` pub fn set_trace_propagation_extract_first(&mut self, val: bool) -> &mut Self { self.config.trace_propagation_extract_first.set_code(val); self } - /// Sets `DD_TRACE_STATS_COMPUTATION_ENABLED` — default: `true` + /// Sets the value of `DD_TRACE_STATS_COMPUTATION_ENABLED`. + /// + /// **Default**: `true` + /// + /// Env variable: `DD_TRACE_STATS_COMPUTATION_ENABLED` pub fn set_trace_stats_computation_enabled(&mut self, val: bool) -> &mut Self { self.config.trace_stats_computation_enabled.set_code(val); self } - /// Sets `OTEL_EXPORTER_OTLP_ENDPOINT` + /// Sets the value of `OTEL_EXPORTER_OTLP_ENDPOINT`. + /// + /// Env variable: `OTEL_EXPORTER_OTLP_ENDPOINT` pub fn set_otlp_endpoint(&mut self, val: String) -> &mut Self { self.config.otlp_endpoint.set_code(Cow::Owned(val)); self } - /// Sets `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` + /// Sets the value of `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`. + /// + /// Env variable: `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` pub fn set_otlp_metrics_endpoint(&mut self, val: String) -> &mut Self { self.config.otlp_metrics_endpoint.set_code(Cow::Owned(val)); self } - /// Sets `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` — default: `10000` + /// Sets the value of `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT`. + /// + /// **Default**: `10000` + /// + /// Env variable: `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` pub fn set_otlp_metrics_timeout(&mut self, val: u32) -> &mut Self { self.config.otlp_metrics_timeout.set_code(val); self } - /// Sets `OTEL_EXPORTER_OTLP_TIMEOUT` — default: `10000` + /// Sets the value of `OTEL_EXPORTER_OTLP_TIMEOUT`. + /// + /// **Default**: `10000` + /// + /// Env variable: `OTEL_EXPORTER_OTLP_TIMEOUT` pub fn set_otlp_timeout(&mut self, val: u32) -> &mut Self { self.config.otlp_timeout.set_code(val); self } - /// Sets `OTEL_METRICS_EXPORTER` — default: `otlp` + /// Sets the value of `OTEL_METRICS_EXPORTER`. + /// + /// **Default**: `otlp` + /// + /// Env variable: `OTEL_METRICS_EXPORTER` pub fn set_otel_metrics_exporter(&mut self, val: String) -> &mut Self { self.config.otel_metrics_exporter.set_code(Cow::Owned(val)); self } - /// Sets `OTEL_METRIC_EXPORT_INTERVAL` — default: `10000` + /// Sets the value of `OTEL_METRIC_EXPORT_INTERVAL`. + /// + /// **Default**: `10000` + /// + /// Env variable: `OTEL_METRIC_EXPORT_INTERVAL` pub fn set_metric_export_interval(&mut self, val: u32) -> &mut Self { self.config.metric_export_interval.set_code(val); self } - /// Sets `OTEL_METRIC_EXPORT_TIMEOUT` — default: `7500` + /// Sets the value of `OTEL_METRIC_EXPORT_TIMEOUT`. + /// + /// **Default**: `7500` + /// + /// Env variable: `OTEL_METRIC_EXPORT_TIMEOUT` pub fn set_metric_export_timeout(&mut self, val: u32) -> &mut Self { self.config.metric_export_timeout.set_code(val); self diff --git a/scripts/local_config_map_generate.py b/scripts/local_config_map_generate.py index 07512ae6..bc322c6b 100644 --- a/scripts/local_config_map_generate.py +++ b/scripts/local_config_map_generate.py @@ -91,13 +91,17 @@ default_display = versions[0].get("default") all_aliases = [a for v in versions for a in v.get("aliases", [])] - def make_doc(prefix): - doc = " /// {} `{}`".format(prefix, key) + def getter_doc(): + return " /// Returns the value of `{}`.".format(key) + + def setter_doc(): + lines = [" /// Sets the value of `{}`.".format(key)] if default_display is not None: - doc += " — default: `{}`".format(default_display) + lines += [" ///", " /// **Default**: `{}`".format(default_display), " ///"] + lines.append(" /// Env variable: `{}`".format(key)) if all_aliases: - doc += "\n /// Aliases: {}".format(", ".join("`{}`".format(a) for a in all_aliases)) - return doc + lines.append(" /// Aliases: {}".format(", ".join("`{}`".format(a) for a in all_aliases))) + return "\n".join(lines) # Build getter/setter lines for simple types skip_getters = "getter" in skip_set @@ -107,52 +111,52 @@ def make_doc(prefix): if not skip_getters: getter_lines.append( "{}\n pub fn {}(&self) -> &str {{ self.{}.value().as_ref() }}".format( - make_doc("Returns"), field_name, field_name + getter_doc(), field_name, field_name ) ) if not skip_setters: setter_lines.append( "{}\n pub fn set_{}(&mut self, val: String) -> &mut Self {{ self.config.{}.set_code(Cow::Owned(val)); self }}".format( - make_doc("Sets"), field_name, field_name + setter_doc(), field_name, field_name ) ) elif json_type == "int": if not skip_getters: getter_lines.append( "{}\n pub fn {}(&self) -> u32 {{ *self.{}.value() }}".format( - make_doc("Returns"), field_name, field_name + getter_doc(), field_name, field_name ) ) if not skip_setters: setter_lines.append( "{}\n pub fn set_{}(&mut self, val: u32) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - make_doc("Sets"), field_name, field_name + setter_doc(), field_name, field_name ) ) elif json_type == "decimal": if not skip_getters: getter_lines.append( "{}\n pub fn {}(&self) -> f64 {{ *self.{}.value() }}".format( - make_doc("Returns"), field_name, field_name + getter_doc(), field_name, field_name ) ) if not skip_setters: setter_lines.append( "{}\n pub fn set_{}(&mut self, val: f64) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - make_doc("Sets"), field_name, field_name + setter_doc(), field_name, field_name ) ) elif json_type == "boolean": if not skip_getters: getter_lines.append( "{}\n pub fn {}(&self) -> bool {{ *self.{}.value() }}".format( - make_doc("Returns"), field_name, field_name + getter_doc(), field_name, field_name ) ) if not skip_setters: setter_lines.append( "{}\n pub fn set_{}(&mut self, val: bool) -> &mut Self {{ self.config.{}.set_code(val); self }}".format( - make_doc("Sets"), field_name, field_name + setter_doc(), field_name, field_name ) ) From 24e1e9a2f56fcb075c7c5d9b2adec6f3d9394f55 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 24 Apr 2026 10:46:51 +0200 Subject: [PATCH 12/13] Cleanup --- .github/workflows/test.yaml | 6 ++---- .gitlab-ci.yml | 9 ++++++--- supported-configurations.json | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cfd854fd..f726aa9e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -165,16 +165,14 @@ jobs: parametric: needs: - build-artifacts - uses: DataDog/system-tests/.github/workflows/run-parametric.yml@8a65f66d74ca77f34e7e5a2f737e963ce9cec563 # main - secrets: inherit + uses: DataDog/system-tests/.github/workflows/run-parametric.yml@23941ab6de4122b7d0ca2b0d4aa7818def68a0d5 # main permissions: contents: read id-token: write - packages: write with: library: rust binaries_artifact: system_tests_binaries job_count: 2 job_matrix: '[1,2]' - ref: 8a65f66d74ca77f34e7e5a2f737e963ce9cec563 # main + ref: 23941ab6de4122b7d0ca2b0d4aa7818def68a0d5 # main push_to_test_optimization: true diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c37e0129..b18113ce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ default: # Config inversion CI steps validate_supported_configurations_v2_local_file: stage: config-validation - image: registry.ddbuild.io/ci/libdatadog-build/packaging:82290795 + image: registry.ddbuild.io/ci/libdatadog-build/packaging:100425777 rules: - when: on_success extends: .validate_supported_configurations_v2_local_file @@ -22,10 +22,13 @@ validate_supported_configurations_v2_local_file: LOCAL_JSON_PATH: "supported-configurations.json" BACKFILLED: "true" -# Executed on release (branch with tag vx.y.z) +# Executed on release tag datadog-opentelemetry-vx.y.z update_central_configurations_version_range_v2: stage: config-validation - image: registry.ddbuild.io/ci/libdatadog-build/packaging:82290795 + image: registry.ddbuild.io/ci/libdatadog-build/packaging:100425777 + rules: + - if: '$CI_COMMIT_TAG =~ /^datadog-opentelemetry-v[0-9]+\.[0-9]+\.[0-9]+$/' + when: on_success extends: .update_central_configurations_version_range_v2 variables: LOCAL_REPO_NAME: "dd-trace-rs" diff --git a/supported-configurations.json b/supported-configurations.json index ef8e965e..84b1a69c 100644 --- a/supported-configurations.json +++ b/supported-configurations.json @@ -325,7 +325,7 @@ ], "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": [ { - "version": "A", + "version": "B", "type": "int", "default": "10000", "propertyKeys": ["otlp_metrics_timeout"] From b5a4a819ea929201e32b1c128af03eea7e02d926 Mon Sep 17 00:00:00 2001 From: Nicolas Catoni Date: Fri, 24 Apr 2026 15:22:50 +0200 Subject: [PATCH 13/13] fix --- .../src/core/configuration/configuration.rs | 10 +- .../configuration/supported_configurations.rs | 480 ++++++++++++++---- scripts/local_config_map_generate.py | 27 +- supported-configurations.json | 11 +- 4 files changed, 407 insertions(+), 121 deletions(-) diff --git a/datadog-opentelemetry/src/core/configuration/configuration.rs b/datadog-opentelemetry/src/core/configuration/configuration.rs index b3bdc52e..1cd39cfc 100644 --- a/datadog-opentelemetry/src/core/configuration/configuration.rs +++ b/datadog-opentelemetry/src/core/configuration/configuration.rs @@ -968,11 +968,10 @@ impl Config { .update_parsed_with_transform(default.datadog_tags_max_length, |max: usize| { max.min(DATADOG_TAGS_MAX_LENGTH) }), - otlp_metrics_protocol: cisu.update_string( - default.otlp_metrics_protocol, - OtlpProtocol::parse_optional, - ), - dogstatsd_agent_url: cisu.update_non_empty_string(default.dogstatsd_agent_url, Cow::Owned), + otlp_metrics_protocol: cisu + .update_string(default.otlp_metrics_protocol, OtlpProtocol::parse_optional), + dogstatsd_agent_url: cisu + .update_non_empty_string(default.dogstatsd_agent_url, Cow::Owned), otlp_headers: cisu.update_string(default.otlp_headers, Cow::Owned), otlp_metrics_headers: cisu.update_string(default.otlp_metrics_headers, Cow::Owned), otlp_protocol: cisu.update_string(default.otlp_protocol, OtlpProtocol::parse_optional), @@ -1118,7 +1117,6 @@ impl Config { self.trace_writer_max_flush_interval } - #[cfg(feature = "test-utils")] pub(crate) fn __internal_wait_agent_info_ready(&self) -> bool { self.wait_agent_info_ready diff --git a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs index 9513fad3..93f95d92 100644 --- a/datadog-opentelemetry/src/core/configuration/supported_configurations.rs +++ b/datadog-opentelemetry/src/core/configuration/supported_configurations.rs @@ -6,6 +6,7 @@ /// add it to the supported-configurations.json file, then run this script. use std::borrow::Cow; use std::sync::{Arc, Mutex}; +use std::time::Duration; use rustc_version_runtime::version; @@ -86,41 +87,83 @@ impl SupportedConfigurations { SupportedConfigurations::DD_DOGSTATSD_PORT => "DD_DOGSTATSD_PORT", SupportedConfigurations::DD_DOGSTATSD_URL => "DD_DOGSTATSD_URL", SupportedConfigurations::DD_ENV => "DD_ENV", - SupportedConfigurations::DD_INSTRUMENTATION_TELEMETRY_ENABLED => "DD_INSTRUMENTATION_TELEMETRY_ENABLED", + SupportedConfigurations::DD_INSTRUMENTATION_TELEMETRY_ENABLED => { + "DD_INSTRUMENTATION_TELEMETRY_ENABLED" + } SupportedConfigurations::DD_LOGS_OTEL_ENABLED => "DD_LOGS_OTEL_ENABLED", SupportedConfigurations::DD_LOG_LEVEL => "DD_LOG_LEVEL", SupportedConfigurations::DD_METRICS_OTEL_ENABLED => "DD_METRICS_OTEL_ENABLED", - SupportedConfigurations::DD_REMOTE_CONFIGURATION_ENABLED => "DD_REMOTE_CONFIGURATION_ENABLED", - SupportedConfigurations::DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS => "DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS", + SupportedConfigurations::DD_REMOTE_CONFIGURATION_ENABLED => { + "DD_REMOTE_CONFIGURATION_ENABLED" + } + SupportedConfigurations::DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS => { + "DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS" + } SupportedConfigurations::DD_SERVICE => "DD_SERVICE", SupportedConfigurations::DD_TAGS => "DD_TAGS", - SupportedConfigurations::DD_TELEMETRY_HEARTBEAT_INTERVAL => "DD_TELEMETRY_HEARTBEAT_INTERVAL", - SupportedConfigurations::DD_TELEMETRY_LOG_COLLECTION_ENABLED => "DD_TELEMETRY_LOG_COLLECTION_ENABLED", + SupportedConfigurations::DD_TELEMETRY_HEARTBEAT_INTERVAL => { + "DD_TELEMETRY_HEARTBEAT_INTERVAL" + } + SupportedConfigurations::DD_TELEMETRY_LOG_COLLECTION_ENABLED => { + "DD_TELEMETRY_LOG_COLLECTION_ENABLED" + } SupportedConfigurations::DD_TRACE_AGENT_PORT => "DD_TRACE_AGENT_PORT", SupportedConfigurations::DD_TRACE_AGENT_URL => "DD_TRACE_AGENT_URL", SupportedConfigurations::DD_TRACE_ENABLED => "DD_TRACE_ENABLED", - SupportedConfigurations::DD_TRACE_PARTIAL_FLUSH_ENABLED => "DD_TRACE_PARTIAL_FLUSH_ENABLED", - SupportedConfigurations::DD_TRACE_PARTIAL_FLUSH_MIN_SPANS => "DD_TRACE_PARTIAL_FLUSH_MIN_SPANS", - SupportedConfigurations::DD_TRACE_PROPAGATION_EXTRACT_FIRST => "DD_TRACE_PROPAGATION_EXTRACT_FIRST", + SupportedConfigurations::DD_TRACE_PARTIAL_FLUSH_ENABLED => { + "DD_TRACE_PARTIAL_FLUSH_ENABLED" + } + SupportedConfigurations::DD_TRACE_PARTIAL_FLUSH_MIN_SPANS => { + "DD_TRACE_PARTIAL_FLUSH_MIN_SPANS" + } + SupportedConfigurations::DD_TRACE_PROPAGATION_EXTRACT_FIRST => { + "DD_TRACE_PROPAGATION_EXTRACT_FIRST" + } SupportedConfigurations::DD_TRACE_PROPAGATION_STYLE => "DD_TRACE_PROPAGATION_STYLE", - SupportedConfigurations::DD_TRACE_PROPAGATION_STYLE_EXTRACT => "DD_TRACE_PROPAGATION_STYLE_EXTRACT", - SupportedConfigurations::DD_TRACE_PROPAGATION_STYLE_INJECT => "DD_TRACE_PROPAGATION_STYLE_INJECT", + SupportedConfigurations::DD_TRACE_PROPAGATION_STYLE_EXTRACT => { + "DD_TRACE_PROPAGATION_STYLE_EXTRACT" + } + SupportedConfigurations::DD_TRACE_PROPAGATION_STYLE_INJECT => { + "DD_TRACE_PROPAGATION_STYLE_INJECT" + } SupportedConfigurations::DD_TRACE_RATE_LIMIT => "DD_TRACE_RATE_LIMIT", SupportedConfigurations::DD_TRACE_SAMPLING_RULES => "DD_TRACE_SAMPLING_RULES", - SupportedConfigurations::DD_TRACE_STATS_COMPUTATION_ENABLED => "DD_TRACE_STATS_COMPUTATION_ENABLED", - SupportedConfigurations::DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH => "DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH", + SupportedConfigurations::DD_TRACE_STATS_COMPUTATION_ENABLED => { + "DD_TRACE_STATS_COMPUTATION_ENABLED" + } + SupportedConfigurations::DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH => { + "DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH" + } SupportedConfigurations::DD_VERSION => "DD_VERSION", SupportedConfigurations::OTEL_EXPORTER_OTLP_ENDPOINT => "OTEL_EXPORTER_OTLP_ENDPOINT", SupportedConfigurations::OTEL_EXPORTER_OTLP_HEADERS => "OTEL_EXPORTER_OTLP_HEADERS", - SupportedConfigurations::OTEL_EXPORTER_OTLP_LOGS_ENDPOINT => "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT", - SupportedConfigurations::OTEL_EXPORTER_OTLP_LOGS_HEADERS => "OTEL_EXPORTER_OTLP_LOGS_HEADERS", - SupportedConfigurations::OTEL_EXPORTER_OTLP_LOGS_PROTOCOL => "OTEL_EXPORTER_OTLP_LOGS_PROTOCOL", - SupportedConfigurations::OTEL_EXPORTER_OTLP_LOGS_TIMEOUT => "OTEL_EXPORTER_OTLP_LOGS_TIMEOUT", - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_ENDPOINT => "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT", - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_HEADERS => "OTEL_EXPORTER_OTLP_METRICS_HEADERS", - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_PROTOCOL => "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL", - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE => "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE", - SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_TIMEOUT => "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT", + SupportedConfigurations::OTEL_EXPORTER_OTLP_LOGS_ENDPOINT => { + "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT" + } + SupportedConfigurations::OTEL_EXPORTER_OTLP_LOGS_HEADERS => { + "OTEL_EXPORTER_OTLP_LOGS_HEADERS" + } + SupportedConfigurations::OTEL_EXPORTER_OTLP_LOGS_PROTOCOL => { + "OTEL_EXPORTER_OTLP_LOGS_PROTOCOL" + } + SupportedConfigurations::OTEL_EXPORTER_OTLP_LOGS_TIMEOUT => { + "OTEL_EXPORTER_OTLP_LOGS_TIMEOUT" + } + SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_ENDPOINT => { + "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT" + } + SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_HEADERS => { + "OTEL_EXPORTER_OTLP_METRICS_HEADERS" + } + SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_PROTOCOL => { + "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL" + } + SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE => { + "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE" + } + SupportedConfigurations::OTEL_EXPORTER_OTLP_METRICS_TIMEOUT => { + "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT" + } SupportedConfigurations::OTEL_EXPORTER_OTLP_PROTOCOL => "OTEL_EXPORTER_OTLP_PROTOCOL", SupportedConfigurations::OTEL_EXPORTER_OTLP_TIMEOUT => "OTEL_EXPORTER_OTLP_TIMEOUT", SupportedConfigurations::OTEL_LOGS_EXPORTER => "OTEL_LOGS_EXPORTER", @@ -133,17 +176,26 @@ impl SupportedConfigurations { #[cfg(test)] SupportedConfigurations::DD_NONEXISTANT_CONFIGURATION => "DD_NONEXISTANT_CONFIGURATION", #[cfg(test)] - SupportedConfigurations::DD_NONEXISTANT_CONFIGURATION_ALIAS => "DD_NONEXISTANT_CONFIGURATION_ALIAS", + SupportedConfigurations::DD_NONEXISTANT_CONFIGURATION_ALIAS => { + "DD_NONEXISTANT_CONFIGURATION_ALIAS" + } #[cfg(test)] - SupportedConfigurations::DD_NONEXISTANT_CONFIGURATION_DEPRECATED => "DD_NONEXISTANT_CONFIGURATION_DEPRECATED", + SupportedConfigurations::DD_NONEXISTANT_CONFIGURATION_DEPRECATED => { + "DD_NONEXISTANT_CONFIGURATION_DEPRECATED" + } } } pub fn aliases(&self) -> &[&'static str] { match self { - SupportedConfigurations::DD_REMOTE_CONFIGURATION_ENABLED => &["DD_REMOTE_CONFIG_ENABLED"], + SupportedConfigurations::DD_REMOTE_CONFIGURATION_ENABLED => { + &["DD_REMOTE_CONFIG_ENABLED"] + } #[cfg(test)] - SupportedConfigurations::DD_NONEXISTANT_CONFIGURATION => &["DD_NONEXISTANT_CONFIGURATION_ALIAS", "DD_NONEXISTANT_CONFIGURATION_DEPRECATED_ALIAS"], + SupportedConfigurations::DD_NONEXISTANT_CONFIGURATION => &[ + "DD_NONEXISTANT_CONFIGURATION_ALIAS", + "DD_NONEXISTANT_CONFIGURATION_DEPRECATED_ALIAS", + ], _ => &[], } } @@ -160,7 +212,7 @@ impl SupportedConfigurations { pub fn is_alias_deprecated(name: &str) -> bool { match name { "DD_REMOTE_CONFIG_ENABLED" => true, - #[cfg(test)] + #[cfg(test)] "DD_NONEXISTANT_CONFIGURATION_DEPRECATED_ALIAS" => true, _ => false, } @@ -188,7 +240,7 @@ pub struct Config { pub(super) agent_host: ConfigItem>, pub(super) dogstatsd_agent_host: ConfigItem>, pub(super) dogstatsd_agent_port: ConfigItem, - pub(super) dogstatsd_agent_url: ConfigItem>, + pub(super) dogstatsd_agent_url: ConfigItemWithOverride>, pub(super) env: ConfigItem>, pub(super) telemetry_enabled: ConfigItem, pub(super) logs_otel_enabled: ConfigItem, @@ -201,7 +253,7 @@ pub struct Config { pub(super) telemetry_heartbeat_interval: ConfigItem, pub(super) telemetry_log_collection_enabled: ConfigItem, pub(super) trace_agent_port: ConfigItem, - pub(super) trace_agent_url: ConfigItem>, + pub(super) trace_agent_url: ConfigItemWithOverride>, pub(super) enabled: ConfigItem, pub(super) trace_partial_flush_enabled: ConfigItem, pub(super) trace_partial_flush_min_spans: ConfigItem, @@ -218,20 +270,24 @@ pub struct Config { pub(super) otlp_headers: ConfigItem>, pub(super) otlp_logs_endpoint: ConfigItem>, pub(super) otlp_logs_headers: ConfigItem>, - pub(super) otlp_logs_protocol: ConfigItem>, + pub(super) otlp_logs_protocol: ConfigItem>, pub(super) otlp_logs_timeout: ConfigItem, pub(super) otlp_metrics_endpoint: ConfigItem>, pub(super) otlp_metrics_headers: ConfigItem>, - pub(super) otlp_metrics_protocol: ConfigItem>, - pub(super) otel_metrics_temporality_preference: ConfigItem>, + pub(super) otlp_metrics_protocol: ConfigItem>, + pub(super) otel_metrics_temporality_preference: + ConfigItem>, pub(super) otlp_metrics_timeout: ConfigItem, - pub(super) otlp_protocol: ConfigItem>, + pub(super) otlp_protocol: ConfigItem>, pub(super) otlp_timeout: ConfigItem, pub(super) otel_logs_exporter: ConfigItem>, pub(super) otel_metrics_exporter: ConfigItem>, pub(super) metric_export_interval: ConfigItem, pub(super) metric_export_timeout: ConfigItem, pub(super) otel_resource_attributes: ConfigItem>, + pub(super) trace_writer_synchronous_write: bool, + pub(super) trace_writer_synchronous_timeout: Duration, + pub(super) trace_writer_max_flush_interval: Duration, #[cfg(feature = "test-utils")] pub(super) wait_agent_info_ready: bool, pub(super) extra_services_tracker: ExtraServicesTracker, @@ -241,79 +297,129 @@ pub struct Config { #[allow(missing_docs)] impl Config { /// Returns the value of `DD_AGENT_HOST`. - pub fn agent_host(&self) -> &str { self.agent_host.value().as_ref() } + pub fn agent_host(&self) -> &str { + self.agent_host.value().as_ref() + } /// Returns the value of `DD_DOGSTATSD_HOST`. - pub fn dogstatsd_agent_host(&self) -> &str { self.dogstatsd_agent_host.value().as_ref() } + pub fn dogstatsd_agent_host(&self) -> &str { + self.dogstatsd_agent_host.value().as_ref() + } /// Returns the value of `DD_DOGSTATSD_PORT`. - pub fn dogstatsd_agent_port(&self) -> u32 { *self.dogstatsd_agent_port.value() } + pub fn dogstatsd_agent_port(&self) -> u32 { + *self.dogstatsd_agent_port.value() + } /// Returns the value of `DD_INSTRUMENTATION_TELEMETRY_ENABLED`. - pub fn telemetry_enabled(&self) -> bool { *self.telemetry_enabled.value() } + pub fn telemetry_enabled(&self) -> bool { + *self.telemetry_enabled.value() + } /// Returns the value of `DD_LOGS_OTEL_ENABLED`. - pub fn logs_otel_enabled(&self) -> bool { *self.logs_otel_enabled.value() } + pub fn logs_otel_enabled(&self) -> bool { + *self.logs_otel_enabled.value() + } /// Returns the value of `DD_METRICS_OTEL_ENABLED`. - pub fn metrics_otel_enabled(&self) -> bool { *self.metrics_otel_enabled.value() } + pub fn metrics_otel_enabled(&self) -> bool { + *self.metrics_otel_enabled.value() + } /// Returns the value of `DD_REMOTE_CONFIGURATION_ENABLED`. - pub fn remote_config_enabled(&self) -> bool { *self.remote_config_enabled.value() } + pub fn remote_config_enabled(&self) -> bool { + *self.remote_config_enabled.value() + } /// Returns the value of `DD_TELEMETRY_LOG_COLLECTION_ENABLED`. - pub fn telemetry_log_collection_enabled(&self) -> bool { *self.telemetry_log_collection_enabled.value() } + pub fn telemetry_log_collection_enabled(&self) -> bool { + *self.telemetry_log_collection_enabled.value() + } /// Returns the value of `DD_TRACE_AGENT_PORT`. - pub fn trace_agent_port(&self) -> u32 { *self.trace_agent_port.value() } + pub fn trace_agent_port(&self) -> u32 { + *self.trace_agent_port.value() + } /// Returns the value of `DD_TRACE_AGENT_URL`. - pub fn trace_agent_url(&self) -> &str { self.trace_agent_url.value().as_ref() } + pub fn trace_agent_url(&self) -> impl Deref + use<'_> { + self.trace_agent_url.value() + } /// Returns the value of `DD_TRACE_ENABLED`. - pub fn enabled(&self) -> bool { *self.enabled.value() } + pub fn enabled(&self) -> bool { + *self.enabled.value() + } /// Returns the value of `DD_TRACE_PARTIAL_FLUSH_ENABLED`. - pub fn trace_partial_flush_enabled(&self) -> bool { *self.trace_partial_flush_enabled.value() } + pub fn trace_partial_flush_enabled(&self) -> bool { + *self.trace_partial_flush_enabled.value() + } /// Returns the value of `DD_TRACE_PROPAGATION_EXTRACT_FIRST`. - pub fn trace_propagation_extract_first(&self) -> bool { *self.trace_propagation_extract_first.value() } + pub fn trace_propagation_extract_first(&self) -> bool { + *self.trace_propagation_extract_first.value() + } /// Returns the value of `DD_TRACE_STATS_COMPUTATION_ENABLED`. - pub fn trace_stats_computation_enabled(&self) -> bool { *self.trace_stats_computation_enabled.value() } + pub fn trace_stats_computation_enabled(&self) -> bool { + *self.trace_stats_computation_enabled.value() + } /// Returns the value of `OTEL_EXPORTER_OTLP_ENDPOINT`. - pub fn otlp_endpoint(&self) -> &str { self.otlp_endpoint.value().as_ref() } + pub fn otlp_endpoint(&self) -> &str { + self.otlp_endpoint.value().as_ref() + } /// Returns the value of `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`. - pub fn otlp_logs_endpoint(&self) -> &str { self.otlp_logs_endpoint.value().as_ref() } + pub fn otlp_logs_endpoint(&self) -> &str { + self.otlp_logs_endpoint.value().as_ref() + } /// Returns the value of `OTEL_EXPORTER_OTLP_LOGS_HEADERS`. - pub fn otlp_logs_headers(&self) -> &str { self.otlp_logs_headers.value().as_ref() } + pub fn otlp_logs_headers(&self) -> &str { + self.otlp_logs_headers.value().as_ref() + } /// Returns the value of `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT`. - pub fn otlp_logs_timeout(&self) -> u32 { *self.otlp_logs_timeout.value() } + pub fn otlp_logs_timeout(&self) -> u32 { + *self.otlp_logs_timeout.value() + } /// Returns the value of `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`. - pub fn otlp_metrics_endpoint(&self) -> &str { self.otlp_metrics_endpoint.value().as_ref() } + pub fn otlp_metrics_endpoint(&self) -> &str { + self.otlp_metrics_endpoint.value().as_ref() + } /// Returns the value of `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT`. - pub fn otlp_metrics_timeout(&self) -> u32 { *self.otlp_metrics_timeout.value() } + pub fn otlp_metrics_timeout(&self) -> u32 { + *self.otlp_metrics_timeout.value() + } /// Returns the value of `OTEL_EXPORTER_OTLP_TIMEOUT`. - pub fn otlp_timeout(&self) -> u32 { *self.otlp_timeout.value() } + pub fn otlp_timeout(&self) -> u32 { + *self.otlp_timeout.value() + } /// Returns the value of `OTEL_LOGS_EXPORTER`. - pub fn otel_logs_exporter(&self) -> &str { self.otel_logs_exporter.value().as_ref() } + pub fn otel_logs_exporter(&self) -> &str { + self.otel_logs_exporter.value().as_ref() + } /// Returns the value of `OTEL_METRICS_EXPORTER`. - pub fn otel_metrics_exporter(&self) -> &str { self.otel_metrics_exporter.value().as_ref() } + pub fn otel_metrics_exporter(&self) -> &str { + self.otel_metrics_exporter.value().as_ref() + } /// Returns the value of `OTEL_METRIC_EXPORT_INTERVAL`. - pub fn metric_export_interval(&self) -> u32 { *self.metric_export_interval.value() } + pub fn metric_export_interval(&self) -> u32 { + *self.metric_export_interval.value() + } /// Returns the value of `OTEL_METRIC_EXPORT_TIMEOUT`. - pub fn metric_export_timeout(&self) -> u32 { *self.metric_export_timeout.value() } + pub fn metric_export_timeout(&self) -> u32 { + *self.metric_export_timeout.value() + } pub(crate) fn get_telemetry_configuration(&self) -> Vec<&dyn ConfigurationProvider> { vec![ @@ -375,42 +481,60 @@ impl ConfigBuilder { /// **Default**: `localhost` /// /// Env variable: `DD_AGENT_HOST` - pub fn set_agent_host(&mut self, val: String) -> &mut Self { self.config.agent_host.set_code(Cow::Owned(val)); self } + pub fn set_agent_host(&mut self, val: String) -> &mut Self { + self.config.agent_host.set_code(Cow::Owned(val)); + self + } /// Sets the value of `DD_DOGSTATSD_HOST`. /// /// **Default**: `localhost` /// /// Env variable: `DD_DOGSTATSD_HOST` - pub fn set_dogstatsd_agent_host(&mut self, val: String) -> &mut Self { self.config.dogstatsd_agent_host.set_code(Cow::Owned(val)); self } + pub fn set_dogstatsd_agent_host(&mut self, val: String) -> &mut Self { + self.config.dogstatsd_agent_host.set_code(Cow::Owned(val)); + self + } /// Sets the value of `DD_DOGSTATSD_PORT`. /// /// **Default**: `8125` /// /// Env variable: `DD_DOGSTATSD_PORT` - pub fn set_dogstatsd_agent_port(&mut self, val: u32) -> &mut Self { self.config.dogstatsd_agent_port.set_code(val); self } + pub fn set_dogstatsd_agent_port(&mut self, val: u32) -> &mut Self { + self.config.dogstatsd_agent_port.set_code(val); + self + } /// Sets the value of `DD_INSTRUMENTATION_TELEMETRY_ENABLED`. /// /// **Default**: `true` /// /// Env variable: `DD_INSTRUMENTATION_TELEMETRY_ENABLED` - pub fn set_telemetry_enabled(&mut self, val: bool) -> &mut Self { self.config.telemetry_enabled.set_code(val); self } + pub fn set_telemetry_enabled(&mut self, val: bool) -> &mut Self { + self.config.telemetry_enabled.set_code(val); + self + } /// Sets the value of `DD_LOGS_OTEL_ENABLED`. /// /// **Default**: `true` /// /// Env variable: `DD_LOGS_OTEL_ENABLED` - pub fn set_logs_otel_enabled(&mut self, val: bool) -> &mut Self { self.config.logs_otel_enabled.set_code(val); self } + pub fn set_logs_otel_enabled(&mut self, val: bool) -> &mut Self { + self.config.logs_otel_enabled.set_code(val); + self + } /// Sets the value of `DD_METRICS_OTEL_ENABLED`. /// /// **Default**: `true` /// /// Env variable: `DD_METRICS_OTEL_ENABLED` - pub fn set_metrics_otel_enabled(&mut self, val: bool) -> &mut Self { self.config.metrics_otel_enabled.set_code(val); self } + pub fn set_metrics_otel_enabled(&mut self, val: bool) -> &mut Self { + self.config.metrics_otel_enabled.set_code(val); + self + } /// Sets the value of `DD_REMOTE_CONFIGURATION_ENABLED`. /// @@ -418,121 +542,178 @@ impl ConfigBuilder { /// /// Env variable: `DD_REMOTE_CONFIGURATION_ENABLED` /// Aliases: `DD_REMOTE_CONFIG_ENABLED` - pub fn set_remote_config_enabled(&mut self, val: bool) -> &mut Self { self.config.remote_config_enabled.set_code(val); self } + pub fn set_remote_config_enabled(&mut self, val: bool) -> &mut Self { + self.config.remote_config_enabled.set_code(val); + self + } /// Sets the value of `DD_TELEMETRY_LOG_COLLECTION_ENABLED`. /// /// **Default**: `true` /// /// Env variable: `DD_TELEMETRY_LOG_COLLECTION_ENABLED` - pub fn set_telemetry_log_collection_enabled(&mut self, val: bool) -> &mut Self { self.config.telemetry_log_collection_enabled.set_code(val); self } + pub fn set_telemetry_log_collection_enabled(&mut self, val: bool) -> &mut Self { + self.config.telemetry_log_collection_enabled.set_code(val); + self + } /// Sets the value of `DD_TRACE_AGENT_PORT`. /// /// **Default**: `8126` /// /// Env variable: `DD_TRACE_AGENT_PORT` - pub fn set_trace_agent_port(&mut self, val: u32) -> &mut Self { self.config.trace_agent_port.set_code(val); self } + pub fn set_trace_agent_port(&mut self, val: u32) -> &mut Self { + self.config.trace_agent_port.set_code(val); + self + } /// Sets the value of `DD_TRACE_AGENT_URL`. /// /// **Default**: `` /// /// Env variable: `DD_TRACE_AGENT_URL` - pub fn set_trace_agent_url(&mut self, val: String) -> &mut Self { self.config.trace_agent_url.set_code(Cow::Owned(val)); self } + pub fn set_trace_agent_url(&mut self, val: String) -> &mut Self { + self.config.trace_agent_url.set_code(Cow::Owned(val)); + self + } /// Sets the value of `DD_TRACE_ENABLED`. /// /// **Default**: `true` /// /// Env variable: `DD_TRACE_ENABLED` - pub fn set_enabled(&mut self, val: bool) -> &mut Self { self.config.enabled.set_code(val); self } + pub fn set_enabled(&mut self, val: bool) -> &mut Self { + self.config.enabled.set_code(val); + self + } /// Sets the value of `DD_TRACE_PARTIAL_FLUSH_ENABLED`. /// /// **Default**: `false` /// /// Env variable: `DD_TRACE_PARTIAL_FLUSH_ENABLED` - pub fn set_trace_partial_flush_enabled(&mut self, val: bool) -> &mut Self { self.config.trace_partial_flush_enabled.set_code(val); self } + pub fn set_trace_partial_flush_enabled(&mut self, val: bool) -> &mut Self { + self.config.trace_partial_flush_enabled.set_code(val); + self + } /// Sets the value of `DD_TRACE_PROPAGATION_EXTRACT_FIRST`. /// /// **Default**: `false` /// /// Env variable: `DD_TRACE_PROPAGATION_EXTRACT_FIRST` - pub fn set_trace_propagation_extract_first(&mut self, val: bool) -> &mut Self { self.config.trace_propagation_extract_first.set_code(val); self } + pub fn set_trace_propagation_extract_first(&mut self, val: bool) -> &mut Self { + self.config.trace_propagation_extract_first.set_code(val); + self + } /// Sets the value of `DD_TRACE_STATS_COMPUTATION_ENABLED`. /// /// **Default**: `true` /// /// Env variable: `DD_TRACE_STATS_COMPUTATION_ENABLED` - pub fn set_trace_stats_computation_enabled(&mut self, val: bool) -> &mut Self { self.config.trace_stats_computation_enabled.set_code(val); self } + pub fn set_trace_stats_computation_enabled(&mut self, val: bool) -> &mut Self { + self.config.trace_stats_computation_enabled.set_code(val); + self + } /// Sets the value of `OTEL_EXPORTER_OTLP_ENDPOINT`. /// Env variable: `OTEL_EXPORTER_OTLP_ENDPOINT` - pub fn set_otlp_endpoint(&mut self, val: String) -> &mut Self { self.config.otlp_endpoint.set_code(Cow::Owned(val)); self } + pub fn set_otlp_endpoint(&mut self, val: String) -> &mut Self { + self.config.otlp_endpoint.set_code(Cow::Owned(val)); + self + } /// Sets the value of `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`. /// Env variable: `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` - pub fn set_otlp_logs_endpoint(&mut self, val: String) -> &mut Self { self.config.otlp_logs_endpoint.set_code(Cow::Owned(val)); self } + pub fn set_otlp_logs_endpoint(&mut self, val: String) -> &mut Self { + self.config.otlp_logs_endpoint.set_code(Cow::Owned(val)); + self + } /// Sets the value of `OTEL_EXPORTER_OTLP_LOGS_HEADERS`. /// Env variable: `OTEL_EXPORTER_OTLP_LOGS_HEADERS` - pub fn set_otlp_logs_headers(&mut self, val: String) -> &mut Self { self.config.otlp_logs_headers.set_code(Cow::Owned(val)); self } + pub fn set_otlp_logs_headers(&mut self, val: String) -> &mut Self { + self.config.otlp_logs_headers.set_code(Cow::Owned(val)); + self + } /// Sets the value of `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT`. /// /// **Default**: `10000` /// /// Env variable: `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` - pub fn set_otlp_logs_timeout(&mut self, val: u32) -> &mut Self { self.config.otlp_logs_timeout.set_code(val); self } + pub fn set_otlp_logs_timeout(&mut self, val: u32) -> &mut Self { + self.config.otlp_logs_timeout.set_code(val); + self + } /// Sets the value of `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`. /// Env variable: `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` - pub fn set_otlp_metrics_endpoint(&mut self, val: String) -> &mut Self { self.config.otlp_metrics_endpoint.set_code(Cow::Owned(val)); self } + pub fn set_otlp_metrics_endpoint(&mut self, val: String) -> &mut Self { + self.config.otlp_metrics_endpoint.set_code(Cow::Owned(val)); + self + } /// Sets the value of `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT`. /// /// **Default**: `10000` /// /// Env variable: `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` - pub fn set_otlp_metrics_timeout(&mut self, val: u32) -> &mut Self { self.config.otlp_metrics_timeout.set_code(val); self } + pub fn set_otlp_metrics_timeout(&mut self, val: u32) -> &mut Self { + self.config.otlp_metrics_timeout.set_code(val); + self + } /// Sets the value of `OTEL_EXPORTER_OTLP_TIMEOUT`. /// /// **Default**: `10000` /// /// Env variable: `OTEL_EXPORTER_OTLP_TIMEOUT` - pub fn set_otlp_timeout(&mut self, val: u32) -> &mut Self { self.config.otlp_timeout.set_code(val); self } + pub fn set_otlp_timeout(&mut self, val: u32) -> &mut Self { + self.config.otlp_timeout.set_code(val); + self + } /// Sets the value of `OTEL_LOGS_EXPORTER`. /// /// **Default**: `otlp` /// /// Env variable: `OTEL_LOGS_EXPORTER` - pub fn set_otel_logs_exporter(&mut self, val: String) -> &mut Self { self.config.otel_logs_exporter.set_code(Cow::Owned(val)); self } + pub fn set_otel_logs_exporter(&mut self, val: String) -> &mut Self { + self.config.otel_logs_exporter.set_code(Cow::Owned(val)); + self + } /// Sets the value of `OTEL_METRICS_EXPORTER`. /// /// **Default**: `otlp` /// /// Env variable: `OTEL_METRICS_EXPORTER` - pub fn set_otel_metrics_exporter(&mut self, val: String) -> &mut Self { self.config.otel_metrics_exporter.set_code(Cow::Owned(val)); self } + pub fn set_otel_metrics_exporter(&mut self, val: String) -> &mut Self { + self.config.otel_metrics_exporter.set_code(Cow::Owned(val)); + self + } /// Sets the value of `OTEL_METRIC_EXPORT_INTERVAL`. /// /// **Default**: `10000` /// /// Env variable: `OTEL_METRIC_EXPORT_INTERVAL` - pub fn set_metric_export_interval(&mut self, val: u32) -> &mut Self { self.config.metric_export_interval.set_code(val); self } + pub fn set_metric_export_interval(&mut self, val: u32) -> &mut Self { + self.config.metric_export_interval.set_code(val); + self + } /// Sets the value of `OTEL_METRIC_EXPORT_TIMEOUT`. /// /// **Default**: `7500` /// /// Env variable: `OTEL_METRIC_EXPORT_TIMEOUT` - pub fn set_metric_export_timeout(&mut self, val: u32) -> &mut Self { self.config.metric_export_timeout.set_code(val); self } + pub fn set_metric_export_timeout(&mut self, val: u32) -> &mut Self { + self.config.metric_export_timeout.set_code(val); + self + } } pub(super) fn default_config() -> Config { @@ -542,6 +723,9 @@ pub(super) fn default_config() -> Config { tracer_version: TRACER_VERSION, language: "rust", language_version: version().to_string(), + trace_writer_synchronous_write: false, + trace_writer_synchronous_timeout: Duration::from_secs(2), + trace_writer_max_flush_interval: Duration::from_secs(1), #[cfg(feature = "test-utils")] wait_agent_info_ready: false, extra_services_tracker: ExtraServicesTracker::new(), @@ -549,30 +733,63 @@ pub(super) fn default_config() -> Config { agent_host: ConfigItem::new(S::DD_AGENT_HOST, Cow::Borrowed("localhost")), dogstatsd_agent_host: ConfigItem::new(S::DD_DOGSTATSD_HOST, Cow::Borrowed("localhost")), dogstatsd_agent_port: ConfigItem::new(S::DD_DOGSTATSD_PORT, 8125), - dogstatsd_agent_url: ConfigItem::new(S::DD_DOGSTATSD_URL, Cow::Borrowed("")), + dogstatsd_agent_url: ConfigItemWithOverride::new_calculated( + S::DD_DOGSTATSD_URL, + Cow::Borrowed(""), + ), env: ConfigItem::new(S::DD_ENV, None), telemetry_enabled: ConfigItem::new(S::DD_INSTRUMENTATION_TELEMETRY_ENABLED, true), logs_otel_enabled: ConfigItem::new(S::DD_LOGS_OTEL_ENABLED, true), log_level_filter: ConfigItem::new(S::DD_LOG_LEVEL, LevelFilter::default()), metrics_otel_enabled: ConfigItem::new(S::DD_METRICS_OTEL_ENABLED, true), remote_config_enabled: ConfigItem::new(S::DD_REMOTE_CONFIGURATION_ENABLED, true), - remote_config_poll_interval: ConfigItem::new(S::DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS, 5.0), - service: ConfigItemWithOverride::new_code(S::DD_SERVICE, ServiceName::Default), + remote_config_poll_interval: ConfigItem::new( + S::DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS, + 5.0, + ), + service: ConfigItemWithOverride::new_calculated(S::DD_SERVICE, ServiceName::Default), global_tags: ConfigItem::new(S::DD_TAGS, Vec::new()), telemetry_heartbeat_interval: ConfigItem::new(S::DD_TELEMETRY_HEARTBEAT_INTERVAL, 60.0), - telemetry_log_collection_enabled: ConfigItem::new(S::DD_TELEMETRY_LOG_COLLECTION_ENABLED, true), + telemetry_log_collection_enabled: ConfigItem::new( + S::DD_TELEMETRY_LOG_COLLECTION_ENABLED, + true, + ), trace_agent_port: ConfigItem::new(S::DD_TRACE_AGENT_PORT, 8126), - trace_agent_url: ConfigItem::new(S::DD_TRACE_AGENT_URL, Cow::Borrowed("")), + trace_agent_url: ConfigItemWithOverride::new_calculated( + S::DD_TRACE_AGENT_URL, + Cow::Borrowed(""), + ), enabled: ConfigItem::new(S::DD_TRACE_ENABLED, true), trace_partial_flush_enabled: ConfigItem::new(S::DD_TRACE_PARTIAL_FLUSH_ENABLED, false), - trace_partial_flush_min_spans: ConfigItem::new(S::DD_TRACE_PARTIAL_FLUSH_MIN_SPANS, 300usize), - trace_propagation_extract_first: ConfigItem::new(S::DD_TRACE_PROPAGATION_EXTRACT_FIRST, false), - trace_propagation_style: ConfigItem::new(S::DD_TRACE_PROPAGATION_STYLE, Some(vec![TracePropagationStyle::Datadog, TracePropagationStyle::TraceContext])), - trace_propagation_style_extract: ConfigItem::new(S::DD_TRACE_PROPAGATION_STYLE_EXTRACT, None), + trace_partial_flush_min_spans: ConfigItem::new( + S::DD_TRACE_PARTIAL_FLUSH_MIN_SPANS, + 300usize, + ), + trace_propagation_extract_first: ConfigItem::new( + S::DD_TRACE_PROPAGATION_EXTRACT_FIRST, + false, + ), + trace_propagation_style: ConfigItem::new( + S::DD_TRACE_PROPAGATION_STYLE, + Some(vec![ + TracePropagationStyle::Datadog, + TracePropagationStyle::TraceContext, + ]), + ), + trace_propagation_style_extract: ConfigItem::new( + S::DD_TRACE_PROPAGATION_STYLE_EXTRACT, + None, + ), trace_propagation_style_inject: ConfigItem::new(S::DD_TRACE_PROPAGATION_STYLE_INJECT, None), trace_rate_limit: ConfigItem::new(S::DD_TRACE_RATE_LIMIT, 100i32), - trace_sampling_rules: ConfigItemWithOverride::new_rc(S::DD_TRACE_SAMPLING_RULES, ParsedSamplingRules::default()), - trace_stats_computation_enabled: ConfigItem::new(S::DD_TRACE_STATS_COMPUTATION_ENABLED, true), + trace_sampling_rules: ConfigItemWithOverride::new_rc( + S::DD_TRACE_SAMPLING_RULES, + ParsedSamplingRules::default(), + ), + trace_stats_computation_enabled: ConfigItem::new( + S::DD_TRACE_STATS_COMPUTATION_ENABLED, + true, + ), datadog_tags_max_length: ConfigItem::new(S::DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH, 512usize), version: ConfigItem::new(S::DD_VERSION, None), otlp_endpoint: ConfigItem::new(S::OTEL_EXPORTER_OTLP_ENDPOINT, Cow::Borrowed("")), @@ -581,10 +798,19 @@ pub(super) fn default_config() -> Config { otlp_logs_headers: ConfigItem::new(S::OTEL_EXPORTER_OTLP_LOGS_HEADERS, Cow::Borrowed("")), otlp_logs_protocol: ConfigItem::new(S::OTEL_EXPORTER_OTLP_LOGS_PROTOCOL, None), otlp_logs_timeout: ConfigItem::new(S::OTEL_EXPORTER_OTLP_LOGS_TIMEOUT, 10000), - otlp_metrics_endpoint: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, Cow::Borrowed("")), - otlp_metrics_headers: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_HEADERS, Cow::Borrowed("")), + otlp_metrics_endpoint: ConfigItem::new( + S::OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, + Cow::Borrowed(""), + ), + otlp_metrics_headers: ConfigItem::new( + S::OTEL_EXPORTER_OTLP_METRICS_HEADERS, + Cow::Borrowed(""), + ), otlp_metrics_protocol: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_PROTOCOL, None), - otel_metrics_temporality_preference: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, Some(opentelemetry_sdk::metrics::Temporality::Delta)), + otel_metrics_temporality_preference: ConfigItem::new( + S::OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, + Some(opentelemetry_sdk::metrics::Temporality::Delta), + ), otlp_metrics_timeout: ConfigItem::new(S::OTEL_EXPORTER_OTLP_METRICS_TIMEOUT, 10000), otlp_protocol: ConfigItem::new(S::OTEL_EXPORTER_OTLP_PROTOCOL, None), otlp_timeout: ConfigItem::new(S::OTEL_EXPORTER_OTLP_TIMEOUT, 10000), @@ -612,23 +838,50 @@ impl std::fmt::Debug for Config { .field("log_level_filter", &self.log_level_filter) .field("metrics_otel_enabled", &self.metrics_otel_enabled) .field("remote_config_enabled", &self.remote_config_enabled) - .field("remote_config_poll_interval", &self.remote_config_poll_interval) + .field( + "remote_config_poll_interval", + &self.remote_config_poll_interval, + ) .field("service", &self.service) .field("global_tags", &self.global_tags) - .field("telemetry_heartbeat_interval", &self.telemetry_heartbeat_interval) - .field("telemetry_log_collection_enabled", &self.telemetry_log_collection_enabled) + .field( + "telemetry_heartbeat_interval", + &self.telemetry_heartbeat_interval, + ) + .field( + "telemetry_log_collection_enabled", + &self.telemetry_log_collection_enabled, + ) .field("trace_agent_port", &self.trace_agent_port) .field("trace_agent_url", &self.trace_agent_url) .field("enabled", &self.enabled) - .field("trace_partial_flush_enabled", &self.trace_partial_flush_enabled) - .field("trace_partial_flush_min_spans", &self.trace_partial_flush_min_spans) - .field("trace_propagation_extract_first", &self.trace_propagation_extract_first) + .field( + "trace_partial_flush_enabled", + &self.trace_partial_flush_enabled, + ) + .field( + "trace_partial_flush_min_spans", + &self.trace_partial_flush_min_spans, + ) + .field( + "trace_propagation_extract_first", + &self.trace_propagation_extract_first, + ) .field("trace_propagation_style", &self.trace_propagation_style) - .field("trace_propagation_style_extract", &self.trace_propagation_style_extract) - .field("trace_propagation_style_inject", &self.trace_propagation_style_inject) + .field( + "trace_propagation_style_extract", + &self.trace_propagation_style_extract, + ) + .field( + "trace_propagation_style_inject", + &self.trace_propagation_style_inject, + ) .field("trace_rate_limit", &self.trace_rate_limit) .field("trace_sampling_rules", &self.trace_sampling_rules) - .field("trace_stats_computation_enabled", &self.trace_stats_computation_enabled) + .field( + "trace_stats_computation_enabled", + &self.trace_stats_computation_enabled, + ) .field("datadog_tags_max_length", &self.datadog_tags_max_length) .field("version", &self.version) .field("otlp_endpoint", &self.otlp_endpoint) @@ -640,7 +893,10 @@ impl std::fmt::Debug for Config { .field("otlp_metrics_endpoint", &self.otlp_metrics_endpoint) .field("otlp_metrics_headers", &self.otlp_metrics_headers) .field("otlp_metrics_protocol", &self.otlp_metrics_protocol) - .field("otel_metrics_temporality_preference", &self.otel_metrics_temporality_preference) + .field( + "otel_metrics_temporality_preference", + &self.otel_metrics_temporality_preference, + ) .field("otlp_metrics_timeout", &self.otlp_metrics_timeout) .field("otlp_protocol", &self.otlp_protocol) .field("otlp_timeout", &self.otlp_timeout) @@ -649,6 +905,18 @@ impl std::fmt::Debug for Config { .field("metric_export_interval", &self.metric_export_interval) .field("metric_export_timeout", &self.metric_export_timeout) .field("otel_resource_attributes", &self.otel_resource_attributes) + .field( + "trace_writer_synchronous_write", + &self.trace_writer_synchronous_write, + ) + .field( + "trace_writer_synchronous_timeout", + &self.trace_writer_synchronous_timeout, + ) + .field( + "trace_writer_max_flush_interval", + &self.trace_writer_max_flush_interval, + ) .field("extra_services_tracker", &self.extra_services_tracker) .field("remote_config_callbacks", &self.remote_config_callbacks) .finish() diff --git a/scripts/local_config_map_generate.py b/scripts/local_config_map_generate.py index bc322c6b..7d736b09 100644 --- a/scripts/local_config_map_generate.py +++ b/scripts/local_config_map_generate.py @@ -109,11 +109,18 @@ def setter_doc(): if field_name and json_type in ("string", "int", "decimal", "boolean"): if json_type == "string": if not skip_getters: - getter_lines.append( - "{}\n pub fn {}(&self) -> &str {{ self.{}.value().as_ref() }}".format( - getter_doc(), field_name, field_name + if config_item_type in ("override_code", "override_rc"): + getter_lines.append( + "{}\n pub fn {}(&self) -> impl Deref + use<'_> {{ self.{}.value() }}".format( + getter_doc(), field_name, field_name + ) + ) + else: + getter_lines.append( + "{}\n pub fn {}(&self) -> &str {{ self.{}.value().as_ref() }}".format( + getter_doc(), field_name, field_name + ) ) - ) if not skip_setters: setter_lines.append( "{}\n pub fn set_{}(&mut self, val: String) -> &mut Self {{ self.config.{}.set_code(Cow::Owned(val)); self }}".format( @@ -167,7 +174,7 @@ def setter_doc(): if rust_value is not None: if config_item_type == "override_code": default_config_lines.append( - " {}: ConfigItemWithOverride::new_code(S::{}, {}),".format( + " {}: ConfigItemWithOverride::new_calculated(S::{}, {}),".format( field_name, key, rust_value ) ) @@ -264,6 +271,7 @@ def setter_doc(): /// add it to the supported-configurations.json file, then run this script. use std::borrow::Cow; use std::sync::{{Arc, Mutex}}; +use std::time::Duration; use rustc_version_runtime::version; @@ -325,6 +333,9 @@ def setter_doc(): pub(super) language_version: String, pub(super) language: &'static str, {struct_fields_block} + pub(super) trace_writer_synchronous_write: bool, + pub(super) trace_writer_synchronous_timeout: Duration, + pub(super) trace_writer_max_flush_interval: Duration, #[cfg(feature = "test-utils")] pub(super) wait_agent_info_ready: bool, pub(super) extra_services_tracker: ExtraServicesTracker, @@ -354,6 +365,9 @@ def setter_doc(): tracer_version: TRACER_VERSION, language: "rust", language_version: version().to_string(), + trace_writer_synchronous_write: false, + trace_writer_synchronous_timeout: Duration::from_secs(2), + trace_writer_max_flush_interval: Duration::from_secs(1), #[cfg(feature = "test-utils")] wait_agent_info_ready: false, extra_services_tracker: ExtraServicesTracker::new(), @@ -369,6 +383,9 @@ def setter_doc(): .field("tracer_version", &self.tracer_version) .field("language_version", &self.language_version) {debug_block} + .field("trace_writer_synchronous_write", &self.trace_writer_synchronous_write) + .field("trace_writer_synchronous_timeout", &self.trace_writer_synchronous_timeout) + .field("trace_writer_max_flush_interval", &self.trace_writer_max_flush_interval) .field("extra_services_tracker", &self.extra_services_tracker) .field("remote_config_callbacks", &self.remote_config_callbacks) .finish() diff --git a/supported-configurations.json b/supported-configurations.json index 31f10647..cda6568e 100644 --- a/supported-configurations.json +++ b/supported-configurations.json @@ -33,6 +33,7 @@ "default": "http://localhost:8125", "propertyKeys": ["dogstatsd_agent_url"], "skip_default_generation": "all", + "config_item_type": "override_code", "rust_value": "Cow::Borrowed(\"\")" } ], @@ -150,7 +151,9 @@ "version": "A", "type": "string", "default": "", - "propertyKeys": ["trace_agent_url"] + "propertyKeys": ["trace_agent_url"], + "config_item_type": "override_code", + "rust_value": "Cow::Borrowed(\"\")" } ], "DD_TRACE_ENABLED": [ @@ -312,7 +315,7 @@ "type": "string", "default": "SDK-dependent, but will typically be either http/protobuf or grpc.", "propertyKeys": ["otlp_logs_protocol"], - "rust_type": "Option", + "rust_type": "Option", "skip_default_generation": "all", "rust_value": "None" } @@ -350,7 +353,7 @@ "type": "string", "default": null, "propertyKeys": ["otlp_metrics_protocol"], - "rust_type": "Option", + "rust_type": "Option", "skip_default_generation": "all", "rust_value": "None" } @@ -380,7 +383,7 @@ "type": "string", "default": "grpc", "propertyKeys": ["otlp_protocol"], - "rust_type": "Option", + "rust_type": "Option", "skip_default_generation": "all", "rust_value": "None" }