Skip to content

Conversation

@Lewis-E
Copy link
Contributor

@Lewis-E Lewis-E commented Dec 26, 2025

What does this PR do?

  • Adds a NamedPipe BufferReader option to let Dogstatsd use windows specific functionality
  • Adopts the multi-instance approach used by winio and the main agent: one server instance per client, spawned in separate tasks.
  • Uses DD_DOGSTATSD_WINDOWS_PIPE_NAME for config + DD_DOGSTATSD_PORT is overridden to 0 when pipe name is set
  • The issue of multiple functions is NOT solved by this PR. We need to add a uniqueness factor to the envvar to handle multiple functions in the same plan, similar to the AAS extension GUID usage, but this needs to be handled 1) at the compat layer so it can be distributed to the rust mini-agent and the dogstatsd library from a single source of truth, and 2) we can't modify envvars in java, so we will also need to add another communication method to dogstatsd java envvar handling.

Motivation

  • When multiple functions run in Windows run on the same plan, only one can connect due to port conflicts for trace agent and dogstatsd agent. The Serverless Compatibility Layer should use named pipes in Windows for transport to prevent this issue.

Additional Notes

Describe how to test/QA your changes

  • New #[cfg(test)] in integration_tests.rs
  • Manual testing in Azure
Screenshot 2025-12-31 at 11 25 00 AM

Separate ticket to add this to self-monitoring when the multiple functions functionality is added: https://datadoghq.atlassian.net/browse/SVLS-8248

@Lewis-E Lewis-E force-pushed the lewis/SVLS-6029/dogstatsd-named-pipes branch 17 times, most recently from 6d4e402 to f97a7e0 Compare December 29, 2025 19:44
enum BufferReader {
UdpSocketReader(tokio::net::UdpSocket),
/// UDP socket reader (cross-platform, default transport)
UdpSocket(tokio::net::UdpSocket),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy change to remove consistent suffix. (All buffer readers are readers.)

@Lewis-E Lewis-E force-pushed the lewis/SVLS-6029/dogstatsd-named-pipes branch 12 times, most recently from a2d4505 to 011b3e3 Compare December 31, 2025 15:19
@duncanpharvey
Copy link
Collaborator

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 669bcfa186

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 218 to 473
let mut config_json = serde_json::json!({
"statsd_port": dd_dogstatsd_port
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report no UDP port when named pipe is configured

When DD_DOGSTATSD_WINDOWS_PIPE_NAME is set on Windows, datadog-serverless-compat normalizes the pipe name and disables UDP by forcing the listener port to 0, but Config::new still reads DD_DOGSTATSD_PORT (default 8125) and this /info response always emits statsd_port from that value. In that setup, tracers that only consult statsd_port will try UDP even though no UDP socket is bound, so metrics will be dropped. Consider mirroring the server behavior by setting the port to 0 (or omitting statsd_port) when a pipe name is present so /info reflects the actual transport.

Useful? React with 👍 / 👎.

});

if let Some(pipe_name) = dd_dogstatsd_windows_pipe_name {
config_json["statsd_windows_pipe_name"] = serde_json::json!(pipe_name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the /info response in a Windows environment for a non-Serverless agent and statsd_windows_pipe_name is not set. The named pipe is not included in the response.

}

// Create new named pipe server
let server = match ServerOptions::new().create(&*pipe_name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run into any permission issues when opening the named pipe? It would be good to understand what the default security descriptor is and if we should set a different value to match what's done in the non Serverless agent.

https://github.com/DataDog/datadog-agent/blob/818a050bff727bd07e3e4ce93787b6537014e828/pkg/trace/config/config.go#L615

See https://datadoghq.atlassian.net/browse/SVLS-8192 for additional context

Copy link
Contributor

@jcstorms1 jcstorms1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #58. Logic looks good, but I'll defer more technical comments to those with more expertise.

@Lewis-E Lewis-E force-pushed the lewis/SVLS-6029/dogstatsd-named-pipes branch from 669bcfa to 195d536 Compare February 2, 2026 16:31

const DOGSTATSD_FLUSH_INTERVAL: u64 = 10;
const DOGSTATSD_TIMEOUT_DURATION: Duration = Duration::from_secs(5);
const DEFAULT_DOGSTATSD_PORT: u16 = 8125;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved into config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to undo this, actually. Separation of concerns for trace/dogstatsd

@Lewis-E Lewis-E force-pushed the lewis/SVLS-6029/dogstatsd-named-pipes branch 3 times, most recently from 07fd58c to a2d1b8f Compare February 2, 2026 17:40
@Lewis-E Lewis-E force-pushed the lewis/SVLS-6029/dogstatsd-named-pipes branch from a2d1b8f to 704609a Compare February 2, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants