From eb03d9c5b8735f344085abb372734defabc0ce04 Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 5 Feb 2026 13:03:44 -0500 Subject: [PATCH 1/9] Move tracer windows named pipe to feature --- crates/datadog-trace-agent/Cargo.toml | 6 ++++++ crates/datadog-trace-agent/src/config.rs | 8 ++++---- crates/datadog-trace-agent/src/mini_agent.rs | 12 ++++++------ crates/datadog-trace-agent/tests/common/helpers.rs | 2 +- crates/datadog-trace-agent/tests/integration_test.rs | 4 ++-- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/crates/datadog-trace-agent/Cargo.toml b/crates/datadog-trace-agent/Cargo.toml index 8a4c871a..c8e4f48c 100644 --- a/crates/datadog-trace-agent/Cargo.toml +++ b/crates/datadog-trace-agent/Cargo.toml @@ -7,6 +7,12 @@ edition.workspace = true [lib] bench = false +[features] +default = [] +# Enable Windows Named Pipes support for the trace agent. +# Only needed for Windows environments. Can be disabled to reduce binary size and dependencies. +windows-pipes = [] + [dependencies] anyhow = "1.0" hyper = { version = "1.6", features = ["http1", "client", "server"] } diff --git a/crates/datadog-trace-agent/src/config.rs b/crates/datadog-trace-agent/src/config.rs index db405222..62cd347d 100644 --- a/crates/datadog-trace-agent/src/config.rs +++ b/crates/datadog-trace-agent/src/config.rs @@ -122,7 +122,7 @@ impl Config { // Windows named pipe name for APM receiver. // Normalize by adding \\.\pipe\ prefix if not present let dd_apm_windows_pipe_name: Option = { - #[cfg(any(windows, test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] { env::var("DD_APM_WINDOWS_PIPE_NAME").ok().map(|pipe_name| { if pipe_name.starts_with("\\\\.\\pipe\\") || pipe_name.starts_with(r"\\.\pipe\") @@ -133,7 +133,7 @@ impl Config { } }) } - #[cfg(not(any(windows, test)))] + #[cfg(not(any(all(windows, feature = "windows-pipes"), test)))] { None } @@ -148,7 +148,7 @@ impl Config { }; let dd_dogstatsd_windows_pipe_name: Option = { - #[cfg(any(windows, test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] { env::var("DD_DOGSTATSD_WINDOWS_PIPE_NAME") .ok() @@ -162,7 +162,7 @@ impl Config { } }) } - #[cfg(not(any(windows, test)))] + #[cfg(not(any(all(windows, feature = "windows-pipes"), test)))] { None } diff --git a/crates/datadog-trace-agent/src/mini_agent.rs b/crates/datadog-trace-agent/src/mini_agent.rs index 7e7cef12..f8691aa1 100644 --- a/crates/datadog-trace-agent/src/mini_agent.rs +++ b/crates/datadog-trace-agent/src/mini_agent.rs @@ -16,7 +16,7 @@ use tracing::{debug, error}; use crate::http_utils::{log_and_create_http_response, verify_request_content_length}; use crate::proxy_flusher::{ProxyFlusher, ProxyRequest}; -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] use tokio::net::windows::named_pipe::ServerOptions; use crate::{config, env_verifier, stats_flusher, stats_processor, trace_flusher, trace_processor}; @@ -144,7 +144,7 @@ impl MiniAgent { if let Some(ref pipe_name) = self.config.dd_apm_windows_pipe_name { // Windows named pipe transport - #[cfg(windows)] + #[cfg(all(windows, feature = "windows-pipes"))] { Self::serve_named_pipe( pipe_name, @@ -155,13 +155,13 @@ impl MiniAgent { .await?; } - #[cfg(not(windows))] + #[cfg(not(all(windows, feature = "windows-pipes")))] { error!( - "Named pipes are only supported on Windows, cannot use pipe: {}", + "Named pipes require the 'windows-pipes' feature to be enabled. Cannot use pipe: {}", pipe_name ); - return Err("Named pipes are only supported on Windows".into()); + return Err("Named pipes require the 'windows-pipes' feature".into()); } } else { // TCP transport @@ -250,7 +250,7 @@ impl MiniAgent { } } - #[cfg(windows)] + #[cfg(all(windows, feature = "windows-pipes"))] async fn serve_named_pipe( pipe_name: &str, service: S, diff --git a/crates/datadog-trace-agent/tests/common/helpers.rs b/crates/datadog-trace-agent/tests/common/helpers.rs index a41cf055..6f6e776f 100644 --- a/crates/datadog-trace-agent/tests/common/helpers.rs +++ b/crates/datadog-trace-agent/tests/common/helpers.rs @@ -55,7 +55,7 @@ pub async fn send_tcp_request( Ok(response) } -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] /// Send an HTTP request over named pipe and return the response pub async fn send_named_pipe_request( pipe_name: &str, diff --git a/crates/datadog-trace-agent/tests/integration_test.rs b/crates/datadog-trace-agent/tests/integration_test.rs index 62d632ed..710b5cf6 100644 --- a/crates/datadog-trace-agent/tests/integration_test.rs +++ b/crates/datadog-trace-agent/tests/integration_test.rs @@ -16,7 +16,7 @@ use serde_json::Value; use std::sync::Arc; use std::time::Duration; -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] use common::helpers::send_named_pipe_request; /// Create a test config with TCP transport @@ -138,7 +138,7 @@ async fn test_mini_agent_tcp_handles_requests() { agent_handle.abort(); } -#[cfg(all(test, windows))] +#[cfg(all(test, windows, feature = "windows-pipes"))] #[tokio::test] async fn test_mini_agent_named_pipe_handles_requests() { // Use just the pipe name without \\.\pipe\ prefix, matching datadog-agent behavior From 3e43c6632d3efb525e21fca55ccfaa3bf002087f Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 5 Feb 2026 13:11:19 -0500 Subject: [PATCH 2/9] Move dogstatsd windows named pipe to feature --- crates/dogstatsd/Cargo.toml | 3 +++ crates/dogstatsd/src/dogstatsd.rs | 18 +++++++++--------- crates/dogstatsd/tests/integration_test.rs | 10 +++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/dogstatsd/Cargo.toml b/crates/dogstatsd/Cargo.toml index 4ec6e09d..596c690e 100644 --- a/crates/dogstatsd/Cargo.toml +++ b/crates/dogstatsd/Cargo.toml @@ -35,3 +35,6 @@ tracing-test = { version = "0.2.5", default-features = false } [features] default = [ "reqwest/rustls-tls" ] fips = [ "reqwest/rustls-tls-no-provider", "datadog-fips/fips" ] +# Enable Windows Named Pipes support for DogStatsD. +# Only needed for Windows environments. Can be disabled to reduce binary size and dependencies. +windows-pipes = [] diff --git a/crates/dogstatsd/src/dogstatsd.rs b/crates/dogstatsd/src/dogstatsd.rs index a7faa2c7..5bb7f5d9 100644 --- a/crates/dogstatsd/src/dogstatsd.rs +++ b/crates/dogstatsd/src/dogstatsd.rs @@ -16,7 +16,7 @@ use crate::metric::{id, parse, Metric}; use tracing::{debug, error, trace}; // Windows-specific imports -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] use { std::sync::Arc, tokio::io::AsyncReadExt, @@ -47,7 +47,7 @@ pub enum MessageSource { /// Message received from a network socket (UDP) Network(SocketAddr), /// Message received from a Windows named pipe (Arc for efficient cloning) - #[cfg(windows)] + #[cfg(all(windows, feature = "windows-pipes"))] NamedPipe(Arc), } @@ -55,7 +55,7 @@ impl std::fmt::Display for MessageSource { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Network(addr) => write!(f, "{}", addr), - #[cfg(windows)] + #[cfg(all(windows, feature = "windows-pipes"))] Self::NamedPipe(name) => write!(f, "{}", name), } } @@ -71,7 +71,7 @@ enum BufferReader { MirrorTest(Vec, SocketAddr), /// Windows named pipe reader (Windows-only transport) - #[cfg(windows)] + #[cfg(all(windows, feature = "windows-pipes"))] NamedPipe { pipe_name: Arc, receiver: Arc>>>, @@ -98,7 +98,7 @@ impl BufferReader { // Mirror Reader: returns immediately with stored data Ok((data.clone(), MessageSource::Network(*socket))) } - #[cfg(windows)] + #[cfg(all(windows, feature = "windows-pipes"))] BufferReader::NamedPipe { pipe_name, receiver, @@ -137,7 +137,7 @@ impl DogStatsD { ) -> DogStatsD { #[allow(unused_variables)] // pipe_name unused on non-Windows let buffer_reader = if let Some(ref pipe_name) = config.windows_pipe_name { - #[cfg(windows)] + #[cfg(all(windows, feature = "windows-pipes"))] { let pipe_name = Arc::new(pipe_name.clone()); @@ -157,10 +157,10 @@ impl DogStatsD { receiver, } } - #[cfg(not(windows))] + #[cfg(not(all(windows, feature = "windows-pipes")))] #[allow(clippy::panic)] { - panic!("Named pipes are only supported on Windows.") + panic!("Named pipes require the 'windows-pipes' feature to be enabled.") } } else { // UDP socket for all platforms @@ -265,7 +265,7 @@ impl DogStatsD { /// Uses a multi-instance approach (like winio in the main agent): /// - Creates new server instance for each client /// - Spawns task to handle each client -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] async fn run_named_pipe_server( pipe_name: Arc, sender: tokio::sync::mpsc::UnboundedSender>, diff --git a/crates/dogstatsd/tests/integration_test.rs b/crates/dogstatsd/tests/integration_test.rs index 90130e79..4b8a6aa9 100644 --- a/crates/dogstatsd/tests/integration_test.rs +++ b/crates/dogstatsd/tests/integration_test.rs @@ -20,7 +20,7 @@ use tokio::{ use tokio_util::sync::CancellationToken; use zstd::zstd_safe::CompressionLevel; -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] use tokio::{io::AsyncWriteExt, net::windows::named_pipe::ClientOptions}; #[cfg(test)] @@ -286,7 +286,7 @@ async fn test_send_with_retry_immediate_failure_after_one_attempt() { } #[cfg(test)] -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] #[tokio::test] async fn test_named_pipe_basic_communication() { let pipe_name = r"\\.\pipe\test_dogstatsd_basic"; @@ -340,7 +340,7 @@ async fn test_named_pipe_basic_communication() { } #[cfg(test)] -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] #[tokio::test] async fn test_named_pipe_disconnect_reconnect() { let pipe_name = r"\\.\pipe\test_dogstatsd_reconnect"; @@ -409,7 +409,7 @@ async fn test_named_pipe_disconnect_reconnect() { } #[cfg(test)] -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] #[tokio::test] async fn test_named_pipe_cancellation() { let pipe_name = r"\\.\pipe\test_dogstatsd_cancel"; @@ -452,7 +452,7 @@ async fn test_named_pipe_cancellation() { } #[cfg(test)] -#[cfg(windows)] +#[cfg(all(windows, feature = "windows-pipes"))] #[tokio::test] async fn test_buffer_split_message() { let pipe_name = r"\\.\pipe\test_dogstatsd_buffer_split"; From f9339cde28122f1c5c280b80175a6db69e37ec8b Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 5 Feb 2026 13:14:33 -0500 Subject: [PATCH 3/9] Keep named pipes for windows builds --- .github/workflows/build-datadog-serverless-compat.yml | 2 +- crates/datadog-serverless-compat/Cargo.toml | 6 ++++++ crates/datadog-serverless-compat/src/main.rs | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-datadog-serverless-compat.yml b/.github/workflows/build-datadog-serverless-compat.yml index 46643766..13d18ee6 100644 --- a/.github/workflows/build-datadog-serverless-compat.yml +++ b/.github/workflows/build-datadog-serverless-compat.yml @@ -45,7 +45,7 @@ jobs: retention-days: 3 - if: ${{ inputs.runner == 'windows-2022' }} shell: bash - run: cargo build --release -p datadog-serverless-compat + run: cargo build --release -p datadog-serverless-compat --features windows-pipes - if: ${{ inputs.runner == 'windows-2022' }} uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 4.6.2 with: diff --git a/crates/datadog-serverless-compat/Cargo.toml b/crates/datadog-serverless-compat/Cargo.toml index 4483d949..bb997852 100644 --- a/crates/datadog-serverless-compat/Cargo.toml +++ b/crates/datadog-serverless-compat/Cargo.toml @@ -5,6 +5,12 @@ edition.workspace = true license.workspace = true description = "Binary to run trace-agent and dogstatsd servers in Serverless environments" +[features] +default = [] +# Enable Windows Named Pipes support for both trace agent and dogstatsd. +# Only needed for Windows environments. +windows-pipes = ["datadog-trace-agent/windows-pipes", "dogstatsd/windows-pipes"] + [dependencies] datadog-trace-agent = { path = "../datadog-trace-agent" } libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "660c550b6311a209d9cf7de762e54b6b7109bcdb" } diff --git a/crates/datadog-serverless-compat/src/main.rs b/crates/datadog-serverless-compat/src/main.rs index adc106e7..c219660d 100644 --- a/crates/datadog-serverless-compat/src/main.rs +++ b/crates/datadog-serverless-compat/src/main.rs @@ -69,7 +69,7 @@ pub async fn main() { // Windows named pipe name for DogStatsD. // Normalize by adding \\.\pipe\ prefix if not present let dd_dogstatsd_windows_pipe_name: Option = { - #[cfg(windows)] + #[cfg(all(windows, feature = "windows-pipes"))] { env::var("DD_DOGSTATSD_WINDOWS_PIPE_NAME") .ok() @@ -82,7 +82,7 @@ pub async fn main() { } }) } - #[cfg(not(windows))] + #[cfg(not(all(windows, feature = "windows-pipes")))] { None } From d288ea60d35a807980f6cf6da8707d42b30136e6 Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 5 Feb 2026 13:24:37 -0500 Subject: [PATCH 4/9] Make tokio features for named pipes also optional --- crates/dogstatsd/Cargo.toml | 5 +++-- crates/dogstatsd/src/dogstatsd.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/dogstatsd/Cargo.toml b/crates/dogstatsd/Cargo.toml index 596c690e..d25b0b9a 100644 --- a/crates/dogstatsd/Cargo.toml +++ b/crates/dogstatsd/Cargo.toml @@ -19,7 +19,7 @@ reqwest = { version = "0.12.4", features = ["json", "http2"], default-features = serde = { version = "1.0.197", default-features = false, features = ["derive"] } serde_json = { version = "1.0.116", default-features = false, features = ["alloc"] } thiserror = { version = "1.0.58", default-features = false } -tokio = { version = "1.37.0", default-features = false, features = ["macros", "rt-multi-thread", "net", "io-util"] } +tokio = { version = "1.37.0", default-features = false, features = ["macros", "rt-multi-thread", "net"] } tokio-util = { version = "0.7.11", default-features = false } tracing = { version = "0.1.40", default-features = false } regex = { version = "1.10.6", default-features = false } @@ -37,4 +37,5 @@ default = [ "reqwest/rustls-tls" ] fips = [ "reqwest/rustls-tls-no-provider", "datadog-fips/fips" ] # Enable Windows Named Pipes support for DogStatsD. # Only needed for Windows environments. Can be disabled to reduce binary size and dependencies. -windows-pipes = [] +# This feature adds tokio's io-util for AsyncReadExt, which is only used for reading from named pipes. +windows-pipes = ["tokio/io-util"] diff --git a/crates/dogstatsd/src/dogstatsd.rs b/crates/dogstatsd/src/dogstatsd.rs index 5bb7f5d9..126ad8e1 100644 --- a/crates/dogstatsd/src/dogstatsd.rs +++ b/crates/dogstatsd/src/dogstatsd.rs @@ -20,7 +20,7 @@ use tracing::{debug, error, trace}; use { std::sync::Arc, tokio::io::AsyncReadExt, - tokio::net::windows::named_pipe::{ClientOptions, ServerOptions}, + tokio::net::windows::named_pipe::ServerOptions, }; // DogStatsD buffer size for receiving metrics From 58b6166581a79123bd2a7a0ca817659ad533fae2 Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 5 Feb 2026 13:30:22 -0500 Subject: [PATCH 5/9] Improve error log/comments --- crates/datadog-serverless-compat/Cargo.toml | 2 -- crates/datadog-trace-agent/Cargo.toml | 2 -- crates/datadog-trace-agent/src/mini_agent.rs | 4 ++-- crates/dogstatsd/Cargo.toml | 3 --- crates/dogstatsd/src/dogstatsd.rs | 8 ++------ 5 files changed, 4 insertions(+), 15 deletions(-) diff --git a/crates/datadog-serverless-compat/Cargo.toml b/crates/datadog-serverless-compat/Cargo.toml index bb997852..b331e92f 100644 --- a/crates/datadog-serverless-compat/Cargo.toml +++ b/crates/datadog-serverless-compat/Cargo.toml @@ -7,8 +7,6 @@ description = "Binary to run trace-agent and dogstatsd servers in Serverless env [features] default = [] -# Enable Windows Named Pipes support for both trace agent and dogstatsd. -# Only needed for Windows environments. windows-pipes = ["datadog-trace-agent/windows-pipes", "dogstatsd/windows-pipes"] [dependencies] diff --git a/crates/datadog-trace-agent/Cargo.toml b/crates/datadog-trace-agent/Cargo.toml index c8e4f48c..85daf48e 100644 --- a/crates/datadog-trace-agent/Cargo.toml +++ b/crates/datadog-trace-agent/Cargo.toml @@ -9,8 +9,6 @@ bench = false [features] default = [] -# Enable Windows Named Pipes support for the trace agent. -# Only needed for Windows environments. Can be disabled to reduce binary size and dependencies. windows-pipes = [] [dependencies] diff --git a/crates/datadog-trace-agent/src/mini_agent.rs b/crates/datadog-trace-agent/src/mini_agent.rs index f8691aa1..6f214095 100644 --- a/crates/datadog-trace-agent/src/mini_agent.rs +++ b/crates/datadog-trace-agent/src/mini_agent.rs @@ -158,10 +158,10 @@ impl MiniAgent { #[cfg(not(all(windows, feature = "windows-pipes")))] { error!( - "Named pipes require the 'windows-pipes' feature to be enabled. Cannot use pipe: {}", + "Named pipes are only supported on Windows and require the windows-pipes feature to be enabled. Cannot use pipe: {}", pipe_name ); - return Err("Named pipes require the 'windows-pipes' feature".into()); + return Err("Named pipes are only supported on Windows and require the windows-pipes feature".into()); } } else { // TCP transport diff --git a/crates/dogstatsd/Cargo.toml b/crates/dogstatsd/Cargo.toml index d25b0b9a..9ef8ccc0 100644 --- a/crates/dogstatsd/Cargo.toml +++ b/crates/dogstatsd/Cargo.toml @@ -35,7 +35,4 @@ tracing-test = { version = "0.2.5", default-features = false } [features] default = [ "reqwest/rustls-tls" ] fips = [ "reqwest/rustls-tls-no-provider", "datadog-fips/fips" ] -# Enable Windows Named Pipes support for DogStatsD. -# Only needed for Windows environments. Can be disabled to reduce binary size and dependencies. -# This feature adds tokio's io-util for AsyncReadExt, which is only used for reading from named pipes. windows-pipes = ["tokio/io-util"] diff --git a/crates/dogstatsd/src/dogstatsd.rs b/crates/dogstatsd/src/dogstatsd.rs index 126ad8e1..3f53f158 100644 --- a/crates/dogstatsd/src/dogstatsd.rs +++ b/crates/dogstatsd/src/dogstatsd.rs @@ -17,11 +17,7 @@ use tracing::{debug, error, trace}; // Windows-specific imports #[cfg(all(windows, feature = "windows-pipes"))] -use { - std::sync::Arc, - tokio::io::AsyncReadExt, - tokio::net::windows::named_pipe::ServerOptions, -}; +use {std::sync::Arc, tokio::io::AsyncReadExt, tokio::net::windows::named_pipe::ServerOptions}; // DogStatsD buffer size for receiving metrics // TODO(astuyve) buf should be dynamic @@ -160,7 +156,7 @@ impl DogStatsD { #[cfg(not(all(windows, feature = "windows-pipes")))] #[allow(clippy::panic)] { - panic!("Named pipes require the 'windows-pipes' feature to be enabled.") + panic!("Named pipes are only supported on Windows and require the windows-pipes feature to be enabled.") } } else { // UDP socket for all platforms From bd46b6e1edf275997a4f5ac67c422c2d3a51b5cb Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 5 Feb 2026 13:42:53 -0500 Subject: [PATCH 6/9] Move windows named pipe param behind feature/os conditional --- crates/datadog-serverless-compat/src/main.rs | 4 +++- crates/dogstatsd/src/dogstatsd.rs | 16 +++++++++++----- crates/dogstatsd/tests/integration_test.rs | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/datadog-serverless-compat/src/main.rs b/crates/datadog-serverless-compat/src/main.rs index c219660d..3a2aceb7 100644 --- a/crates/datadog-serverless-compat/src/main.rs +++ b/crates/datadog-serverless-compat/src/main.rs @@ -178,6 +178,7 @@ pub async fn main() { https_proxy, dogstatsd_tags, dd_statsd_metric_namespace, + #[cfg(feature = "windows-pipes")] dd_dogstatsd_windows_pipe_name.clone(), ) .await; @@ -212,7 +213,7 @@ async fn start_dogstatsd( https_proxy: Option, dogstatsd_tags: &str, metric_namespace: Option, - windows_pipe_name: Option, + #[cfg(feature = "windows-pipes")] windows_pipe_name: Option, ) -> (CancellationToken, Option, AggregatorHandle) { // 1. Create the aggregator service #[allow(clippy::expect_used)] @@ -229,6 +230,7 @@ async fn start_dogstatsd( host: AGENT_HOST.to_string(), port, metric_namespace, + #[cfg(feature = "windows-pipes")] windows_pipe_name, }; let dogstatsd_cancel_token = tokio_util::sync::CancellationToken::new(); diff --git a/crates/dogstatsd/src/dogstatsd.rs b/crates/dogstatsd/src/dogstatsd.rs index 3f53f158..56fd713f 100644 --- a/crates/dogstatsd/src/dogstatsd.rs +++ b/crates/dogstatsd/src/dogstatsd.rs @@ -34,6 +34,7 @@ pub struct DogStatsDConfig { /// Optional namespace to prepend to all metric names (e.g., "myapp") pub metric_namespace: Option, /// Optional Windows named pipe name. (e.g., "\\\\.\\pipe\\my_pipe"). + #[cfg(feature = "windows-pipes")] pub windows_pipe_name: Option, } @@ -131,11 +132,17 @@ impl DogStatsD { aggregator_handle: AggregatorHandle, cancel_token: tokio_util::sync::CancellationToken, ) -> DogStatsD { - #[allow(unused_variables)] // pipe_name unused on non-Windows - let buffer_reader = if let Some(ref pipe_name) = config.windows_pipe_name { + // Determine if we should use a named pipe or UDP/UDS + #[cfg(all(windows, feature = "windows-pipes"))] + let use_named_pipe = config.windows_pipe_name.is_some(); + #[cfg(not(all(windows, feature = "windows-pipes")))] + let use_named_pipe = false; + + let buffer_reader = if use_named_pipe { + // Windows named pipe transport #[cfg(all(windows, feature = "windows-pipes"))] { - let pipe_name = Arc::new(pipe_name.clone()); + let pipe_name = Arc::new(config.windows_pipe_name.as_ref().unwrap().clone()); // Create channel for receiving data from client handlers let (sender, receiver) = tokio::sync::mpsc::unbounded_channel(); @@ -154,9 +161,8 @@ impl DogStatsD { } } #[cfg(not(all(windows, feature = "windows-pipes")))] - #[allow(clippy::panic)] { - panic!("Named pipes are only supported on Windows and require the windows-pipes feature to be enabled.") + unreachable!("Named pipe flag should never be true without the feature") } } else { // UDP socket for all platforms diff --git a/crates/dogstatsd/tests/integration_test.rs b/crates/dogstatsd/tests/integration_test.rs index 4b8a6aa9..b9827b50 100644 --- a/crates/dogstatsd/tests/integration_test.rs +++ b/crates/dogstatsd/tests/integration_test.rs @@ -100,6 +100,7 @@ async fn start_dogstatsd(aggregator_handle: AggregatorHandle) -> CancellationTok host: "127.0.0.1".to_string(), port: 18125, metric_namespace: None, + #[cfg(feature = "windows-pipes")] windows_pipe_name: None, }; let dogstatsd_cancel_token = tokio_util::sync::CancellationToken::new(); From c9f6a919e112be037d84900e7b0c835a48b1dc28 Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 5 Feb 2026 14:35:46 -0500 Subject: [PATCH 7/9] Move tracer windows pipe name behind feature macro --- crates/datadog-trace-agent/src/config.rs | 7 +++++++ crates/datadog-trace-agent/src/mini_agent.rs | 21 ++++++++++++------- .../src/trace_processor.rs | 2 ++ .../tests/integration_test.rs | 7 ++++++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/crates/datadog-trace-agent/src/config.rs b/crates/datadog-trace-agent/src/config.rs index 62cd347d..21d21fe9 100644 --- a/crates/datadog-trace-agent/src/config.rs +++ b/crates/datadog-trace-agent/src/config.rs @@ -81,8 +81,10 @@ impl Tags { pub struct Config { pub dd_site: String, pub dd_apm_receiver_port: u16, + #[cfg(feature = "windows-pipes")] pub dd_apm_windows_pipe_name: Option, pub dd_dogstatsd_port: u16, + #[cfg(feature = "windows-pipes")] pub dd_dogstatsd_windows_pipe_name: Option, pub env_type: trace_utils::EnvironmentType, pub app_name: Option, @@ -223,8 +225,10 @@ impl Config { proxy_request_retry_backoff_base_ms: 100, verify_env_timeout_ms: 100, dd_apm_receiver_port, + #[cfg(feature = "windows-pipes")] dd_apm_windows_pipe_name, dd_dogstatsd_port, + #[cfg(feature = "windows-pipes")] dd_dogstatsd_windows_pipe_name, dd_site, trace_intake: Endpoint { @@ -378,6 +382,7 @@ mod tests { #[test] #[serial] + #[cfg(feature = "windows-pipes")] fn test_apm_windows_pipe_name() { env::set_var("DD_API_KEY", "_not_a_real_key_"); env::set_var("ASCSVCRT_SPRING__APPLICATION__NAME", "test-spring-app"); @@ -399,6 +404,7 @@ mod tests { #[test] #[serial] + #[cfg(feature = "windows-pipes")] fn test_dogstatsd_windows_pipe_name() { env::set_var("DD_API_KEY", "_not_a_real_key_"); env::set_var("ASCSVCRT_SPRING__APPLICATION__NAME", "test-spring-app"); @@ -456,6 +462,7 @@ mod tests { assert!(config_res.is_ok()); let config = config_res.unwrap(); assert_eq!(config.dd_apm_receiver_port, 8126); + #[cfg(feature = "windows-pipes")] assert_eq!(config.dd_apm_windows_pipe_name, None); env::remove_var("DD_API_KEY"); env::remove_var("ASCSVCRT_SPRING__APPLICATION__NAME"); diff --git a/crates/datadog-trace-agent/src/mini_agent.rs b/crates/datadog-trace-agent/src/mini_agent.rs index 6f214095..b5005944 100644 --- a/crates/datadog-trace-agent/src/mini_agent.rs +++ b/crates/datadog-trace-agent/src/mini_agent.rs @@ -129,7 +129,12 @@ impl MiniAgent { }); // Determine which transport to use based on configuration - if let Some(ref pipe_name) = self.config.dd_apm_windows_pipe_name { + #[cfg(feature = "windows-pipes")] + let pipe_name_opt = self.config.dd_apm_windows_pipe_name.as_ref(); + #[cfg(not(feature = "windows-pipes"))] + let pipe_name_opt: Option<&String> = None; + + if let Some(pipe_name) = pipe_name_opt { debug!("Mini Agent started: listening on named pipe {}", pipe_name); } else { debug!( @@ -142,26 +147,23 @@ impl MiniAgent { now.elapsed().as_millis() ); - if let Some(ref pipe_name) = self.config.dd_apm_windows_pipe_name { + if let Some(_pipe_name) = pipe_name_opt { // Windows named pipe transport #[cfg(all(windows, feature = "windows-pipes"))] { Self::serve_named_pipe( - pipe_name, + _pipe_name, service, trace_flusher_handle, stats_flusher_handle, ) .await?; } - #[cfg(not(all(windows, feature = "windows-pipes")))] { - error!( - "Named pipes are only supported on Windows and require the windows-pipes feature to be enabled. Cannot use pipe: {}", - pipe_name + unreachable!( + "Named pipe flag should never be true without the feature and Windows" ); - return Err("Named pipes are only supported on Windows and require the windows-pipes feature".into()); } } else { // TCP transport @@ -386,7 +388,10 @@ impl MiniAgent { } (_, INFO_ENDPOINT_PATH) => match Self::info_handler( config.dd_apm_receiver_port, + #[cfg(feature = "windows-pipes")] config.dd_apm_windows_pipe_name.as_deref(), + #[cfg(not(feature = "windows-pipes"))] + None, config.dd_dogstatsd_port, ) { Ok(res) => Ok(res), diff --git a/crates/datadog-trace-agent/src/trace_processor.rs b/crates/datadog-trace-agent/src/trace_processor.rs index f9d796cc..2f91aacb 100644 --- a/crates/datadog-trace-agent/src/trace_processor.rs +++ b/crates/datadog-trace-agent/src/trace_processor.rs @@ -204,8 +204,10 @@ mod tests { }, dd_site: "datadoghq.com".to_string(), dd_apm_receiver_port: 8126, + #[cfg(feature = "windows-pipes")] dd_apm_windows_pipe_name: None, dd_dogstatsd_port: 8125, + #[cfg(feature = "windows-pipes")] dd_dogstatsd_windows_pipe_name: None, env_type: trace_utils::EnvironmentType::CloudFunction, os: "linux".to_string(), diff --git a/crates/datadog-trace-agent/tests/integration_test.rs b/crates/datadog-trace-agent/tests/integration_test.rs index 710b5cf6..05f5ca69 100644 --- a/crates/datadog-trace-agent/tests/integration_test.rs +++ b/crates/datadog-trace-agent/tests/integration_test.rs @@ -24,8 +24,10 @@ pub fn create_tcp_test_config() -> Config { Config { dd_site: "mock-datadoghq.com".to_string(), dd_apm_receiver_port: 8126, + #[cfg(feature = "windows-pipes")] dd_apm_windows_pipe_name: None, dd_dogstatsd_port: 8125, + #[cfg(feature = "windows-pipes")] dd_dogstatsd_windows_pipe_name: None, env_type: trace_utils::EnvironmentType::AzureFunction, app_name: Some("test-app".to_string()), @@ -145,7 +147,10 @@ async fn test_mini_agent_named_pipe_handles_requests() { let pipe_name = "dd_trace_integration_test"; let pipe_path = format!(r"\\.\pipe\{}", pipe_name); // Full path for client connections let mut config = create_tcp_test_config(); - config.dd_apm_windows_pipe_name = Some(pipe_path.clone()); + #[cfg(feature = "windows-pipes")] + { + config.dd_apm_windows_pipe_name = Some(pipe_path.clone()); + } config.dd_apm_receiver_port = 0; let config = Arc::new(config); From a840fc2440c2bbb956d32062760ca63b06254b2a Mon Sep 17 00:00:00 2001 From: Lewis Date: Thu, 5 Feb 2026 15:22:25 -0500 Subject: [PATCH 8/9] Clippy fixes and consistency in pipe name cfg conditionals --- crates/datadog-trace-agent/src/config.rs | 14 +++++++------- crates/datadog-trace-agent/src/mini_agent.rs | 11 ++++++----- crates/datadog-trace-agent/src/trace_processor.rs | 4 ++-- .../datadog-trace-agent/tests/integration_test.rs | 5 +---- crates/dogstatsd/src/dogstatsd.rs | 11 ++++++----- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/crates/datadog-trace-agent/src/config.rs b/crates/datadog-trace-agent/src/config.rs index 21d21fe9..ffa9fced 100644 --- a/crates/datadog-trace-agent/src/config.rs +++ b/crates/datadog-trace-agent/src/config.rs @@ -81,10 +81,10 @@ impl Tags { pub struct Config { pub dd_site: String, pub dd_apm_receiver_port: u16, - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] pub dd_apm_windows_pipe_name: Option, pub dd_dogstatsd_port: u16, - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] pub dd_dogstatsd_windows_pipe_name: Option, pub env_type: trace_utils::EnvironmentType, pub app_name: Option, @@ -225,10 +225,10 @@ impl Config { proxy_request_retry_backoff_base_ms: 100, verify_env_timeout_ms: 100, dd_apm_receiver_port, - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] dd_apm_windows_pipe_name, dd_dogstatsd_port, - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] dd_dogstatsd_windows_pipe_name, dd_site, trace_intake: Endpoint { @@ -382,7 +382,7 @@ mod tests { #[test] #[serial] - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] fn test_apm_windows_pipe_name() { env::set_var("DD_API_KEY", "_not_a_real_key_"); env::set_var("ASCSVCRT_SPRING__APPLICATION__NAME", "test-spring-app"); @@ -404,7 +404,7 @@ mod tests { #[test] #[serial] - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] fn test_dogstatsd_windows_pipe_name() { env::set_var("DD_API_KEY", "_not_a_real_key_"); env::set_var("ASCSVCRT_SPRING__APPLICATION__NAME", "test-spring-app"); @@ -462,7 +462,7 @@ mod tests { assert!(config_res.is_ok()); let config = config_res.unwrap(); assert_eq!(config.dd_apm_receiver_port, 8126); - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] assert_eq!(config.dd_apm_windows_pipe_name, None); env::remove_var("DD_API_KEY"); env::remove_var("ASCSVCRT_SPRING__APPLICATION__NAME"); diff --git a/crates/datadog-trace-agent/src/mini_agent.rs b/crates/datadog-trace-agent/src/mini_agent.rs index b5005944..9db9b8a2 100644 --- a/crates/datadog-trace-agent/src/mini_agent.rs +++ b/crates/datadog-trace-agent/src/mini_agent.rs @@ -129,9 +129,9 @@ impl MiniAgent { }); // Determine which transport to use based on configuration - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] let pipe_name_opt = self.config.dd_apm_windows_pipe_name.as_ref(); - #[cfg(not(feature = "windows-pipes"))] + #[cfg(not(any(feature = "windows-pipes", test)))] let pipe_name_opt: Option<&String> = None; if let Some(pipe_name) = pipe_name_opt { @@ -147,12 +147,12 @@ impl MiniAgent { now.elapsed().as_millis() ); - if let Some(_pipe_name) = pipe_name_opt { + if let Some(pipe_name) = pipe_name_opt { // Windows named pipe transport #[cfg(all(windows, feature = "windows-pipes"))] { Self::serve_named_pipe( - _pipe_name, + pipe_name, service, trace_flusher_handle, stats_flusher_handle, @@ -161,6 +161,7 @@ impl MiniAgent { } #[cfg(not(all(windows, feature = "windows-pipes")))] { + let _ = pipe_name; // Suppress unused variable warning unreachable!( "Named pipe flag should never be true without the feature and Windows" ); @@ -277,7 +278,7 @@ impl MiniAgent { loop { // Create a new pipe instance - let pipe = match ServerOptions::new().create(&pipe_path) { + let pipe = match ServerOptions::new().create(pipe_path) { Ok(pipe) => { debug!("Created pipe server instance '{}' in byte mode", pipe_path); pipe diff --git a/crates/datadog-trace-agent/src/trace_processor.rs b/crates/datadog-trace-agent/src/trace_processor.rs index 2f91aacb..447258a4 100644 --- a/crates/datadog-trace-agent/src/trace_processor.rs +++ b/crates/datadog-trace-agent/src/trace_processor.rs @@ -204,10 +204,10 @@ mod tests { }, dd_site: "datadoghq.com".to_string(), dd_apm_receiver_port: 8126, - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] dd_apm_windows_pipe_name: None, dd_dogstatsd_port: 8125, - #[cfg(feature = "windows-pipes")] + #[cfg(any(feature = "windows-pipes", test))] dd_dogstatsd_windows_pipe_name: None, env_type: trace_utils::EnvironmentType::CloudFunction, os: "linux".to_string(), diff --git a/crates/datadog-trace-agent/tests/integration_test.rs b/crates/datadog-trace-agent/tests/integration_test.rs index 05f5ca69..0cba339c 100644 --- a/crates/datadog-trace-agent/tests/integration_test.rs +++ b/crates/datadog-trace-agent/tests/integration_test.rs @@ -147,10 +147,7 @@ async fn test_mini_agent_named_pipe_handles_requests() { let pipe_name = "dd_trace_integration_test"; let pipe_path = format!(r"\\.\pipe\{}", pipe_name); // Full path for client connections let mut config = create_tcp_test_config(); - #[cfg(feature = "windows-pipes")] - { - config.dd_apm_windows_pipe_name = Some(pipe_path.clone()); - } + config.dd_apm_windows_pipe_name = Some(pipe_path.clone()); config.dd_apm_receiver_port = 0; let config = Arc::new(config); diff --git a/crates/dogstatsd/src/dogstatsd.rs b/crates/dogstatsd/src/dogstatsd.rs index 56fd713f..fca6ee41 100644 --- a/crates/dogstatsd/src/dogstatsd.rs +++ b/crates/dogstatsd/src/dogstatsd.rs @@ -134,15 +134,15 @@ impl DogStatsD { ) -> DogStatsD { // Determine if we should use a named pipe or UDP/UDS #[cfg(all(windows, feature = "windows-pipes"))] - let use_named_pipe = config.windows_pipe_name.is_some(); + let pipe_name_opt = config.windows_pipe_name.as_ref(); #[cfg(not(all(windows, feature = "windows-pipes")))] - let use_named_pipe = false; + let pipe_name_opt: Option<&String> = None; - let buffer_reader = if use_named_pipe { + let buffer_reader = if let Some(pipe_name_ref) = pipe_name_opt { // Windows named pipe transport #[cfg(all(windows, feature = "windows-pipes"))] { - let pipe_name = Arc::new(config.windows_pipe_name.as_ref().unwrap().clone()); + let pipe_name = Arc::new(pipe_name_ref.clone()); // Create channel for receiving data from client handlers let (sender, receiver) = tokio::sync::mpsc::unbounded_channel(); @@ -162,6 +162,7 @@ impl DogStatsD { } #[cfg(not(all(windows, feature = "windows-pipes")))] { + let _ = pipe_name_ref; // Suppress unused variable warning unreachable!("Named pipe flag should never be true without the feature") } } else { @@ -352,7 +353,7 @@ async fn run_named_pipe_server( break; } Ok(_) => { - if let Ok(_) = std::str::from_utf8(&buf[..complete_message_size]) { + if std::str::from_utf8(&buf[..complete_message_size]).is_ok() { debug!( "Sent {} bytes from '{}'", complete_message_size, pipe_name_clone From b63695aa07732aece24937e10221bfc4e16fb471 Mon Sep 17 00:00:00 2001 From: Lewis Date: Wed, 11 Feb 2026 16:57:28 -0500 Subject: [PATCH 9/9] More consistent windows cfg gating --- crates/datadog-serverless-compat/src/main.rs | 6 ++--- crates/datadog-trace-agent/src/config.rs | 14 ++++++------ crates/datadog-trace-agent/src/mini_agent.rs | 22 +++++++++---------- .../src/trace_processor.rs | 4 ++-- .../tests/integration_test.rs | 4 ++-- crates/dogstatsd/src/dogstatsd.rs | 8 +++++-- crates/dogstatsd/tests/integration_test.rs | 2 +- 7 files changed, 32 insertions(+), 28 deletions(-) diff --git a/crates/datadog-serverless-compat/src/main.rs b/crates/datadog-serverless-compat/src/main.rs index 3a2aceb7..66be3554 100644 --- a/crates/datadog-serverless-compat/src/main.rs +++ b/crates/datadog-serverless-compat/src/main.rs @@ -178,7 +178,7 @@ pub async fn main() { https_proxy, dogstatsd_tags, dd_statsd_metric_namespace, - #[cfg(feature = "windows-pipes")] + #[cfg(all(windows, feature = "windows-pipes"))] dd_dogstatsd_windows_pipe_name.clone(), ) .await; @@ -213,7 +213,7 @@ async fn start_dogstatsd( https_proxy: Option, dogstatsd_tags: &str, metric_namespace: Option, - #[cfg(feature = "windows-pipes")] windows_pipe_name: Option, + #[cfg(all(windows, feature = "windows-pipes"))] windows_pipe_name: Option, ) -> (CancellationToken, Option, AggregatorHandle) { // 1. Create the aggregator service #[allow(clippy::expect_used)] @@ -230,7 +230,7 @@ async fn start_dogstatsd( host: AGENT_HOST.to_string(), port, metric_namespace, - #[cfg(feature = "windows-pipes")] + #[cfg(all(windows, feature = "windows-pipes"))] windows_pipe_name, }; let dogstatsd_cancel_token = tokio_util::sync::CancellationToken::new(); diff --git a/crates/datadog-trace-agent/src/config.rs b/crates/datadog-trace-agent/src/config.rs index ffa9fced..754f75eb 100644 --- a/crates/datadog-trace-agent/src/config.rs +++ b/crates/datadog-trace-agent/src/config.rs @@ -81,10 +81,10 @@ impl Tags { pub struct Config { pub dd_site: String, pub dd_apm_receiver_port: u16, - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] pub dd_apm_windows_pipe_name: Option, pub dd_dogstatsd_port: u16, - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] pub dd_dogstatsd_windows_pipe_name: Option, pub env_type: trace_utils::EnvironmentType, pub app_name: Option, @@ -225,10 +225,10 @@ impl Config { proxy_request_retry_backoff_base_ms: 100, verify_env_timeout_ms: 100, dd_apm_receiver_port, - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] dd_apm_windows_pipe_name, dd_dogstatsd_port, - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] dd_dogstatsd_windows_pipe_name, dd_site, trace_intake: Endpoint { @@ -382,7 +382,7 @@ mod tests { #[test] #[serial] - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] fn test_apm_windows_pipe_name() { env::set_var("DD_API_KEY", "_not_a_real_key_"); env::set_var("ASCSVCRT_SPRING__APPLICATION__NAME", "test-spring-app"); @@ -404,7 +404,7 @@ mod tests { #[test] #[serial] - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] fn test_dogstatsd_windows_pipe_name() { env::set_var("DD_API_KEY", "_not_a_real_key_"); env::set_var("ASCSVCRT_SPRING__APPLICATION__NAME", "test-spring-app"); @@ -462,7 +462,7 @@ mod tests { assert!(config_res.is_ok()); let config = config_res.unwrap(); assert_eq!(config.dd_apm_receiver_port, 8126); - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] assert_eq!(config.dd_apm_windows_pipe_name, None); env::remove_var("DD_API_KEY"); env::remove_var("ASCSVCRT_SPRING__APPLICATION__NAME"); diff --git a/crates/datadog-trace-agent/src/mini_agent.rs b/crates/datadog-trace-agent/src/mini_agent.rs index 9db9b8a2..6af32b12 100644 --- a/crates/datadog-trace-agent/src/mini_agent.rs +++ b/crates/datadog-trace-agent/src/mini_agent.rs @@ -129,9 +129,9 @@ impl MiniAgent { }); // Determine which transport to use based on configuration - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] let pipe_name_opt = self.config.dd_apm_windows_pipe_name.as_ref(); - #[cfg(not(any(feature = "windows-pipes", test)))] + #[cfg(not(any(all(windows, feature = "windows-pipes"), test)))] let pipe_name_opt: Option<&String> = None; if let Some(pipe_name) = pipe_name_opt { @@ -163,7 +163,9 @@ impl MiniAgent { { let _ = pipe_name; // Suppress unused variable warning unreachable!( - "Named pipe flag should never be true without the feature and Windows" + "Named pipes are only supported on Windows with the windows-pipes feature \ + enabled, cannot use pipe: {}.", + pipe_name ); } } else { @@ -270,17 +272,15 @@ impl MiniAgent { S::Future: Send, S::Error: std::error::Error + Send + Sync + 'static, { - // pipe_name already includes \\.\pipe\ prefix from config - let pipe_path = pipe_name; - let server = hyper::server::conn::http1::Builder::new(); let mut joinset = tokio::task::JoinSet::new(); loop { // Create a new pipe instance - let pipe = match ServerOptions::new().create(pipe_path) { + // pipe_name already includes \\.\pipe\ prefix from config + let pipe = match ServerOptions::new().create(pipe_name) { Ok(pipe) => { - debug!("Created pipe server instance '{}' in byte mode", pipe_path); + debug!("Created pipe server instance '{}' in byte mode", pipe_name); pipe } Err(e) => { @@ -307,7 +307,7 @@ impl MiniAgent { return Err(e.into()); } Ok(()) => { - debug!("Client connected to '{}'", pipe_path); + debug!("Client connected to '{}'", pipe_name); pipe } }, @@ -389,9 +389,9 @@ impl MiniAgent { } (_, INFO_ENDPOINT_PATH) => match Self::info_handler( config.dd_apm_receiver_port, - #[cfg(feature = "windows-pipes")] + #[cfg(all(windows, feature = "windows-pipes"))] config.dd_apm_windows_pipe_name.as_deref(), - #[cfg(not(feature = "windows-pipes"))] + #[cfg(not(all(windows, feature = "windows-pipes")))] None, config.dd_dogstatsd_port, ) { diff --git a/crates/datadog-trace-agent/src/trace_processor.rs b/crates/datadog-trace-agent/src/trace_processor.rs index 447258a4..41f6e9e8 100644 --- a/crates/datadog-trace-agent/src/trace_processor.rs +++ b/crates/datadog-trace-agent/src/trace_processor.rs @@ -204,10 +204,10 @@ mod tests { }, dd_site: "datadoghq.com".to_string(), dd_apm_receiver_port: 8126, - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] dd_apm_windows_pipe_name: None, dd_dogstatsd_port: 8125, - #[cfg(any(feature = "windows-pipes", test))] + #[cfg(any(all(windows, feature = "windows-pipes"), test))] dd_dogstatsd_windows_pipe_name: None, env_type: trace_utils::EnvironmentType::CloudFunction, os: "linux".to_string(), diff --git a/crates/datadog-trace-agent/tests/integration_test.rs b/crates/datadog-trace-agent/tests/integration_test.rs index 0cba339c..ea2fde9e 100644 --- a/crates/datadog-trace-agent/tests/integration_test.rs +++ b/crates/datadog-trace-agent/tests/integration_test.rs @@ -24,10 +24,10 @@ pub fn create_tcp_test_config() -> Config { Config { dd_site: "mock-datadoghq.com".to_string(), dd_apm_receiver_port: 8126, - #[cfg(feature = "windows-pipes")] + #[cfg(all(windows, feature = "windows-pipes"))] dd_apm_windows_pipe_name: None, dd_dogstatsd_port: 8125, - #[cfg(feature = "windows-pipes")] + #[cfg(all(windows, feature = "windows-pipes"))] dd_dogstatsd_windows_pipe_name: None, env_type: trace_utils::EnvironmentType::AzureFunction, app_name: Some("test-app".to_string()), diff --git a/crates/dogstatsd/src/dogstatsd.rs b/crates/dogstatsd/src/dogstatsd.rs index fca6ee41..30fbe995 100644 --- a/crates/dogstatsd/src/dogstatsd.rs +++ b/crates/dogstatsd/src/dogstatsd.rs @@ -34,7 +34,7 @@ pub struct DogStatsDConfig { /// Optional namespace to prepend to all metric names (e.g., "myapp") pub metric_namespace: Option, /// Optional Windows named pipe name. (e.g., "\\\\.\\pipe\\my_pipe"). - #[cfg(feature = "windows-pipes")] + #[cfg(all(windows, feature = "windows-pipes"))] pub windows_pipe_name: Option, } @@ -163,7 +163,11 @@ impl DogStatsD { #[cfg(not(all(windows, feature = "windows-pipes")))] { let _ = pipe_name_ref; // Suppress unused variable warning - unreachable!("Named pipe flag should never be true without the feature") + unreachable!( + "Named pipes are only supported on Windows with the windows-pipes feature \ + enabled, cannot use pipe: {}.", + pipe_name_ref + ); } } else { // UDP socket for all platforms diff --git a/crates/dogstatsd/tests/integration_test.rs b/crates/dogstatsd/tests/integration_test.rs index b9827b50..e51b0973 100644 --- a/crates/dogstatsd/tests/integration_test.rs +++ b/crates/dogstatsd/tests/integration_test.rs @@ -100,7 +100,7 @@ async fn start_dogstatsd(aggregator_handle: AggregatorHandle) -> CancellationTok host: "127.0.0.1".to_string(), port: 18125, metric_namespace: None, - #[cfg(feature = "windows-pipes")] + #[cfg(all(windows, feature = "windows-pipes"))] windows_pipe_name: None, }; let dogstatsd_cancel_token = tokio_util::sync::CancellationToken::new();