diff --git a/components-rs/Cargo.toml b/components-rs/Cargo.toml index c4b8de1c34..dfcc3aee29 100644 --- a/components-rs/Cargo.toml +++ b/components-rs/Cargo.toml @@ -23,6 +23,7 @@ libdd-data-pipeline = { path = "../libdatadog/libdd-data-pipeline" } libdd-tinybytes = { path = "../libdatadog/libdd-tinybytes" } libdd-trace-utils = { path = "../libdatadog/libdd-trace-utils" } libdd-trace-stats = { path = "../libdatadog/libdd-trace-stats" } +libdd-trace-protobuf = { path = "../libdatadog/libdd-trace-protobuf" } libdd-crashtracker-ffi = { path = "../libdatadog/libdd-crashtracker-ffi", default-features = false, features = ["collector"] } libdd-library-config-ffi = { path = "../libdatadog/libdd-library-config-ffi", default-features = false } spawn_worker = { path = "../libdatadog/spawn_worker" } diff --git a/components-rs/remote_config.rs b/components-rs/remote_config.rs index 5b08de64a8..1138cf707f 100644 --- a/components-rs/remote_config.rs +++ b/components-rs/remote_config.rs @@ -92,6 +92,10 @@ pub struct RemoteConfigState { manager: RemoteConfigManager, live_debugger: LiveDebuggerState, dynamic_config: DynamicConfig, + // Service name of the currently tracked target. libdd-remote-config's `Target` no longer + // exposes its inner fields (they were hidden in libdatadog #2182), so we keep our own copy of + // the service — set whenever we track a target — for building debugger diagnostics payloads. + current_service: String, } #[repr(C)] @@ -223,6 +227,7 @@ pub unsafe extern "C" fn ddog_init_remote_config_state( ..Default::default() }, dynamic_config: Default::default(), + current_service: String::new(), }) } @@ -639,13 +644,17 @@ pub extern "C" fn ddog_remote_configs_service_env_change( tags: &libdd_common_ffi::Vec, process_tags: &libdd_common_ffi::Vec, ) -> bool { - let new_target = Target { - service: service.to_utf8_lossy().to_string(), - env: env.to_utf8_lossy().to_string(), - app_version: version.to_utf8_lossy().to_string(), - tags: tags.as_slice().to_vec(), - process_tags: process_tags.as_slice().to_vec(), - }; + let service = service.to_utf8_lossy().to_string(); + // `Target`'s fields are private since libdatadog #2182; construct via the public constructor. + // `tags`/`process_tags` are now `Vec` of already-formatted `"key:value"` entries, so + // render each `Tag` (whose `Display`/`to_string` yields `"key:value"`) to a String. + let new_target = Target::new( + service.clone(), + env.to_utf8_lossy().to_string(), + version.to_utf8_lossy().to_string(), + tags.as_slice().iter().map(|t| t.to_string()).collect(), + process_tags.as_slice().iter().map(|t| t.to_string()).collect(), + ); if let Some(target) = remote_config.manager.get_target() { if **target == new_target { @@ -653,6 +662,8 @@ pub extern "C" fn ddog_remote_configs_service_env_change( } } + // Keep our own copy of the service name; `Target` no longer exposes it. + remote_config.current_service = service; remote_config.manager.track_target(&Arc::new(new_target)); // Caller must call ddog_process_remote_configs if true. // We don't call it here to allow the caller delaying the call as necessary. @@ -777,12 +788,13 @@ pub unsafe extern "C" fn ddog_send_debugger_diagnostics<'a>( probe: &'a Probe, timestamp: u64, ) -> MaybeError { - let service = Cow::Borrowed( - remote_config_state - .manager - .get_target() - .map_or("", |t| t.service.as_str()), - ); + // `Target` no longer exposes its service field (libdatadog #2182); use the copy we tracked + // when the target was set. Fall back to empty when no target is currently tracked. + let service = Cow::Borrowed(if remote_config_state.manager.get_target().is_some() { + remote_config_state.current_service.as_str() + } else { + "" + }); let mut payload = ddog_debugger_diagnostics_create_unboxed( probe, service, diff --git a/components-rs/stats.rs b/components-rs/stats.rs index e2e831c48e..43083a275c 100644 --- a/components-rs/stats.rs +++ b/components-rs/stats.rs @@ -10,6 +10,7 @@ use crate::trace_filter; use datadog_ipc::shm_stats::{OwnedShmSpanInput, ShmSpanConcentrator, ShmSpanInput, MAX_PEER_TAGS}; use datadog_sidecar::service::blocking::{add_span_to_concentrator, SidecarTransport}; +use libdd_trace_protobuf::pb; use libdd_trace_stats::span_concentrator::FixedAggregationKey; use libdd_common_ffi::slice::{AsBytes, CharSlice}; use std::collections::HashMap; @@ -148,7 +149,13 @@ fn build_fixed_key<'a>(span: &'a PhpSpanStats<'a>) -> FixedAggregationKey<&'a st http_endpoint: extract_http_endpoint(span), http_status_code: extract_http_status_code(span), is_synthetics_request: is_synthetics_request(span), - is_trace_root: span.is_trace_root, + // `is_trace_root` became a `Trilean` in libdatadog #2180; map our bool onto it. The PHP + // side always knows whether a span is a trace root, so we never emit `NotSet`. + is_trace_root: if span.is_trace_root { + pb::Trilean::True + } else { + pb::Trilean::False + }, grpc_status_code: extract_grpc_status_code(span), service_source: char_slice_str(span.service_source), } diff --git a/libdatadog b/libdatadog index 6a6d4a535e..d7b2aad37e 160000 --- a/libdatadog +++ b/libdatadog @@ -1 +1 @@ -Subproject commit 6a6d4a535e9875a7b012ce3f00eb6929649c3fb5 +Subproject commit d7b2aad37e2c45e44ba54473c9dd5ef5e3c94669