From 033dda6f94b9513268a50f23a6698bc556699f8d Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Wed, 25 Feb 2026 13:58:12 -0500 Subject: [PATCH 01/10] feat(trace-protobuf): Add two fields to ClientGroupedStats --- libdd-trace-protobuf/src/pb/stats.proto | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libdd-trace-protobuf/src/pb/stats.proto b/libdd-trace-protobuf/src/pb/stats.proto index f86d727a26..a46355c1f1 100644 --- a/libdd-trace-protobuf/src/pb/stats.proto +++ b/libdd-trace-protobuf/src/pb/stats.proto @@ -4,6 +4,8 @@ package pb; option go_package = "pkg/proto/pbgo/trace"; // golang +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; + // protoc --gogofaster_out=. -I $GOPATH/src -I . stats.proto // StatsPayload is the payload used to send stats from the agent to the backend. @@ -103,4 +105,8 @@ message ClientGroupedStats { string GRPC_status_code = 18; string HTTP_method = 19; // HTTP method of the request string HTTP_endpoint = 20; // Http route or quantized/simplified URL path + string service_source = 21 [(gogoproto.moretags) = "msg:\"srv_src\""]; // used to identify service override origin + // span_derived_primary_tags are primary tags that are derived from span tags + // These tags must be validated against configured primary tags for the org + repeated string span_derived_primary_tags = 22; } From fb53fc887901b945f2cf0f0f13e25f6f0effde3d Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Wed, 25 Feb 2026 14:45:13 -0500 Subject: [PATCH 02/10] Update Rust structs and test --- libdd-trace-protobuf/build.rs | 5 +++++ libdd-trace-protobuf/src/pb.rs | 11 +++++++++++ libdd-trace-protobuf/src/pb_test.rs | 2 ++ 3 files changed, 18 insertions(+) diff --git a/libdd-trace-protobuf/build.rs b/libdd-trace-protobuf/build.rs index dcecdad2f8..6f5a4c1a0e 100644 --- a/libdd-trace-protobuf/build.rs +++ b/libdd-trace-protobuf/build.rs @@ -176,6 +176,11 @@ fn generate_protobuf() { "ClientGroupedStats.HTTP_endpoint", "#[serde(default)] #[serde(rename = \"HTTPEndpoint\")]", ); + config.field_attribute("ClientGroupedStats.service_source", "#[serde(default)]"); + config.field_attribute( + "ClientGroupedStats.span_derived_primary_tags", + "#[serde(default)]", + ); config.field_attribute( "ClientGroupedStats.okSummary", diff --git a/libdd-trace-protobuf/src/pb.rs b/libdd-trace-protobuf/src/pb.rs index 50167c9da1..54c40449a9 100644 --- a/libdd-trace-protobuf/src/pb.rs +++ b/libdd-trace-protobuf/src/pb.rs @@ -646,6 +646,17 @@ pub struct ClientGroupedStats { #[serde(default)] #[serde(rename = "HTTPEndpoint")] pub http_endpoint: ::prost::alloc::string::String, + /// used to identify service override origin + #[prost(string, tag = "21")] + #[serde(default)] + pub service_source: ::prost::alloc::string::String, + /// span_derived_primary_tags are primary tags that are derived from span tags + /// These tags must be validated against configured primary tags for the org + #[prost(string, repeated, tag = "22")] + #[serde(default)] + pub span_derived_primary_tags: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, } /// Trilean is an expanded boolean type that is meant to differentiate between being unset and false. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] diff --git a/libdd-trace-protobuf/src/pb_test.rs b/libdd-trace-protobuf/src/pb_test.rs index 09e1df8bc0..4d0672c4a5 100644 --- a/libdd-trace-protobuf/src/pb_test.rs +++ b/libdd-trace-protobuf/src/pb_test.rs @@ -112,6 +112,8 @@ mod tests { grpc_status_code: "0".to_string(), http_endpoint: "/test".to_string(), http_method: "GET".to_string(), + service_source: "".to_string(), + span_derived_primary_tags: vec![], }], agent_time_shift: 0, }], From 2e6371a3183738abe9bbb9fc63d0544895868d8c Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Wed, 25 Feb 2026 14:58:53 -0500 Subject: [PATCH 03/10] fix(trace-protobuf): Sync stats.proto with datadog-agent and update pb.rs - Align stats.proto with datadog-agent (use @inject_tag comment instead of gogoproto annotation, remove gogo.proto import, update field comments) - Update DATADOG_AGENT_TAG to bdcdd8cf1ba4090a29b96d5669cfab5dd81814b1 - Regenerate pb.rs with service_source and span_derived_primary_tags fields - Add serde(default) attributes for new fields in build.rs - Fix pb_test.rs to include new fields in ClientGroupedStats initializer Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/verify-proto-files.yml | 2 +- libdd-trace-protobuf/src/pb.rs | 7 ++++--- libdd-trace-protobuf/src/pb/stats.proto | 9 ++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/verify-proto-files.yml b/.github/workflows/verify-proto-files.yml index 0e7b570bdc..6a9a00b525 100644 --- a/.github/workflows/verify-proto-files.yml +++ b/.github/workflows/verify-proto-files.yml @@ -3,7 +3,7 @@ on: pull_request: types: [ opened, synchronize, reopened ] env: - DATADOG_AGENT_TAG: "7f6d07c93ba087f23f80a3f0c2da4b1f3dc664d7" + DATADOG_AGENT_TAG: "bdcdd8cf1ba4090a29b96d5669cfab5dd81814b1" rust_version: "1.84.1" CARGO_TERM_COLOR: always CARGO_INCREMENTAL: 0 diff --git a/libdd-trace-protobuf/src/pb.rs b/libdd-trace-protobuf/src/pb.rs index 54c40449a9..c242c1b131 100644 --- a/libdd-trace-protobuf/src/pb.rs +++ b/libdd-trace-protobuf/src/pb.rs @@ -646,12 +646,13 @@ pub struct ClientGroupedStats { #[serde(default)] #[serde(rename = "HTTPEndpoint")] pub http_endpoint: ::prost::alloc::string::String, - /// used to identify service override origin + /// @inject_tag: msg:"srv_src" #[prost(string, tag = "21")] #[serde(default)] pub service_source: ::prost::alloc::string::String, - /// span_derived_primary_tags are primary tags that are derived from span tags - /// These tags must be validated against configured primary tags for the org + /// used to identify service override origin + /// span_derived_primary_tags are user-configured tags that are extracted from spans and used for stats aggregation + /// E.g., `aws.s3.bucket`, `http.url`, or any custom tag #[prost(string, repeated, tag = "22")] #[serde(default)] pub span_derived_primary_tags: ::prost::alloc::vec::Vec< diff --git a/libdd-trace-protobuf/src/pb/stats.proto b/libdd-trace-protobuf/src/pb/stats.proto index a46355c1f1..e5b5a24fca 100644 --- a/libdd-trace-protobuf/src/pb/stats.proto +++ b/libdd-trace-protobuf/src/pb/stats.proto @@ -4,8 +4,6 @@ package pb; option go_package = "pkg/proto/pbgo/trace"; // golang -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - // protoc --gogofaster_out=. -I $GOPATH/src -I . stats.proto // StatsPayload is the payload used to send stats from the agent to the backend. @@ -105,8 +103,9 @@ message ClientGroupedStats { string GRPC_status_code = 18; string HTTP_method = 19; // HTTP method of the request string HTTP_endpoint = 20; // Http route or quantized/simplified URL path - string service_source = 21 [(gogoproto.moretags) = "msg:\"srv_src\""]; // used to identify service override origin - // span_derived_primary_tags are primary tags that are derived from span tags - // These tags must be validated against configured primary tags for the org + string service_source = 21; // @inject_tag: msg:"srv_src" + // used to identify service override origin + // span_derived_primary_tags are user-configured tags that are extracted from spans and used for stats aggregation + // E.g., `aws.s3.bucket`, `http.url`, or any custom tag repeated string span_derived_primary_tags = 22; } From e91e30fe5f997c99dff9fab019c98c3511d297ab Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Wed, 25 Feb 2026 16:39:28 -0500 Subject: [PATCH 04/10] fix(trace-stats): Add new ClientGroupedStats fields in encode_grouped_stats Add service_source and span_derived_primary_tags to the ClientGroupedStats initializer in aggregation.rs following the addition of these fields to the protobuf definition. Co-Authored-By: Claude Sonnet 4.6 --- libdd-trace-stats/src/span_concentrator/aggregation.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdd-trace-stats/src/span_concentrator/aggregation.rs b/libdd-trace-stats/src/span_concentrator/aggregation.rs index 3ef068cd5f..3e141bfd1b 100644 --- a/libdd-trace-stats/src/span_concentrator/aggregation.rs +++ b/libdd-trace-stats/src/span_concentrator/aggregation.rs @@ -296,6 +296,8 @@ fn encode_grouped_stats(key: OwnedAggregationKey, group: GroupedStats) -> pb::Cl http_method: key.http_method, http_endpoint: key.http_endpoint, grpc_status_code: String::new(), // currently not used + service_source: String::new(), // set by the agent, not the tracer + span_derived_primary_tags: vec![], } } From 8e17676b5275d431ddd2eaa29fdaf97be8e53ed4 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Wed, 25 Feb 2026 16:59:31 -0500 Subject: [PATCH 05/10] fix(bin-tests): Fix function-casts-as-integer clippy lint Add intermediate *const () pointer cast before usize cast for signal handler function pointers, as required by the function_casts_as_integer clippy lint. Co-Authored-By: Claude Sonnet 4.6 --- bin_tests/src/modes/unix/test_001_sigpipe.rs | 2 +- bin_tests/src/modes/unix/test_002_sigchld.rs | 2 +- bin_tests/src/modes/unix/test_003_sigchld_with_exec.rs | 2 +- bin_tests/src/modes/unix/test_005_sigpipe_sigstack.rs | 2 +- bin_tests/src/modes/unix/test_006_sigchld_sigstack.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin_tests/src/modes/unix/test_001_sigpipe.rs b/bin_tests/src/modes/unix/test_001_sigpipe.rs index 387c99ec10..4c08bf3617 100644 --- a/bin_tests/src/modes/unix/test_001_sigpipe.rs +++ b/bin_tests/src/modes/unix/test_001_sigpipe.rs @@ -106,7 +106,7 @@ pub fn setup(output_dir: &Path) -> anyhow::Result<()> { // Set up the sigaction struct with sa_sigaction and sa_flags let sigpipe_action = libc::sigaction { - sa_sigaction: sigpipe_handler as usize, + sa_sigaction: sigpipe_handler as *const () as usize, sa_mask: sigset, sa_flags: libc::SA_RESTART | libc::SA_SIGINFO, #[cfg(target_os = "linux")] diff --git a/bin_tests/src/modes/unix/test_002_sigchld.rs b/bin_tests/src/modes/unix/test_002_sigchld.rs index 86d9e73252..e257f335ab 100644 --- a/bin_tests/src/modes/unix/test_002_sigchld.rs +++ b/bin_tests/src/modes/unix/test_002_sigchld.rs @@ -124,7 +124,7 @@ pub fn setup(output_dir: &Path) -> anyhow::Result<()> { // Set up the sigaction struct with sa_sigaction and sa_flags let sigchld_action = libc::sigaction { - sa_sigaction: sigchld_handler as usize, + sa_sigaction: sigchld_handler as *const () as usize, sa_mask: sigset, sa_flags: libc::SA_RESTART | libc::SA_SIGINFO, #[cfg(target_os = "linux")] diff --git a/bin_tests/src/modes/unix/test_003_sigchld_with_exec.rs b/bin_tests/src/modes/unix/test_003_sigchld_with_exec.rs index 5e5eb6f985..c20e82d185 100644 --- a/bin_tests/src/modes/unix/test_003_sigchld_with_exec.rs +++ b/bin_tests/src/modes/unix/test_003_sigchld_with_exec.rs @@ -102,7 +102,7 @@ pub fn setup(output_dir: &Path) -> anyhow::Result<()> { // Set up the sigaction struct with sa_sigaction and sa_flags let sigchld_action = libc::sigaction { - sa_sigaction: sigchld_handler as usize, + sa_sigaction: sigchld_handler as *const () as usize, sa_mask: sigset, sa_flags: libc::SA_RESTART | libc::SA_SIGINFO, #[cfg(target_os = "linux")] diff --git a/bin_tests/src/modes/unix/test_005_sigpipe_sigstack.rs b/bin_tests/src/modes/unix/test_005_sigpipe_sigstack.rs index 583aa0afb6..cbe69f3aa2 100644 --- a/bin_tests/src/modes/unix/test_005_sigpipe_sigstack.rs +++ b/bin_tests/src/modes/unix/test_005_sigpipe_sigstack.rs @@ -97,7 +97,7 @@ pub fn setup(output_dir: &Path) -> anyhow::Result<()> { // Set up the sigaction struct with sa_sigaction and sa_flags let sigpipe_action = libc::sigaction { - sa_sigaction: sigpipe_handler as usize, + sa_sigaction: sigpipe_handler as *const () as usize, sa_mask: sigset, sa_flags: libc::SA_RESTART | libc::SA_SIGINFO, #[cfg(target_os = "linux")] diff --git a/bin_tests/src/modes/unix/test_006_sigchld_sigstack.rs b/bin_tests/src/modes/unix/test_006_sigchld_sigstack.rs index de6810bda4..53cc086d05 100644 --- a/bin_tests/src/modes/unix/test_006_sigchld_sigstack.rs +++ b/bin_tests/src/modes/unix/test_006_sigchld_sigstack.rs @@ -117,7 +117,7 @@ pub fn setup(output_dir: &Path) -> anyhow::Result<()> { // Set up the sigaction struct with sa_sigaction and sa_flags let sigchld_action = libc::sigaction { - sa_sigaction: sigchld_handler as usize, + sa_sigaction: sigchld_handler as *const () as usize, sa_mask: sigset, sa_flags: libc::SA_RESTART | libc::SA_SIGINFO, #[cfg(not(target_os = "macos"))] From 8282e1ccb2888de4c4688700e861b9a3ca93239d Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Wed, 25 Feb 2026 17:24:26 -0500 Subject: [PATCH 06/10] fix(sidecar): Fix unnecessary_unwrap clippy lint in appsec_config handling Replace is_some() + unwrap() pattern with idiomatic if let Some(...) in config.rs and entry.rs. Co-Authored-By: Claude Sonnet 4.6 --- datadog-sidecar/src/config.rs | 5 ++--- datadog-sidecar/src/entry.rs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/datadog-sidecar/src/config.rs b/datadog-sidecar/src/config.rs index 4009e3a1ad..810cbd78ed 100644 --- a/datadog-sidecar/src/config.rs +++ b/datadog-sidecar/src/config.rs @@ -118,9 +118,8 @@ impl Config { if let Ok(json) = serde_json::to_string(&self.crashtracker_endpoint) { res.insert(ENV_SIDECAR_CRASHTRACKER_ENDPOINT, json.into()); } - if self.appsec_config.is_some() { - #[allow(clippy::unwrap_used)] - res.extend(self.appsec_config.as_ref().unwrap().to_env()); + if let Some(appsec_config) = &self.appsec_config { + res.extend(appsec_config.to_env()); } if self.max_memory != 0 { res.insert( diff --git a/datadog-sidecar/src/entry.rs b/datadog-sidecar/src/entry.rs index d0a0fad4fc..252ee4fa64 100644 --- a/datadog-sidecar/src/entry.rs +++ b/datadog-sidecar/src/entry.rs @@ -200,10 +200,9 @@ pub fn daemonize(listener: IpcServer, mut cfg: Config) -> anyhow::Result<()> { setup_daemon_process(listener, &mut spawn_cfg)?; let mut lib_deps = cfg.library_dependencies; - if cfg.appsec_config.is_some() { - #[allow(clippy::unwrap_used)] + if let Some(appsec_config) = cfg.appsec_config { lib_deps.push(spawn_worker::LibDependency::Path( - cfg.appsec_config.unwrap().shared_lib_path.into(), + appsec_config.shared_lib_path.into(), )); } From b0aaac7ca6c46cdf94d71a8e2723219920048a80 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Wed, 25 Feb 2026 17:26:53 -0500 Subject: [PATCH 07/10] fix(trace-utils): Add new ClientGroupedStats fields in stats_utils test Co-Authored-By: Claude Sonnet 4.6 --- libdd-trace-utils/src/stats_utils.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdd-trace-utils/src/stats_utils.rs b/libdd-trace-utils/src/stats_utils.rs index 405077d52b..d0feb1541d 100644 --- a/libdd-trace-utils/src/stats_utils.rs +++ b/libdd-trace-utils/src/stats_utils.rs @@ -200,6 +200,8 @@ mod mini_agent_tests { grpc_status_code: "0".to_string(), http_endpoint: "/test".to_string(), http_method: "GET".to_string(), + service_source: "".to_string(), + span_derived_primary_tags: vec![], }], agent_time_shift: 0, }], From c2fe7cbd78165c7b2525b497a8474fb815328596 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Wed, 25 Feb 2026 18:01:21 -0500 Subject: [PATCH 08/10] fix(bin-tests): Fix remaining function-casts-as-integer lint in behavior.rs Co-Authored-By: Claude Sonnet 4.6 --- bin_tests/src/modes/behavior.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin_tests/src/modes/behavior.rs b/bin_tests/src/modes/behavior.rs index ce66270643..14d7c74fce 100644 --- a/bin_tests/src/modes/behavior.rs +++ b/bin_tests/src/modes/behavior.rs @@ -164,7 +164,7 @@ mod tests { } let sigpipe_action = libc::sigaction { - sa_sigaction: sigpipe_handler as usize, + sa_sigaction: sigpipe_handler as *const () as usize, sa_mask: sigset, sa_flags: libc::SA_RESTART | libc::SA_SIGINFO, #[cfg(target_os = "linux")] From 379704b3e399fc31023d5d3d6ea6de284cfe58da Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Mon, 2 Mar 2026 13:54:31 -0500 Subject: [PATCH 09/10] Update comment --- libdd-trace-stats/src/span_concentrator/aggregation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdd-trace-stats/src/span_concentrator/aggregation.rs b/libdd-trace-stats/src/span_concentrator/aggregation.rs index 209f11359a..ce44453c4a 100644 --- a/libdd-trace-stats/src/span_concentrator/aggregation.rs +++ b/libdd-trace-stats/src/span_concentrator/aggregation.rs @@ -296,8 +296,8 @@ fn encode_grouped_stats(key: OwnedAggregationKey, group: GroupedStats) -> pb::Cl http_method: key.http_method, http_endpoint: key.http_endpoint, grpc_status_code: String::new(), // currently not used - service_source: String::new(), // set by the agent, not the tracer - span_derived_primary_tags: vec![], + service_source: String::new(), // set by the agent + span_derived_primary_tags: vec![], // set by the agent } } From 3ea58af51badd49822cbb28e6fda992fa21f67b1 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Mon, 2 Mar 2026 14:01:11 -0500 Subject: [PATCH 10/10] fmt --- libdd-trace-stats/src/span_concentrator/aggregation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdd-trace-stats/src/span_concentrator/aggregation.rs b/libdd-trace-stats/src/span_concentrator/aggregation.rs index ce44453c4a..26171fbb14 100644 --- a/libdd-trace-stats/src/span_concentrator/aggregation.rs +++ b/libdd-trace-stats/src/span_concentrator/aggregation.rs @@ -295,8 +295,8 @@ fn encode_grouped_stats(key: OwnedAggregationKey, group: GroupedStats) -> pb::Cl }, http_method: key.http_method, http_endpoint: key.http_endpoint, - grpc_status_code: String::new(), // currently not used - service_source: String::new(), // set by the agent + grpc_status_code: String::new(), // currently not used + service_source: String::new(), // set by the agent span_derived_primary_tags: vec![], // set by the agent } }