Skip to content

feat(dogstatsd): listen on UDP and the named pipe together - #181

Draft
Lewis-E wants to merge 2 commits into
mainfrom
lewis/SVLS-9467/dogstatsd-dual-listen
Draft

Lewis-E wants to merge 2 commits into
mainfrom
lewis/SVLS-9467/dogstatsd-dual-listen

Conversation

@Lewis-E

@Lewis-E Lewis-E commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

When DD_DOGSTATSD_WINDOWS_PIPE_NAME is set, dogstatsd now listens on UDP 8125 and the named pipe together, as #94 did for the trace agent. With a pipe set, the UDP bind is best-effort, as #129 did for TCP 8126. A failed bind logs a warning and dogstatsd keeps running on its pipe. Without a pipe, a failed bind still panics, so Linux, Lambda and Windows without a pipe behave as before.

datadog-serverless-compat no longer forces the dogstatsd port to 0 when a pipe is set. It logs the pipe listener, and the dogstatsd crate logs whether the UDP bind succeeded.

Motivation

SVLS-9467: Java multi-function named pipes on Azure Functions. serverless-compat-java will give each function its own dogstatsd pipe. Customer code on a java-dogstatsd-client without pipe support, or set to localhost:8125, would lose custom metrics without any error if the binary stopped listening on UDP. On Elastic Premium and Dedicated plans several function apps share one VM, so only the first binary gets 8125, and the others must not crash.

Additional Notes

  • The reader waits on UDP and the pipe with tokio::select!. When the UDP bind failed, the UDP arm never completes, the same Option pattern as Make TCP port-8126 bind best-effort when named pipe is active #129.
  • On Windows, a UDP recv_from error such as ConnectionReset ends the shared read loop, which would also stop pipe reads. UDP-only mode already ends on that error, and the server never sends on the socket, so I expect it to be rare.
  • The client-side change that lets custom metrics use the per-function pipe is in DataDog/java-dogstatsd-client (SVLS-8246). This PR is its fallback for older clients.

Describe how to test/QA your changes

  • New Windows-only test_named_pipe_and_udp_dual_listen sends one metric over UDP and one over the pipe to one server, then checks that the flush contains both and that cancellation stops it. It follows Listen on both TCP and named pipes when a pipe name is configured #94's dual-transport test.
  • cargo clippy passes for x86_64-pc-windows-gnu with windows-pipes,windows-enhanced-metrics and on macOS. The Windows tests only run in Windows CI.
  • Planned: one pre-release end-to-end run with two Java functions on one shared plan.

When DD_DOGSTATSD_WINDOWS_PIPE_NAME is set, dogstatsd now keeps its UDP
listener alongside the pipe, as #94 did for the trace agent. Clients that
can't use a pipe, such as older java-dogstatsd-client versions, still
reach the binary over 8125.

With a pipe set, the UDP bind is best-effort, as #129 did for TCP 8126.
Several function apps share one VM on Elastic Premium and Dedicated plans,
so a second app's binary finds 8125 taken and must keep running on its
pipe. Without a pipe, a failed bind still panics.

datadog-serverless-compat no longer forces the dogstatsd port to 0 when a
pipe is set, and logs both listeners.

SVLS-9467
With a pipe set, main.rs logged "starting to listen on port 8125" even
when the best-effort UDP bind had failed. The dogstatsd crate now logs the
UDP listener at info when it binds, next to its existing warning when it
doesn't, and main.rs logs only the pipe in that case.

SVLS-9467

This branch has not been deployed

No deployments
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.

1 participant