From 05ca5f80e69787d6c1c0aa8f7f4be97408419353 Mon Sep 17 00:00:00 2001 From: shreyamalpani Date: Mon, 17 Nov 2025 09:42:52 -0500 Subject: [PATCH 1/7] [SVLS-8002] fix: collect CPU metric offsets on PlatformStart (#930) ## Overview Collect CPU metric offsets on receiving the PlatformStart instead of the Invoke event to avoid accounting for additional idle time while calculating utilization. Also, guard uptime and idle time to be non-negative for edge-cases. Maintains collecting network offsets on the Invoke event to match with Lambda Insights. ## Testing Tested with self-monitoring image --- .../src/lifecycle/invocation/processor.rs | 25 ++++++++++++++----- bottlecap/src/metrics/enhanced/lambda.rs | 14 ++++++++--- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/bottlecap/src/lifecycle/invocation/processor.rs b/bottlecap/src/lifecycle/invocation/processor.rs index c9784f99e..1dfcb7fb3 100644 --- a/bottlecap/src/lifecycle/invocation/processor.rs +++ b/bottlecap/src/lifecycle/invocation/processor.rs @@ -141,15 +141,11 @@ impl Processor { // Resume tmp, fd, and threads enhanced metrics monitoring self.enhanced_metrics.resume_usage_metrics_monitoring(); - // Collect offsets for network and cpu metrics let network_offset: Option = proc::get_network_data().ok(); - let cpu_offset: Option = proc::get_cpu_data().ok(); - let uptime_offset: Option = proc::get_uptime().ok(); - let enhanced_metric_offsets = Some(EnhancedMetricData { network_offset, - cpu_offset, - uptime_offset, + cpu_offset: None, + uptime_offset: None, }); self.context_buffer .add_enhanced_metric_data(&request_id, enhanced_metric_offsets); @@ -319,6 +315,23 @@ impl Processor { .try_into() .unwrap_or_default(); self.context_buffer.add_start_time(&request_id, start_time); + + if self.config.lambda_proc_enhanced_metrics { + let cpu_offset: Option = proc::get_cpu_data().ok(); + let uptime_offset: Option = proc::get_uptime().ok(); + if let Some(context) = self.context_buffer.get_mut(&request_id) { + if let Some(ref mut enhanced_data) = context.enhanced_metric_data { + enhanced_data.cpu_offset = cpu_offset; + enhanced_data.uptime_offset = uptime_offset; + } else { + context.enhanced_metric_data = Some(EnhancedMetricData { + network_offset: None, + cpu_offset, + uptime_offset, + }); + } + } + } } #[allow(clippy::too_many_arguments)] diff --git a/bottlecap/src/metrics/enhanced/lambda.rs b/bottlecap/src/metrics/enhanced/lambda.rs index b2066c821..740d44599 100644 --- a/bottlecap/src/metrics/enhanced/lambda.rs +++ b/bottlecap/src/metrics/enhanced/lambda.rs @@ -370,6 +370,12 @@ impl Lambda { let uptime = uptime_data_end - uptime_data_offset; let total_idle_time = cpu_data_end.total_idle_time_ms - cpu_data_offset.total_idle_time_ms; + // Change in uptime should be positive and greater than total idle time across all cores + if uptime <= 0.0 || (uptime * num_cores) < total_idle_time { + debug!("Invalid uptime, skipping CPU utilization metrics"); + return; + } + let mut max_idle_time = 0.0; let mut min_idle_time = f64::MAX; let now = std::time::UNIX_EPOCH @@ -383,6 +389,8 @@ impl Lambda { cpu_data_offset.individual_cpu_idle_times.get(cpu_name) { let idle_time = cpu_idle_time - cpu_idle_time_offset; + let idle_time = idle_time.max(0.0); // Ensure idle time is non-negative + if idle_time < min_idle_time { min_idle_time = idle_time; } @@ -394,15 +402,15 @@ impl Lambda { // Maximally utilized CPU is the one with the least time spent in the idle process // Multiply by 100 to report as percentage - let cpu_max_utilization = ((uptime - min_idle_time) / uptime) * 100.0; + let cpu_max_utilization = ((uptime - min_idle_time).max(0.0) / uptime) * 100.0; // Minimally utilized CPU is the one with the most time spent in the idle process // Multiply by 100 to report as percentage - let cpu_min_utilization = ((uptime - max_idle_time) / uptime) * 100.0; + let cpu_min_utilization = ((uptime - max_idle_time).max(0.0) / uptime) * 100.0; // CPU total utilization is the proportion of total non-idle time to the total uptime across all cores let cpu_total_utilization_decimal = - ((uptime * num_cores) - total_idle_time) / (uptime * num_cores); + ((uptime * num_cores) - total_idle_time).max(0.0) / (uptime * num_cores); // Multiply by 100 to report as percentage let cpu_total_utilization_pct = cpu_total_utilization_decimal * 100.0; // Multiply by num_cores to report in terms of cores From 9759172a7cbc797614f43bbbfc77cf9963f140b8 Mon Sep 17 00:00:00 2001 From: Tianning Li Date: Mon, 17 Nov 2025 11:25:24 -0500 Subject: [PATCH 2/7] (feat) Add URL to proxy flusher error logs (#933) https://datadoghq.atlassian.net/browse/SVLS-8005 ## Overview Proxy flush doesn't log the URL in case of error. Need to add it to better investigate the issue. ## Testing n/a --- bottlecap/src/traces/proxy_flusher.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bottlecap/src/traces/proxy_flusher.rs b/bottlecap/src/traces/proxy_flusher.rs index 8d3828faf..a0de1d357 100644 --- a/bottlecap/src/traces/proxy_flusher.rs +++ b/bottlecap/src/traces/proxy_flusher.rs @@ -165,7 +165,9 @@ impl Flusher { elapsed.as_millis() ); } else { - error!("PROXY_FLUSHER | Request failed with status {status}: {body:?}"); + error!( + "PROXY_FLUSHER | Request failed with status {status} to {url}: {body:?}" + ); } return Ok(()); From 3928795a55a45e317504e4e30f352fa275cfc0c8 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Thu, 6 Nov 2025 21:03:03 -0500 Subject: [PATCH 3/7] chore: Upgrade libdatadog and construct http client for traces --- bottlecap/Cargo.lock | 258 +++++++++--------- bottlecap/Cargo.toml | 22 +- bottlecap/src/appsec/processor/context.rs | 4 +- bottlecap/src/appsec/processor/mod.rs | 2 +- bottlecap/src/bin/bottlecap/main.rs | 2 +- bottlecap/src/config/mod.rs | 2 +- bottlecap/src/lifecycle/invocation/context.rs | 2 +- bottlecap/src/lifecycle/invocation/mod.rs | 2 +- .../src/lifecycle/invocation/processor.rs | 4 +- .../lifecycle/invocation/processor_service.rs | 2 +- .../src/lifecycle/invocation/span_inferrer.rs | 2 +- .../invocation/triggers/alb_event.rs | 2 +- .../triggers/api_gateway_http_event.rs | 2 +- .../triggers/api_gateway_rest_event.rs | 2 +- .../triggers/api_gateway_websocket_event.rs | 2 +- .../invocation/triggers/dynamodb_event.rs | 2 +- .../invocation/triggers/event_bridge_event.rs | 2 +- .../invocation/triggers/kinesis_event.rs | 2 +- .../triggers/lambda_function_url_event.rs | 2 +- .../src/lifecycle/invocation/triggers/mod.rs | 2 +- .../invocation/triggers/msk_event.rs | 2 +- .../lifecycle/invocation/triggers/s3_event.rs | 2 +- .../invocation/triggers/sns_event.rs | 4 +- .../invocation/triggers/sqs_event.rs | 2 +- .../triggers/step_function_event.rs | 2 +- bottlecap/src/otlp/agent.rs | 2 +- bottlecap/src/otlp/processor.rs | 2 +- bottlecap/src/otlp/transform.rs | 8 +- bottlecap/src/traces/context.rs | 2 +- bottlecap/src/traces/propagation/mod.rs | 2 +- bottlecap/src/traces/span_pointers.rs | 2 +- bottlecap/src/traces/stats_aggregator.rs | 2 +- .../src/traces/stats_concentrator_service.rs | 6 +- bottlecap/src/traces/stats_flusher.rs | 6 +- bottlecap/src/traces/stats_generator.rs | 2 +- bottlecap/src/traces/stats_processor.rs | 6 +- bottlecap/src/traces/trace_agent.rs | 6 +- bottlecap/src/traces/trace_aggregator.rs | 6 +- .../src/traces/trace_aggregator_service.rs | 6 +- bottlecap/src/traces/trace_flusher.rs | 32 ++- bottlecap/src/traces/trace_processor.rs | 16 +- bottlecap/tests/appsec_processor_test.rs | 2 +- 42 files changed, 239 insertions(+), 201 deletions(-) diff --git a/bottlecap/Cargo.lock b/bottlecap/Cargo.lock index 4bd008bdb..97b3ec01f 100644 --- a/bottlecap/Cargo.lock +++ b/bottlecap/Cargo.lock @@ -521,12 +521,7 @@ dependencies = [ "cookie", "datadog-fips", "datadog-protos", - "datadog-trace-normalization", "datadog-trace-obfuscation", - "datadog-trace-protobuf", - "datadog-trace-stats", - "datadog-trace-utils", - "ddcommon", "ddsketch-agent", "dogstatsd", "figment", @@ -538,9 +533,16 @@ dependencies = [ "http-body-util", "httpmock", "hyper 1.6.0", + "hyper-http-proxy", "hyper-util", + "indexmap 2.12.0", "itertools 0.14.0", "lazy_static", + "libdd-common", + "libdd-trace-normalization", + "libdd-trace-protobuf", + "libdd-trace-stats", + "libdd-trace-utils", "libddwaf", "log", "mime", @@ -767,14 +769,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "datadog-ddsketch" -version = "22.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=ba8955394cf35cf24a1a508fbe6264ad84702567#ba8955394cf35cf24a1a508fbe6264ad84702567" -dependencies = [ - "prost", -] - [[package]] name = "datadog-fips" version = "0.1.0" @@ -799,24 +793,15 @@ dependencies = [ "tonic-build", ] -[[package]] -name = "datadog-trace-normalization" -version = "22.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=ba8955394cf35cf24a1a508fbe6264ad84702567#ba8955394cf35cf24a1a508fbe6264ad84702567" -dependencies = [ - "anyhow", - "datadog-trace-protobuf", -] - [[package]] name = "datadog-trace-obfuscation" -version = "22.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=ba8955394cf35cf24a1a508fbe6264ad84702567#ba8955394cf35cf24a1a508fbe6264ad84702567" +version = "24.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" dependencies = [ "anyhow", - "datadog-trace-protobuf", - "datadog-trace-utils", - "ddcommon", + "libdd-common", + "libdd-trace-protobuf", + "libdd-trace-utils", "log", "percent-encoding", "regex", @@ -825,88 +810,6 @@ dependencies = [ "url", ] -[[package]] -name = "datadog-trace-protobuf" -version = "22.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=ba8955394cf35cf24a1a508fbe6264ad84702567#ba8955394cf35cf24a1a508fbe6264ad84702567" -dependencies = [ - "prost", - "serde", - "serde_bytes", -] - -[[package]] -name = "datadog-trace-stats" -version = "22.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=ba8955394cf35cf24a1a508fbe6264ad84702567#ba8955394cf35cf24a1a508fbe6264ad84702567" -dependencies = [ - "datadog-ddsketch", - "datadog-trace-protobuf", - "datadog-trace-utils", - "hashbrown 0.15.4", -] - -[[package]] -name = "datadog-trace-utils" -version = "22.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=ba8955394cf35cf24a1a508fbe6264ad84702567#ba8955394cf35cf24a1a508fbe6264ad84702567" -dependencies = [ - "anyhow", - "bytes", - "datadog-trace-normalization", - "datadog-trace-protobuf", - "ddcommon", - "flate2", - "futures", - "http-body-util", - "hyper 1.6.0", - "hyper-http-proxy", - "prost", - "rand 0.8.5", - "rmp", - "rmp-serde", - "rmpv", - "serde", - "serde_json", - "tinybytes", - "tokio", - "tracing", - "zstd", -] - -[[package]] -name = "ddcommon" -version = "22.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=ba8955394cf35cf24a1a508fbe6264ad84702567#ba8955394cf35cf24a1a508fbe6264ad84702567" -dependencies = [ - "anyhow", - "cc", - "const_format", - "futures", - "futures-core", - "futures-util", - "hex", - "http 1.3.1", - "http-body 1.0.1", - "http-body-util", - "hyper 1.6.0", - "hyper-rustls", - "hyper-util", - "libc", - "nix 0.29.0", - "pin-project", - "regex", - "rustls", - "rustls-native-certs", - "serde", - "static_assertions", - "thiserror 1.0.69", - "tokio", - "tokio-rustls", - "tower-service", - "windows-sys 0.52.0", -] - [[package]] name = "ddsketch-agent" version = "0.1.0" @@ -1340,7 +1243,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.3.1", - "indexmap 2.10.0", + "indexmap 2.12.0", "slab", "tokio", "tokio-util", @@ -1373,6 +1276,12 @@ dependencies = [ "foldhash", ] +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + [[package]] name = "headers" version = "0.4.1" @@ -1767,12 +1676,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.10.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", - "hashbrown 0.15.4", + "hashbrown 0.16.0", ] [[package]] @@ -1916,6 +1825,113 @@ version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +[[package]] +name = "libdd-common" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +dependencies = [ + "anyhow", + "cc", + "const_format", + "futures", + "futures-core", + "futures-util", + "hex", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "hyper 1.6.0", + "hyper-rustls", + "hyper-util", + "libc", + "nix 0.29.0", + "pin-project", + "regex", + "rustls", + "rustls-native-certs", + "serde", + "static_assertions", + "thiserror 1.0.69", + "tokio", + "tokio-rustls", + "tower-service", + "windows-sys 0.52.0", +] + +[[package]] +name = "libdd-ddsketch" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +dependencies = [ + "prost", +] + +[[package]] +name = "libdd-tinybytes" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +dependencies = [ + "serde", +] + +[[package]] +name = "libdd-trace-normalization" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +dependencies = [ + "anyhow", + "libdd-trace-protobuf", +] + +[[package]] +name = "libdd-trace-protobuf" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +dependencies = [ + "prost", + "serde", + "serde_bytes", +] + +[[package]] +name = "libdd-trace-stats" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +dependencies = [ + "hashbrown 0.15.4", + "libdd-ddsketch", + "libdd-trace-protobuf", + "libdd-trace-utils", +] + +[[package]] +name = "libdd-trace-utils" +version = "1.0.0" +source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +dependencies = [ + "anyhow", + "bytes", + "flate2", + "futures", + "http-body-util", + "hyper 1.6.0", + "indexmap 2.12.0", + "libdd-common", + "libdd-tinybytes", + "libdd-trace-normalization", + "libdd-trace-protobuf", + "prost", + "rand 0.8.5", + "rmp", + "rmp-serde", + "rmpv", + "serde", + "serde_json", + "tokio", + "tracing", + "zstd", +] + [[package]] name = "libddwaf" version = "1.28.1" @@ -2323,7 +2339,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.10.0", + "indexmap 2.12.0", ] [[package]] @@ -2572,7 +2588,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4aeaa1f2460f1d348eeaeed86aea999ce98c1bded6f089ff8514c9d9dbdc973" dependencies = [ "anyhow", - "indexmap 2.10.0", + "indexmap 2.12.0", "log", "protobuf", "protobuf-support", @@ -3128,7 +3144,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d2de91cf02bbc07cde38891769ccd5d4f073d22a40683aa4bc7a95781aaa2c4" dependencies = [ "form_urlencoded", - "indexmap 2.10.0", + "indexmap 2.12.0", "itoa", "serde", ] @@ -3183,7 +3199,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.10.0", + "indexmap 2.12.0", "itoa", "ryu", "serde", @@ -3521,14 +3537,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinybytes" -version = "22.1.0" -source = "git+https://github.com/DataDog/libdatadog?rev=ba8955394cf35cf24a1a508fbe6264ad84702567#ba8955394cf35cf24a1a508fbe6264ad84702567" -dependencies = [ - "serde", -] - [[package]] name = "tinystr" version = "0.8.1" diff --git a/bottlecap/Cargo.toml b/bottlecap/Cargo.toml index 5da581f55..5d537e0e1 100644 --- a/bottlecap/Cargo.toml +++ b/bottlecap/Cargo.toml @@ -50,6 +50,10 @@ rustls-native-certs = { version = "0.8.1", optional = true } axum = { version = "0.8.4", default-features = false, features = ["default"] } ustr = { version = "1.0.0", default-features = false } tower-http = { version = "0.6.6", default-features = false, features = ["limit"] } +hyper-http-proxy = { version = "1.1.0", default-features = false, features = [ + "rustls-tls-webpki-roots", +] } +indexmap = {version = "2.11.0", default-features = false} # If you are adding or updating a datadog-owned code dependency, please ensure # that it has a clippy.toml rule for disallowing the reqwest::Client::builder # method in favor of our @@ -57,12 +61,12 @@ tower-http = { version = "0.6.6", default-features = false, features = ["limit"] # be found in the clippy.toml file adjacent to this Cargo.toml. datadog-protos = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "c89b58e5784b985819baf11f13f7d35876741222"} ddsketch-agent = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "c89b58e5784b985819baf11f13f7d35876741222"} -ddcommon = { git = "https://github.com/DataDog/libdatadog", rev = "ba8955394cf35cf24a1a508fbe6264ad84702567" } -datadog-trace-protobuf = { git = "https://github.com/DataDog/libdatadog", rev = "ba8955394cf35cf24a1a508fbe6264ad84702567" } -datadog-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "ba8955394cf35cf24a1a508fbe6264ad84702567" , features = ["mini_agent"] } -datadog-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "ba8955394cf35cf24a1a508fbe6264ad84702567" } -datadog-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "ba8955394cf35cf24a1a508fbe6264ad84702567" } -datadog-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "ba8955394cf35cf24a1a508fbe6264ad84702567" } +libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } +libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" , features = ["mini_agent"] } +libdd-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } +datadog-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } +libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } dogstatsd = { git = "https://github.com/DataDog/serverless-components", rev = "502f005c56b8d51dee95424a9c1404df46e2aae4", default-features = false } datadog-fips = { git = "https://github.com/DataDog/serverless-components", rev = "502f005c56b8d51dee95424a9c1404df46e2aae4", default-features = false } libddwaf = { version = "1.28.1", git = "https://github.com/DataDog/libddwaf-rust", rev = "d1534a158d976bd4f747bf9fcc58e0712d2d17fc", default-features = false, features = ["serde"] } @@ -104,10 +108,10 @@ opt-level = 3 tikv-jemallocator = "0.5" [features] -default = ["reqwest/rustls-tls-native-roots", "dogstatsd/default", "datadog-fips/default" ] +default = ["reqwest/rustls-tls-native-roots", "dogstatsd/default", "datadog-fips/default", ] fips = [ - "ddcommon/fips", - "datadog-trace-utils/fips", + "libdd-common/fips", + "libdd-trace-utils/fips", "dogstatsd/fips", "datadog-fips/fips", "libddwaf/fips", diff --git a/bottlecap/src/appsec/processor/context.rs b/bottlecap/src/appsec/processor/context.rs index cc0fff886..79ce3a002 100644 --- a/bottlecap/src/appsec/processor/context.rs +++ b/bottlecap/src/appsec/processor/context.rs @@ -4,8 +4,8 @@ use std::sync::Arc; use std::time::Duration; use bytes::{Buf, Bytes}; -use datadog_trace_protobuf::pb::Span; -use datadog_trace_utils::tracer_header_tags; +use libdd_trace_protobuf::pb::Span; +use libdd_trace_utils::tracer_header_tags; use libddwaf::object::{Keyed, WafMap, WafObject}; use libddwaf::{Context as WafContext, Handle, RunError, RunOutput, RunResult, waf_map}; use mime::Mime; diff --git a/bottlecap/src/appsec/processor/mod.rs b/bottlecap/src/appsec/processor/mod.rs index bd52079ad..7143300e4 100644 --- a/bottlecap/src/appsec/processor/mod.rs +++ b/bottlecap/src/appsec/processor/mod.rs @@ -8,7 +8,7 @@ use std::time::Duration; use bytes::Bytes; use cookie::Cookie; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use itertools::Itertools; use libddwaf::object::{WafMap, WafOwned}; use libddwaf::{Builder, Config as WafConfig, Handle}; diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index 2d7f5fb1b..045698405 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -78,7 +78,7 @@ use bottlecap::{ use datadog_fips::reqwest_adapter::create_reqwest_client_builder; use datadog_protos::metrics::SketchPayload; use datadog_trace_obfuscation::obfuscation_config; -use datadog_trace_utils::send_data::SendData; +use libdd_trace_utils::send_data::SendData; use decrypt::resolve_secrets; use dogstatsd::{ aggregator_service::AggregatorHandle as MetricsAggregatorHandle, diff --git a/bottlecap/src/config/mod.rs b/bottlecap/src/config/mod.rs index 369e6ee73..f5ab18be5 100644 --- a/bottlecap/src/config/mod.rs +++ b/bottlecap/src/config/mod.rs @@ -11,7 +11,7 @@ pub mod trace_propagation_style; pub mod yaml; use datadog_trace_obfuscation::replacer::ReplaceRule; -use datadog_trace_utils::config_utils::{trace_intake_url, trace_intake_url_prefixed}; +use libdd_trace_utils::config_utils::{trace_intake_url, trace_intake_url_prefixed}; use serde::{Deserialize, Deserializer}; use serde_aux::prelude::deserialize_bool_from_anything; diff --git a/bottlecap/src/lifecycle/invocation/context.rs b/bottlecap/src/lifecycle/invocation/context.rs index 13c0f0032..c8f4fac18 100644 --- a/bottlecap/src/lifecycle/invocation/context.rs +++ b/bottlecap/src/lifecycle/invocation/context.rs @@ -7,7 +7,7 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde_json::Value; use tracing::debug; diff --git a/bottlecap/src/lifecycle/invocation/mod.rs b/bottlecap/src/lifecycle/invocation/mod.rs index 30db1b842..f99974b6c 100644 --- a/bottlecap/src/lifecycle/invocation/mod.rs +++ b/bottlecap/src/lifecycle/invocation/mod.rs @@ -1,5 +1,5 @@ use base64::{DecodeError, Engine, engine::general_purpose}; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use rand::{Rng, RngCore, rngs::OsRng}; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/processor.rs b/bottlecap/src/lifecycle/invocation/processor.rs index 1dfcb7fb3..e9ec350ac 100644 --- a/bottlecap/src/lifecycle/invocation/processor.rs +++ b/bottlecap/src/lifecycle/invocation/processor.rs @@ -5,8 +5,8 @@ use std::{ }; use chrono::{DateTime, Utc}; -use datadog_trace_protobuf::pb::Span; -use datadog_trace_utils::tracer_header_tags; +use libdd_trace_protobuf::pb::Span; +use libdd_trace_utils::tracer_header_tags; use serde_json::Value; use tokio::time::Instant; use tracing::{debug, warn}; diff --git a/bottlecap/src/lifecycle/invocation/processor_service.rs b/bottlecap/src/lifecycle/invocation/processor_service.rs index 8eab53d44..4c7ffc605 100644 --- a/bottlecap/src/lifecycle/invocation/processor_service.rs +++ b/bottlecap/src/lifecycle/invocation/processor_service.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, sync::Arc}; use chrono::{DateTime, Utc}; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use dogstatsd::aggregator_service::AggregatorHandle; use serde_json::Value; use thiserror::Error; diff --git a/bottlecap/src/lifecycle/invocation/span_inferrer.rs b/bottlecap/src/lifecycle/invocation/span_inferrer.rs index 5f30ea67d..f5b7adff0 100644 --- a/bottlecap/src/lifecycle/invocation/span_inferrer.rs +++ b/bottlecap/src/lifecycle/invocation/span_inferrer.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::sync::Arc; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde_json::Value; use tracing::debug; diff --git a/bottlecap/src/lifecycle/invocation/triggers/alb_event.rs b/bottlecap/src/lifecycle/invocation/triggers/alb_event.rs index 4ac442831..26c0f8082 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/alb_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/alb_event.rs @@ -2,7 +2,7 @@ use super::ServiceNameResolver; use crate::lifecycle::invocation::triggers::{ FUNCTION_TRIGGER_EVENT_SOURCE_TAG, Trigger, body::Body, }; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/api_gateway_http_event.rs b/bottlecap/src/lifecycle/invocation/triggers/api_gateway_http_event.rs index 253065bb2..807e4e7ab 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/api_gateway_http_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/api_gateway_http_event.rs @@ -6,7 +6,7 @@ use crate::lifecycle::invocation::{ parameterize_api_resource, }, }; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/api_gateway_rest_event.rs b/bottlecap/src/lifecycle/invocation/triggers/api_gateway_rest_event.rs index ba7479026..9bebc7744 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/api_gateway_rest_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/api_gateway_rest_event.rs @@ -6,7 +6,7 @@ use crate::lifecycle::invocation::{ parameterize_api_resource, serde_utils::nullable_map, }, }; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/api_gateway_websocket_event.rs b/bottlecap/src/lifecycle/invocation/triggers/api_gateway_websocket_event.rs index a7d9d73a8..62d767366 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/api_gateway_websocket_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/api_gateway_websocket_event.rs @@ -5,7 +5,7 @@ use crate::{ triggers::{FUNCTION_TRIGGER_EVENT_SOURCE_TAG, Trigger, body::Body, lowercase_key}, }, }; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/dynamodb_event.rs b/bottlecap/src/lifecycle/invocation/triggers/dynamodb_event.rs index 38b3f4dfc..4b9fd1ce2 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/dynamodb_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/dynamodb_event.rs @@ -1,5 +1,5 @@ use base64::{Engine, engine::general_purpose::STANDARD}; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/event_bridge_event.rs b/bottlecap/src/lifecycle/invocation/triggers/event_bridge_event.rs index f4754cef5..f4b15b7ed 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/event_bridge_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/event_bridge_event.rs @@ -1,5 +1,5 @@ use chrono::{DateTime, Utc}; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/kinesis_event.rs b/bottlecap/src/lifecycle/invocation/triggers/kinesis_event.rs index 6ccf24fcf..64a4fe3c3 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/kinesis_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/kinesis_event.rs @@ -1,7 +1,7 @@ #![allow(clippy::module_name_repetitions)] use base64::Engine; use base64::engine::general_purpose; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::{Value, from_slice}; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/lambda_function_url_event.rs b/bottlecap/src/lifecycle/invocation/triggers/lambda_function_url_event.rs index 3f4389202..bec439eae 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/lambda_function_url_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/lambda_function_url_event.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, env}; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; diff --git a/bottlecap/src/lifecycle/invocation/triggers/mod.rs b/bottlecap/src/lifecycle/invocation/triggers/mod.rs index e51e23e80..d1809bb6c 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/mod.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/mod.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use lazy_static::lazy_static; use regex::Regex; use serde::{Deserialize, Deserializer}; diff --git a/bottlecap/src/lifecycle/invocation/triggers/msk_event.rs b/bottlecap/src/lifecycle/invocation/triggers/msk_event.rs index 6523387ee..2673f1446 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/msk_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/msk_event.rs @@ -2,7 +2,7 @@ use crate::lifecycle::invocation::processor::MS_TO_NS; use crate::lifecycle::invocation::triggers::{ FUNCTION_TRIGGER_EVENT_SOURCE_TAG, ServiceNameResolver, Trigger, }; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/s3_event.rs b/bottlecap/src/lifecycle/invocation/triggers/s3_event.rs index 6e2237d7a..5af80349c 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/s3_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/s3_event.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use chrono::{DateTime, Utc}; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use tracing::debug; diff --git a/bottlecap/src/lifecycle/invocation/triggers/sns_event.rs b/bottlecap/src/lifecycle/invocation/triggers/sns_event.rs index 95df01083..73e53d2ac 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/sns_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/sns_event.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use chrono::{DateTime, Utc}; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use tracing::debug; @@ -185,7 +185,7 @@ impl ServiceNameResolver for SnsRecord { #[cfg(test)] #[allow(clippy::unwrap_used)] mod tests { - use datadog_trace_protobuf::pb::Span; + use libdd_trace_protobuf::pb::Span; use super::*; use crate::lifecycle::invocation::triggers::test_utils::read_json_file; diff --git a/bottlecap/src/lifecycle/invocation/triggers/sqs_event.rs b/bottlecap/src/lifecycle/invocation/triggers/sqs_event.rs index 834e9c143..fab3549b6 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/sqs_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/sqs_event.rs @@ -8,7 +8,7 @@ use crate::lifecycle::invocation::{ }, }; use crate::traces::context::{Sampling, SpanContext}; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; diff --git a/bottlecap/src/lifecycle/invocation/triggers/step_function_event.rs b/bottlecap/src/lifecycle/invocation/triggers/step_function_event.rs index aaf5cfe2b..628388e6c 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/step_function_event.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/step_function_event.rs @@ -114,7 +114,7 @@ impl Trigger for StepFunctionEvent { fn enrich_span( &self, - _span: &mut datadog_trace_protobuf::pb::Span, + _span: &mut libdd_trace_protobuf::pb::Span, _service_mapping: &HashMap, _aws_service_representation_enabled: bool, ) { diff --git a/bottlecap/src/otlp/agent.rs b/bottlecap/src/otlp/agent.rs index a519bdb62..b41dbb8fa 100644 --- a/bottlecap/src/otlp/agent.rs +++ b/bottlecap/src/otlp/agent.rs @@ -5,7 +5,7 @@ use axum::{ response::{IntoResponse, Response}, routing::post, }; -use datadog_trace_utils::trace_utils::TracerHeaderTags as DatadogTracerHeaderTags; +use libdd_trace_utils::trace_utils::TracerHeaderTags as DatadogTracerHeaderTags; use serde_json::json; use std::net::SocketAddr; use std::sync::Arc; diff --git a/bottlecap/src/otlp/processor.rs b/bottlecap/src/otlp/processor.rs index 97f4d7669..1e08a9856 100644 --- a/bottlecap/src/otlp/processor.rs +++ b/bottlecap/src/otlp/processor.rs @@ -1,4 +1,4 @@ -use datadog_trace_protobuf::pb::Span as DatadogSpan; +use libdd_trace_protobuf::pb::Span as DatadogSpan; use opentelemetry_proto::tonic::collector::trace::v1::ExportTraceServiceRequest; use prost::Message; use std::{error::Error, sync::Arc}; diff --git a/bottlecap/src/otlp/transform.rs b/bottlecap/src/otlp/transform.rs index 4f098a194..76ae9f688 100644 --- a/bottlecap/src/otlp/transform.rs +++ b/bottlecap/src/otlp/transform.rs @@ -1,7 +1,7 @@ -use datadog_trace_normalization::normalize_utils::{ +use libdd_trace_normalization::normalize_utils::{ normalize_name, normalize_service, normalize_tag, }; -use datadog_trace_protobuf::pb::Span as DatadogSpan; +use libdd_trace_protobuf::pb::Span as DatadogSpan; use hex; use lazy_static::lazy_static; use opentelemetry_proto::tonic::common::v1::{ @@ -566,7 +566,7 @@ fn get_otel_status_code(otel_span: &OtelSpan) -> u32 { 0 } -// todo: use from datadog_trace_utils when public +// todo: use from libdd_trace_utils when public fn set_top_level_dd_span(span: &mut DatadogSpan, is_top_level: bool) { if is_top_level { span.metrics.insert("_top_level".into(), 1.0); @@ -575,7 +575,7 @@ fn set_top_level_dd_span(span: &mut DatadogSpan, is_top_level: bool) { } } -// todo: use from datadog_trace_utils when public +// todo: use from libdd_trace_utils when public fn set_measured_dd_span(span: &mut DatadogSpan, measured: bool) { if measured { span.metrics.remove("_dd.measured"); diff --git a/bottlecap/src/traces/context.rs b/bottlecap/src/traces/context.rs index 600ae1c39..4c31d619e 100644 --- a/bottlecap/src/traces/context.rs +++ b/bottlecap/src/traces/context.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use datadog_trace_protobuf::pb::SpanLink; +use libdd_trace_protobuf::pb::SpanLink; #[derive(Copy, Clone, Default, Debug, PartialEq)] pub struct Sampling { diff --git a/bottlecap/src/traces/propagation/mod.rs b/bottlecap/src/traces/propagation/mod.rs index 163601962..097f94292 100644 --- a/bottlecap/src/traces/propagation/mod.rs +++ b/bottlecap/src/traces/propagation/mod.rs @@ -5,7 +5,7 @@ use crate::{ traces::context::SpanContext, }; use carrier::{Extractor, Injector}; -use datadog_trace_protobuf::pb::SpanLink; +use libdd_trace_protobuf::pb::SpanLink; use text_map_propagator::{ BAGGAGE_PREFIX, DATADOG_HIGHER_ORDER_TRACE_ID_BITS_KEY, DATADOG_LAST_PARENT_ID_KEY, TRACESTATE_KEY, diff --git a/bottlecap/src/traces/span_pointers.rs b/bottlecap/src/traces/span_pointers.rs index 47bf3f9fa..1f88a5ee5 100644 --- a/bottlecap/src/traces/span_pointers.rs +++ b/bottlecap/src/traces/span_pointers.rs @@ -1,7 +1,7 @@ // Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -use datadog_trace_protobuf::pb::SpanLink; +use libdd_trace_protobuf::pb::SpanLink; use sha2::{Digest, Sha256}; use std::collections::HashMap; diff --git a/bottlecap/src/traces/stats_aggregator.rs b/bottlecap/src/traces/stats_aggregator.rs index 8c8a1eaf6..daa3a5e77 100644 --- a/bottlecap/src/traces/stats_aggregator.rs +++ b/bottlecap/src/traces/stats_aggregator.rs @@ -1,5 +1,5 @@ use crate::traces::stats_concentrator_service::StatsConcentratorHandle; -use datadog_trace_protobuf::pb::ClientStatsPayload; +use libdd_trace_protobuf::pb::ClientStatsPayload; use std::collections::VecDeque; use tracing::error; diff --git a/bottlecap/src/traces/stats_concentrator_service.rs b/bottlecap/src/traces/stats_concentrator_service.rs index 06c4f1851..edeff12dd 100644 --- a/bottlecap/src/traces/stats_concentrator_service.rs +++ b/bottlecap/src/traces/stats_concentrator_service.rs @@ -1,9 +1,9 @@ use tokio::sync::{mpsc, oneshot}; use crate::config::Config; -use datadog_trace_protobuf::pb; -use datadog_trace_protobuf::pb::{ClientStatsPayload, TracerPayload}; -use datadog_trace_stats::span_concentrator::SpanConcentrator; +use libdd_trace_protobuf::pb; +use libdd_trace_protobuf::pb::{ClientStatsPayload, TracerPayload}; +use libdd_trace_stats::span_concentrator::SpanConcentrator; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use std::time::{Duration, SystemTime}; diff --git a/bottlecap/src/traces/stats_flusher.rs b/bottlecap/src/traces/stats_flusher.rs index 1c10979f2..0838df84a 100644 --- a/bottlecap/src/traces/stats_flusher.rs +++ b/bottlecap/src/traces/stats_flusher.rs @@ -10,9 +10,9 @@ use tokio::sync::OnceCell; use crate::config; use crate::lifecycle::invocation::processor::S_TO_MS; use crate::traces::stats_aggregator::StatsAggregator; -use datadog_trace_protobuf::pb; -use datadog_trace_utils::{config_utils::trace_stats_url, stats_utils}; -use ddcommon::Endpoint; +use libdd_trace_protobuf::pb; +use libdd_trace_utils::{config_utils::trace_stats_url, stats_utils}; +use libdd_common::Endpoint; use dogstatsd::api_key::ApiKeyFactory; use tracing::{debug, error}; diff --git a/bottlecap/src/traces/stats_generator.rs b/bottlecap/src/traces/stats_generator.rs index 63724291d..81dc4cdb5 100644 --- a/bottlecap/src/traces/stats_generator.rs +++ b/bottlecap/src/traces/stats_generator.rs @@ -1,5 +1,5 @@ use crate::traces::stats_concentrator_service::StatsConcentratorHandle; -use datadog_trace_utils::tracer_payload::TracerPayloadCollection; +use libdd_trace_utils::tracer_payload::TracerPayloadCollection; use tracing::error; use crate::traces::stats_concentrator_service::StatsError; diff --git a/bottlecap/src/traces/stats_processor.rs b/bottlecap/src/traces/stats_processor.rs index fa30bf0c2..cbf360df6 100644 --- a/bottlecap/src/traces/stats_processor.rs +++ b/bottlecap/src/traces/stats_processor.rs @@ -12,9 +12,9 @@ use axum::{ use tokio::sync::mpsc::Sender; use tracing::{debug, error}; -use datadog_trace_protobuf::pb; -use datadog_trace_utils::stats_utils; -use ddcommon::hyper_migration; +use libdd_trace_protobuf::pb; +use libdd_trace_utils::stats_utils; +use libdd_common::hyper_migration; use super::trace_agent::MAX_CONTENT_LENGTH; use crate::http::extract_request_body; diff --git a/bottlecap/src/traces/trace_agent.rs b/bottlecap/src/traces/trace_agent.rs index 7814f3e49..28f80cd3a 100644 --- a/bottlecap/src/traces/trace_agent.rs +++ b/bottlecap/src/traces/trace_agent.rs @@ -41,9 +41,9 @@ use crate::{ trace_processor, }, }; -use datadog_trace_protobuf::pb; -use datadog_trace_utils::trace_utils::{self}; -use ddcommon::hyper_migration; +use libdd_trace_protobuf::pb; +use libdd_trace_utils::trace_utils::{self}; +use libdd_common::hyper_migration; use crate::traces::stats_concentrator_service::StatsConcentratorHandle; diff --git a/bottlecap/src/traces/trace_aggregator.rs b/bottlecap/src/traces/trace_aggregator.rs index 09212c4dc..24f4f842a 100644 --- a/bottlecap/src/traces/trace_aggregator.rs +++ b/bottlecap/src/traces/trace_aggregator.rs @@ -1,4 +1,4 @@ -use datadog_trace_utils::send_data::SendDataBuilder; +use libdd_trace_utils::send_data::SendDataBuilder; use std::collections::VecDeque; /// Maximum content size per payload uncompressed in bytes, @@ -88,10 +88,10 @@ impl TraceAggregator { #[cfg(test)] #[allow(clippy::unwrap_used)] mod tests { - use datadog_trace_utils::{ + use libdd_trace_utils::{ trace_utils::TracerHeaderTags, tracer_payload::TracerPayloadCollection, }; - use ddcommon::Endpoint; + use libdd_common::Endpoint; use super::*; diff --git a/bottlecap/src/traces/trace_aggregator_service.rs b/bottlecap/src/traces/trace_aggregator_service.rs index ac77a5748..947c3e19a 100644 --- a/bottlecap/src/traces/trace_aggregator_service.rs +++ b/bottlecap/src/traces/trace_aggregator_service.rs @@ -1,4 +1,4 @@ -use datadog_trace_utils::send_data::SendDataBuilder; +use libdd_trace_utils::send_data::SendDataBuilder; use tokio::sync::{mpsc, oneshot}; use tracing::{debug, error}; @@ -104,10 +104,10 @@ impl AggregatorService { #[allow(clippy::unwrap_used)] mod tests { use super::*; - use datadog_trace_utils::{ + use libdd_trace_utils::{ trace_utils::TracerHeaderTags, tracer_payload::TracerPayloadCollection, }; - use ddcommon::Endpoint; + use libdd_common::Endpoint; #[tokio::test] async fn test_aggregator_service_insert_and_flush() { diff --git a/bottlecap/src/traces/trace_flusher.rs b/bottlecap/src/traces/trace_flusher.rs index bb7186d09..cc0b8eea7 100644 --- a/bottlecap/src/traces/trace_flusher.rs +++ b/bottlecap/src/traces/trace_flusher.rs @@ -2,17 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 use async_trait::async_trait; -use datadog_trace_utils::{ +use libdd_trace_utils::{ config_utils::trace_intake_url_prefixed, send_data::SendDataBuilder, trace_utils::{self, SendData}, }; -use ddcommon::Endpoint; +use libdd_common::{Endpoint, GenericHttpClient, hyper_migration}; use dogstatsd::api_key::ApiKeyFactory; use std::str::FromStr; use std::sync::Arc; use tokio::task::JoinSet; use tracing::{debug, error}; +use std::error::Error; +use hyper_http_proxy; use crate::config::Config; use crate::lifecycle::invocation::processor::S_TO_MS; @@ -165,6 +167,11 @@ impl TraceFlusher for ServerlessTraceFlusher { tokio::task::yield_now().await; debug!("TRACES | Flushing {} traces", coalesced_traces.len()); + let Ok(http_client) = ServerlessTraceFlusher::get_http_client(proxy_https.as_ref()) else { + error!("TRACES | Failed to create HTTP client"); + return None; + }; + for trace in &coalesced_traces { let trace_with_endpoint = match endpoint { Some(additional_endpoint) => trace.with_endpoint(additional_endpoint.clone()), @@ -172,7 +179,7 @@ impl TraceFlusher for ServerlessTraceFlusher { }; let send_result = trace_with_endpoint - .send_proxy(proxy_https.as_deref()) + .send(&http_client) .await .last_result; @@ -187,3 +194,22 @@ impl TraceFlusher for ServerlessTraceFlusher { None } } + +impl ServerlessTraceFlusher { + fn get_http_client(proxy_https: Option<&String>) -> Result>, Box> { + if let Some(proxy) = proxy_https { + let proxy = hyper_http_proxy::Proxy::new( + hyper_http_proxy::Intercept::Https, + proxy.parse()?, + ); + let proxy_connector = hyper_http_proxy::ProxyConnector::from_proxy( + libdd_common::connector::Connector::default(), + proxy, + )?; + Ok(hyper_migration::client_builder().build(proxy_connector)) + } else { + let proxy_connector = hyper_http_proxy::ProxyConnector::new(libdd_common::connector::Connector::default())?; + Ok(hyper_migration::client_builder().build(proxy_connector)) + } + } +} \ No newline at end of file diff --git a/bottlecap/src/traces/trace_processor.rs b/bottlecap/src/traces/trace_processor.rs index 8618f6b70..907616b8b 100644 --- a/bottlecap/src/traces/trace_processor.rs +++ b/bottlecap/src/traces/trace_processor.rs @@ -15,14 +15,14 @@ use crate::traces::{ use async_trait::async_trait; use datadog_trace_obfuscation::obfuscate::obfuscate_span; use datadog_trace_obfuscation::obfuscation_config; -use datadog_trace_protobuf::pb; -use datadog_trace_protobuf::pb::Span; -use datadog_trace_utils::send_data::{Compression, SendDataBuilder}; -use datadog_trace_utils::send_with_retry::{RetryBackoffType, RetryStrategy}; -use datadog_trace_utils::trace_utils::{self}; -use datadog_trace_utils::tracer_header_tags; -use datadog_trace_utils::tracer_payload::{TraceChunkProcessor, TracerPayloadCollection}; -use ddcommon::Endpoint; +use libdd_trace_protobuf::pb; +use libdd_trace_protobuf::pb::Span; +use libdd_trace_utils::send_data::{Compression, SendDataBuilder}; +use libdd_trace_utils::send_with_retry::{RetryBackoffType, RetryStrategy}; +use libdd_trace_utils::trace_utils::{self}; +use libdd_trace_utils::tracer_header_tags; +use libdd_trace_utils::tracer_payload::{TraceChunkProcessor, TracerPayloadCollection}; +use libdd_common::Endpoint; use regex::Regex; use std::str::FromStr; use std::sync::Arc; diff --git a/bottlecap/tests/appsec_processor_test.rs b/bottlecap/tests/appsec_processor_test.rs index b246179d6..127ed01a7 100644 --- a/bottlecap/tests/appsec_processor_test.rs +++ b/bottlecap/tests/appsec_processor_test.rs @@ -8,7 +8,7 @@ use bottlecap::appsec::processor::Processor; use bottlecap::config::Config; use bottlecap::lifecycle::invocation::triggers::IdentifiedTrigger; use bytes::Bytes; -use datadog_trace_protobuf::pb::Span; +use libdd_trace_protobuf::pb::Span; use itertools::Itertools; use tokio::sync::Mutex; use tokio::task::JoinSet; From 954e8c1c8c7dfc61d5f20f32d89be251937f1ff7 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Thu, 13 Nov 2025 13:32:01 -0500 Subject: [PATCH 4/7] fmt --- bottlecap/src/appsec/processor/mod.rs | 2 +- bottlecap/src/bin/bottlecap/main.rs | 2 +- .../lifecycle/invocation/processor_service.rs | 2 +- .../src/lifecycle/invocation/triggers/mod.rs | 2 +- bottlecap/src/otlp/transform.rs | 4 +-- bottlecap/src/traces/stats_flusher.rs | 4 +-- bottlecap/src/traces/stats_processor.rs | 2 +- bottlecap/src/traces/trace_agent.rs | 2 +- bottlecap/src/traces/trace_aggregator.rs | 2 +- .../src/traces/trace_aggregator_service.rs | 2 +- bottlecap/src/traces/trace_flusher.rs | 32 ++++++++++--------- bottlecap/src/traces/trace_processor.rs | 2 +- bottlecap/tests/appsec_processor_test.rs | 2 +- 13 files changed, 31 insertions(+), 29 deletions(-) diff --git a/bottlecap/src/appsec/processor/mod.rs b/bottlecap/src/appsec/processor/mod.rs index 7143300e4..930711b41 100644 --- a/bottlecap/src/appsec/processor/mod.rs +++ b/bottlecap/src/appsec/processor/mod.rs @@ -8,8 +8,8 @@ use std::time::Duration; use bytes::Bytes; use cookie::Cookie; -use libdd_trace_protobuf::pb::Span; use itertools::Itertools; +use libdd_trace_protobuf::pb::Span; use libddwaf::object::{WafMap, WafOwned}; use libddwaf::{Builder, Config as WafConfig, Handle}; use tokio::sync::Mutex; diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index 045698405..dc6afebde 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -78,7 +78,6 @@ use bottlecap::{ use datadog_fips::reqwest_adapter::create_reqwest_client_builder; use datadog_protos::metrics::SketchPayload; use datadog_trace_obfuscation::obfuscation_config; -use libdd_trace_utils::send_data::SendData; use decrypt::resolve_secrets; use dogstatsd::{ aggregator_service::AggregatorHandle as MetricsAggregatorHandle, @@ -93,6 +92,7 @@ use dogstatsd::{ flusher::{Flusher as MetricsFlusher, FlusherConfig as MetricsFlusherConfig}, metric::{EMPTY_TAGS, SortedTags}, }; +use libdd_trace_utils::send_data::SendData; use reqwest::Client; use std::{collections::hash_map, env, path::Path, str::FromStr, sync::Arc}; use tokio::time::{Duration, Instant}; diff --git a/bottlecap/src/lifecycle/invocation/processor_service.rs b/bottlecap/src/lifecycle/invocation/processor_service.rs index 4c7ffc605..722bb92fd 100644 --- a/bottlecap/src/lifecycle/invocation/processor_service.rs +++ b/bottlecap/src/lifecycle/invocation/processor_service.rs @@ -1,8 +1,8 @@ use std::{collections::HashMap, sync::Arc}; use chrono::{DateTime, Utc}; -use libdd_trace_protobuf::pb::Span; use dogstatsd::aggregator_service::AggregatorHandle; +use libdd_trace_protobuf::pb::Span; use serde_json::Value; use thiserror::Error; use tokio::sync::{mpsc, oneshot}; diff --git a/bottlecap/src/lifecycle/invocation/triggers/mod.rs b/bottlecap/src/lifecycle/invocation/triggers/mod.rs index d1809bb6c..cd28b523f 100644 --- a/bottlecap/src/lifecycle/invocation/triggers/mod.rs +++ b/bottlecap/src/lifecycle/invocation/triggers/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; -use libdd_trace_protobuf::pb::Span; use lazy_static::lazy_static; +use libdd_trace_protobuf::pb::Span; use regex::Regex; use serde::{Deserialize, Deserializer}; use serde_json::Value; diff --git a/bottlecap/src/otlp/transform.rs b/bottlecap/src/otlp/transform.rs index 76ae9f688..9fb11cfef 100644 --- a/bottlecap/src/otlp/transform.rs +++ b/bottlecap/src/otlp/transform.rs @@ -1,9 +1,9 @@ +use hex; +use lazy_static::lazy_static; use libdd_trace_normalization::normalize_utils::{ normalize_name, normalize_service, normalize_tag, }; use libdd_trace_protobuf::pb::Span as DatadogSpan; -use hex; -use lazy_static::lazy_static; use opentelemetry_proto::tonic::common::v1::{ AnyValue, InstrumentationScope as OtelInstrumentationScope, KeyValue, any_value, }; diff --git a/bottlecap/src/traces/stats_flusher.rs b/bottlecap/src/traces/stats_flusher.rs index 0838df84a..6635f9ec4 100644 --- a/bottlecap/src/traces/stats_flusher.rs +++ b/bottlecap/src/traces/stats_flusher.rs @@ -10,10 +10,10 @@ use tokio::sync::OnceCell; use crate::config; use crate::lifecycle::invocation::processor::S_TO_MS; use crate::traces::stats_aggregator::StatsAggregator; +use dogstatsd::api_key::ApiKeyFactory; +use libdd_common::Endpoint; use libdd_trace_protobuf::pb; use libdd_trace_utils::{config_utils::trace_stats_url, stats_utils}; -use libdd_common::Endpoint; -use dogstatsd::api_key::ApiKeyFactory; use tracing::{debug, error}; #[async_trait] diff --git a/bottlecap/src/traces/stats_processor.rs b/bottlecap/src/traces/stats_processor.rs index cbf360df6..fd8c91260 100644 --- a/bottlecap/src/traces/stats_processor.rs +++ b/bottlecap/src/traces/stats_processor.rs @@ -12,9 +12,9 @@ use axum::{ use tokio::sync::mpsc::Sender; use tracing::{debug, error}; +use libdd_common::hyper_migration; use libdd_trace_protobuf::pb; use libdd_trace_utils::stats_utils; -use libdd_common::hyper_migration; use super::trace_agent::MAX_CONTENT_LENGTH; use crate::http::extract_request_body; diff --git a/bottlecap/src/traces/trace_agent.rs b/bottlecap/src/traces/trace_agent.rs index 28f80cd3a..0e32055e1 100644 --- a/bottlecap/src/traces/trace_agent.rs +++ b/bottlecap/src/traces/trace_agent.rs @@ -41,9 +41,9 @@ use crate::{ trace_processor, }, }; +use libdd_common::hyper_migration; use libdd_trace_protobuf::pb; use libdd_trace_utils::trace_utils::{self}; -use libdd_common::hyper_migration; use crate::traces::stats_concentrator_service::StatsConcentratorHandle; diff --git a/bottlecap/src/traces/trace_aggregator.rs b/bottlecap/src/traces/trace_aggregator.rs index 24f4f842a..a17d54c7b 100644 --- a/bottlecap/src/traces/trace_aggregator.rs +++ b/bottlecap/src/traces/trace_aggregator.rs @@ -88,10 +88,10 @@ impl TraceAggregator { #[cfg(test)] #[allow(clippy::unwrap_used)] mod tests { + use libdd_common::Endpoint; use libdd_trace_utils::{ trace_utils::TracerHeaderTags, tracer_payload::TracerPayloadCollection, }; - use libdd_common::Endpoint; use super::*; diff --git a/bottlecap/src/traces/trace_aggregator_service.rs b/bottlecap/src/traces/trace_aggregator_service.rs index 947c3e19a..034bb050d 100644 --- a/bottlecap/src/traces/trace_aggregator_service.rs +++ b/bottlecap/src/traces/trace_aggregator_service.rs @@ -104,10 +104,10 @@ impl AggregatorService { #[allow(clippy::unwrap_used)] mod tests { use super::*; + use libdd_common::Endpoint; use libdd_trace_utils::{ trace_utils::TracerHeaderTags, tracer_payload::TracerPayloadCollection, }; - use libdd_common::Endpoint; #[tokio::test] async fn test_aggregator_service_insert_and_flush() { diff --git a/bottlecap/src/traces/trace_flusher.rs b/bottlecap/src/traces/trace_flusher.rs index cc0b8eea7..6e54f0de9 100644 --- a/bottlecap/src/traces/trace_flusher.rs +++ b/bottlecap/src/traces/trace_flusher.rs @@ -2,19 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 use async_trait::async_trait; +use dogstatsd::api_key::ApiKeyFactory; +use hyper_http_proxy; +use libdd_common::{Endpoint, GenericHttpClient, hyper_migration}; use libdd_trace_utils::{ config_utils::trace_intake_url_prefixed, send_data::SendDataBuilder, trace_utils::{self, SendData}, }; -use libdd_common::{Endpoint, GenericHttpClient, hyper_migration}; -use dogstatsd::api_key::ApiKeyFactory; +use std::error::Error; use std::str::FromStr; use std::sync::Arc; use tokio::task::JoinSet; use tracing::{debug, error}; -use std::error::Error; -use hyper_http_proxy; use crate::config::Config; use crate::lifecycle::invocation::processor::S_TO_MS; @@ -178,10 +178,7 @@ impl TraceFlusher for ServerlessTraceFlusher { None => trace.clone(), }; - let send_result = trace_with_endpoint - .send(&http_client) - .await - .last_result; + let send_result = trace_with_endpoint.send(&http_client).await.last_result; if let Err(e) = send_result { error!("TRACES | Request failed: {e:?}"); @@ -196,20 +193,25 @@ impl TraceFlusher for ServerlessTraceFlusher { } impl ServerlessTraceFlusher { - fn get_http_client(proxy_https: Option<&String>) -> Result>, Box> { + fn get_http_client( + proxy_https: Option<&String>, + ) -> Result< + GenericHttpClient>, + Box, + > { if let Some(proxy) = proxy_https { - let proxy = hyper_http_proxy::Proxy::new( - hyper_http_proxy::Intercept::Https, - proxy.parse()?, - ); + let proxy = + hyper_http_proxy::Proxy::new(hyper_http_proxy::Intercept::Https, proxy.parse()?); let proxy_connector = hyper_http_proxy::ProxyConnector::from_proxy( libdd_common::connector::Connector::default(), proxy, )?; Ok(hyper_migration::client_builder().build(proxy_connector)) } else { - let proxy_connector = hyper_http_proxy::ProxyConnector::new(libdd_common::connector::Connector::default())?; + let proxy_connector = hyper_http_proxy::ProxyConnector::new( + libdd_common::connector::Connector::default(), + )?; Ok(hyper_migration::client_builder().build(proxy_connector)) } } -} \ No newline at end of file +} diff --git a/bottlecap/src/traces/trace_processor.rs b/bottlecap/src/traces/trace_processor.rs index 907616b8b..d8ade3acc 100644 --- a/bottlecap/src/traces/trace_processor.rs +++ b/bottlecap/src/traces/trace_processor.rs @@ -15,6 +15,7 @@ use crate::traces::{ use async_trait::async_trait; use datadog_trace_obfuscation::obfuscate::obfuscate_span; use datadog_trace_obfuscation::obfuscation_config; +use libdd_common::Endpoint; use libdd_trace_protobuf::pb; use libdd_trace_protobuf::pb::Span; use libdd_trace_utils::send_data::{Compression, SendDataBuilder}; @@ -22,7 +23,6 @@ use libdd_trace_utils::send_with_retry::{RetryBackoffType, RetryStrategy}; use libdd_trace_utils::trace_utils::{self}; use libdd_trace_utils::tracer_header_tags; use libdd_trace_utils::tracer_payload::{TraceChunkProcessor, TracerPayloadCollection}; -use libdd_common::Endpoint; use regex::Regex; use std::str::FromStr; use std::sync::Arc; diff --git a/bottlecap/tests/appsec_processor_test.rs b/bottlecap/tests/appsec_processor_test.rs index 127ed01a7..c7b0f7b56 100644 --- a/bottlecap/tests/appsec_processor_test.rs +++ b/bottlecap/tests/appsec_processor_test.rs @@ -8,8 +8,8 @@ use bottlecap::appsec::processor::Processor; use bottlecap::config::Config; use bottlecap::lifecycle::invocation::triggers::IdentifiedTrigger; use bytes::Bytes; -use libdd_trace_protobuf::pb::Span; use itertools::Itertools; +use libdd_trace_protobuf::pb::Span; use tokio::sync::Mutex; use tokio::task::JoinSet; From 4ba178328b422cd5d11c9114c7b403d8067dfe10 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Thu, 13 Nov 2025 13:39:45 -0500 Subject: [PATCH 5/7] Update license --- bottlecap/Cargo.toml | 2 +- bottlecap/LICENSE-3rdparty.csv | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bottlecap/Cargo.toml b/bottlecap/Cargo.toml index 5d537e0e1..fd742e563 100644 --- a/bottlecap/Cargo.toml +++ b/bottlecap/Cargo.toml @@ -108,7 +108,7 @@ opt-level = 3 tikv-jemallocator = "0.5" [features] -default = ["reqwest/rustls-tls-native-roots", "dogstatsd/default", "datadog-fips/default", ] +default = ["reqwest/rustls-tls-native-roots", "dogstatsd/default", "datadog-fips/default" ] fips = [ "libdd-common/fips", "libdd-trace-utils/fips", diff --git a/bottlecap/LICENSE-3rdparty.csv b/bottlecap/LICENSE-3rdparty.csv index a2ef6aad7..b46187d4e 100644 --- a/bottlecap/LICENSE-3rdparty.csv +++ b/bottlecap/LICENSE-3rdparty.csv @@ -32,15 +32,9 @@ core-foundation-sys,https://github.com/servo/core-foundation-rs,MIT OR Apache-2. cpufeatures,https://github.com/RustCrypto/utils,MIT OR Apache-2.0,RustCrypto Developers crc32fast,https://github.com/srijs/rust-crc32fast,MIT OR Apache-2.0,"Sam Rijs , Alex Crichton " crypto-common,https://github.com/RustCrypto/traits,MIT OR Apache-2.0,RustCrypto Developers -datadog-ddsketch,https://github.com/DataDog/libdatadog,Apache-2.0,The datadog-ddsketch Authors datadog-fips,https://github.com/DataDog/serverless-components,Apache-2.0,The datadog-fips Authors datadog-protos,https://github.com/DataDog/saluki,Apache-2.0,The datadog-protos Authors -datadog-trace-normalization,https://github.com/DataDog/libdatadog,Apache-2.0,David Lee datadog-trace-obfuscation,https://github.com/DataDog/libdatadog,Apache-2.0,David Lee -datadog-trace-protobuf,https://github.com/DataDog/libdatadog,Apache-2.0,David Lee -datadog-trace-stats,https://github.com/DataDog/libdatadog,Apache-2.0,The datadog-trace-stats Authors -datadog-trace-utils,https://github.com/DataDog/libdatadog,Apache-2.0,The datadog-trace-utils Authors -ddcommon,https://github.com/DataDog/libdatadog,Apache-2.0,The ddcommon Authors ddsketch-agent,https://github.com/DataDog/saluki,Apache-2.0,The ddsketch-agent Authors deranged,https://github.com/jhpratt/deranged,MIT OR Apache-2.0,Jacob Pratt derive_more,https://github.com/JelteF/derive_more,MIT,Jelte Fennema @@ -108,6 +102,13 @@ jobserver,https://github.com/rust-lang/jobserver-rs,MIT OR Apache-2.0,Alex Crich js-sys,https://github.com/rustwasm/wasm-bindgen/tree/master/crates/js-sys,MIT OR Apache-2.0,The wasm-bindgen Developers lazy_static,https://github.com/rust-lang-nursery/lazy-static.rs,MIT OR Apache-2.0,Marvin Löbel libc,https://github.com/rust-lang/libc,MIT OR Apache-2.0,The Rust Project Developers +libdd-common,https://github.com/DataDog/libdatadog/tree/main/datadog-common,Apache-2.0,The libdd-common Authors +libdd-ddsketch,https://github.com/DataDog/libdatadog/tree/main/libdd-ddsketch,Apache-2.0,The libdd-ddsketch Authors +libdd-tinybytes,https://github.com/DataDog/libdatadog/tree/main/libdd-tinybytes,Apache-2.0,The libdd-tinybytes Authors +libdd-trace-normalization,https://github.com/DataDog/libdatadog/tree/main/libdd-trace-normalization,Apache-2.0,David Lee +libdd-trace-protobuf,https://github.com/DataDog/libdatadog/tree/main/libdd-trace-protobuf,Apache-2.0,The libdd-trace-protobuf Authors +libdd-trace-stats,https://github.com/DataDog/libdatadog/tree/main/libdd-trace-stats,Apache-2.0,The libdd-trace-stats Authors +libdd-trace-utils,https://github.com/DataDog/libdatadog/tree/main/libdd-trace-utils,Apache-2.0,The libdd-trace-utils Authors libddwaf,https://github.com/DataDog/libddwaf-rust,Apache-2.0,"DataDog, Inc. " libddwaf-sys,https://github.com/DataDog/libddwaf-rust,Apache-2.0,"DataDog, Inc. " linux-raw-sys,https://github.com/sunfishcode/linux-raw-sys,Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT,Dan Gohman @@ -221,7 +222,6 @@ tikv-jemallocator,https://github.com/tikv/jemallocator,MIT OR Apache-2.0,"Alex C time,https://github.com/time-rs/time,MIT OR Apache-2.0,"Jacob Pratt , Time contributors" time-core,https://github.com/time-rs/time,MIT OR Apache-2.0,"Jacob Pratt , Time contributors" time-macros,https://github.com/time-rs/time,MIT OR Apache-2.0,"Jacob Pratt , Time contributors" -tinybytes,https://github.com/DataDog/libdatadog,Apache-2.0,The tinybytes Authors tinystr,https://github.com/unicode-org/icu4x,Unicode-3.0,The ICU4X Project Developers tinyvec,https://github.com/Lokathor/tinyvec,Zlib OR Apache-2.0 OR MIT,Lokathor tinyvec_macros,https://github.com/Soveu/tinyvec_macros,MIT OR Apache-2.0 OR Zlib,Soveu From 1897e0c76b09708b9f8a2bdbf8b21c6e99a7313c Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Thu, 13 Nov 2025 14:48:14 -0500 Subject: [PATCH 6/7] feat: Support sending trace stats via http proxy --- bottlecap/Cargo.lock | 16 ++++++++-------- bottlecap/Cargo.toml | 12 ++++++------ bottlecap/src/traces/stats_flusher.rs | 10 ++++++++-- bottlecap/src/traces/trace_flusher.rs | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/bottlecap/Cargo.lock b/bottlecap/Cargo.lock index 97b3ec01f..c1142d178 100644 --- a/bottlecap/Cargo.lock +++ b/bottlecap/Cargo.lock @@ -796,7 +796,7 @@ dependencies = [ [[package]] name = "datadog-trace-obfuscation" version = "24.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +source = "git+https://github.com/DataDog/libdatadog?rev=128be247ecf0b80e05305e0aa6d0d59a1b6ae714#128be247ecf0b80e05305e0aa6d0d59a1b6ae714" dependencies = [ "anyhow", "libdd-common", @@ -1828,7 +1828,7 @@ checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "libdd-common" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +source = "git+https://github.com/DataDog/libdatadog?rev=128be247ecf0b80e05305e0aa6d0d59a1b6ae714#128be247ecf0b80e05305e0aa6d0d59a1b6ae714" dependencies = [ "anyhow", "cc", @@ -1861,7 +1861,7 @@ dependencies = [ [[package]] name = "libdd-ddsketch" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +source = "git+https://github.com/DataDog/libdatadog?rev=128be247ecf0b80e05305e0aa6d0d59a1b6ae714#128be247ecf0b80e05305e0aa6d0d59a1b6ae714" dependencies = [ "prost", ] @@ -1869,7 +1869,7 @@ dependencies = [ [[package]] name = "libdd-tinybytes" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +source = "git+https://github.com/DataDog/libdatadog?rev=128be247ecf0b80e05305e0aa6d0d59a1b6ae714#128be247ecf0b80e05305e0aa6d0d59a1b6ae714" dependencies = [ "serde", ] @@ -1877,7 +1877,7 @@ dependencies = [ [[package]] name = "libdd-trace-normalization" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +source = "git+https://github.com/DataDog/libdatadog?rev=128be247ecf0b80e05305e0aa6d0d59a1b6ae714#128be247ecf0b80e05305e0aa6d0d59a1b6ae714" dependencies = [ "anyhow", "libdd-trace-protobuf", @@ -1886,7 +1886,7 @@ dependencies = [ [[package]] name = "libdd-trace-protobuf" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +source = "git+https://github.com/DataDog/libdatadog?rev=128be247ecf0b80e05305e0aa6d0d59a1b6ae714#128be247ecf0b80e05305e0aa6d0d59a1b6ae714" dependencies = [ "prost", "serde", @@ -1896,7 +1896,7 @@ dependencies = [ [[package]] name = "libdd-trace-stats" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +source = "git+https://github.com/DataDog/libdatadog?rev=128be247ecf0b80e05305e0aa6d0d59a1b6ae714#128be247ecf0b80e05305e0aa6d0d59a1b6ae714" dependencies = [ "hashbrown 0.15.4", "libdd-ddsketch", @@ -1907,7 +1907,7 @@ dependencies = [ [[package]] name = "libdd-trace-utils" version = "1.0.0" -source = "git+https://github.com/DataDog/libdatadog?rev=422fae9093ec0b3b1b2638458597a12cc373d00a#422fae9093ec0b3b1b2638458597a12cc373d00a" +source = "git+https://github.com/DataDog/libdatadog?rev=128be247ecf0b80e05305e0aa6d0d59a1b6ae714#128be247ecf0b80e05305e0aa6d0d59a1b6ae714" dependencies = [ "anyhow", "bytes", diff --git a/bottlecap/Cargo.toml b/bottlecap/Cargo.toml index fd742e563..d38e6e0c5 100644 --- a/bottlecap/Cargo.toml +++ b/bottlecap/Cargo.toml @@ -61,12 +61,12 @@ indexmap = {version = "2.11.0", default-features = false} # be found in the clippy.toml file adjacent to this Cargo.toml. datadog-protos = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "c89b58e5784b985819baf11f13f7d35876741222"} ddsketch-agent = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "c89b58e5784b985819baf11f13f7d35876741222"} -libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } -libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } -libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" , features = ["mini_agent"] } -libdd-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } -datadog-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } -libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "422fae9093ec0b3b1b2638458597a12cc373d00a" } +libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "128be247ecf0b80e05305e0aa6d0d59a1b6ae714" } +libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog", rev = "128be247ecf0b80e05305e0aa6d0d59a1b6ae714" } +libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "128be247ecf0b80e05305e0aa6d0d59a1b6ae714" , features = ["mini_agent"] } +libdd-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "128be247ecf0b80e05305e0aa6d0d59a1b6ae714" } +datadog-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "128be247ecf0b80e05305e0aa6d0d59a1b6ae714" } +libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "128be247ecf0b80e05305e0aa6d0d59a1b6ae714" } dogstatsd = { git = "https://github.com/DataDog/serverless-components", rev = "502f005c56b8d51dee95424a9c1404df46e2aae4", default-features = false } datadog-fips = { git = "https://github.com/DataDog/serverless-components", rev = "502f005c56b8d51dee95424a9c1404df46e2aae4", default-features = false } libddwaf = { version = "1.28.1", git = "https://github.com/DataDog/libddwaf-rust", rev = "d1534a158d976bd4f747bf9fcc58e0712d2d17fc", default-features = false, features = ["serde"] } diff --git a/bottlecap/src/traces/stats_flusher.rs b/bottlecap/src/traces/stats_flusher.rs index 6635f9ec4..0994aa005 100644 --- a/bottlecap/src/traces/stats_flusher.rs +++ b/bottlecap/src/traces/stats_flusher.rs @@ -10,12 +10,14 @@ use tokio::sync::OnceCell; use crate::config; use crate::lifecycle::invocation::processor::S_TO_MS; use crate::traces::stats_aggregator::StatsAggregator; +use crate::traces::trace_flusher::ServerlessTraceFlusher; use dogstatsd::api_key::ApiKeyFactory; use libdd_common::Endpoint; use libdd_trace_protobuf::pb; use libdd_trace_utils::{config_utils::trace_stats_url, stats_utils}; use tracing::{debug, error}; + #[async_trait] pub trait StatsFlusher { fn new( @@ -101,9 +103,13 @@ impl StatsFlusher for ServerlessStatsFlusher { let start = std::time::Instant::now(); + let Ok(http_client) = ServerlessTraceFlusher::get_http_client(self.config.proxy_https.as_ref()) else { + error!("STATS_FLUSHER | Failed to create HTTP client"); + return; + }; + let resp = - stats_utils::send_stats_payload(serialized_stats_payload, endpoint, api_key.as_str()) - .await; + stats_utils::send_stats_payload_with_client(serialized_stats_payload, endpoint, api_key.as_str(), Some(&http_client)).await; let elapsed = start.elapsed(); debug!( "Stats request to {} took {} ms", diff --git a/bottlecap/src/traces/trace_flusher.rs b/bottlecap/src/traces/trace_flusher.rs index 6e54f0de9..81cfa10de 100644 --- a/bottlecap/src/traces/trace_flusher.rs +++ b/bottlecap/src/traces/trace_flusher.rs @@ -193,7 +193,7 @@ impl TraceFlusher for ServerlessTraceFlusher { } impl ServerlessTraceFlusher { - fn get_http_client( + pub fn get_http_client( proxy_https: Option<&String>, ) -> Result< GenericHttpClient>, From 68dafbff18032fef73d0600eb4e0f762eedf5b7f Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Thu, 13 Nov 2025 14:50:21 -0500 Subject: [PATCH 7/7] fmt --- bottlecap/src/traces/stats_flusher.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bottlecap/src/traces/stats_flusher.rs b/bottlecap/src/traces/stats_flusher.rs index 0994aa005..404f57b6b 100644 --- a/bottlecap/src/traces/stats_flusher.rs +++ b/bottlecap/src/traces/stats_flusher.rs @@ -17,7 +17,6 @@ use libdd_trace_protobuf::pb; use libdd_trace_utils::{config_utils::trace_stats_url, stats_utils}; use tracing::{debug, error}; - #[async_trait] pub trait StatsFlusher { fn new( @@ -103,13 +102,20 @@ impl StatsFlusher for ServerlessStatsFlusher { let start = std::time::Instant::now(); - let Ok(http_client) = ServerlessTraceFlusher::get_http_client(self.config.proxy_https.as_ref()) else { + let Ok(http_client) = + ServerlessTraceFlusher::get_http_client(self.config.proxy_https.as_ref()) + else { error!("STATS_FLUSHER | Failed to create HTTP client"); return; }; - let resp = - stats_utils::send_stats_payload_with_client(serialized_stats_payload, endpoint, api_key.as_str(), Some(&http_client)).await; + let resp = stats_utils::send_stats_payload_with_client( + serialized_stats_payload, + endpoint, + api_key.as_str(), + Some(&http_client), + ) + .await; let elapsed = start.elapsed(); debug!( "Stats request to {} took {} ms",