Skip to content

Read dd.dogstatsd.pipe.name for the default named pipe - #344

Open
Lewis-E wants to merge 2 commits into
DataDog:masterfrom
Lewis-E:lewis/SVLS-8246/system-property-pipe
Open

Lewis-E wants to merge 2 commits into
DataDog:masterfrom
Lewis-E:lewis/SVLS-8246/system-property-pipe

Conversation

@Lewis-E

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

Copy link
Copy Markdown

This PR is part of a project to support named pipes on windows for Azure Serverless environments.

  • In Azure App Service and Azure Functions running on Azure App Service, it's possible to put multiple serverless apps in one app service plan, at which point they run in the same compute environment and compete for named pipe connections.
  • Windows apps run on IIS, which allows overlapping instances during a restart. These restarts also compete for a named pipe.
  • To prevent competition between apps where the loser cannot send metrics at all, we need to be able to assign unique names to a pipe. This unique name is generated after the process has started and java cannot override environmental variables after a process has started, so we are switching to sending names as system properties.

See Also:

Implementation

Precedence:

  1. Explicit builder settings (addressLookup/address, namedPipe, hostname/port).
  2. The dd.dogstatsd.pipe.name system property.
  3. The existing DD_DOGSTATSD_URL, DD_DOGSTATSD_PIPE_NAME and DD_AGENT_HOST/DD_DOGSTATSD_PORT environment variables.

If the system-property pipe can't be opened when the client is built, the client falls back to UDP (DD_AGENT_HOST, else localhost, and DD_DOGSTATSD_PORT, else customer's set value or the 8125 default). The serverless compat binary listens on UDP and the pipe together (serverless-components#181), so this covers a cold start where the client starts before the binary creates its pipe. The client reports the fallback to the error handler once, during the build, so it can't repeat per message. Explicit and environment-variable pipes can still compete and will throw errors as expected.

Tests

  • BuilderAddressTest.system_property_named_pipe_resolution checks that the property takes priority over every existing environment case, and explicit settings take priority over the property.
  • NonBlockingStatsDClientBuilderTest.system_property_named_pipe_falls_back_to_udp checks that an unopenable property pipe still builds, sends over UDP, and reports to the error handler exactly once.
  • NonBlockingStatsDClientBuilderTest.environment_named_pipe_does_not_fall_back checks that an unopenable DD_DOGSTATSD_PIPE_NAME still throws.

We tested this end to end on Azure Functions Elastic Premium (EP1) and Dedicated (B2) plans. Each plan ran three Java apps sharing an instance with .NET and Node apps, and each Java app used a dev build of this branch with a default-settings client. Every app's distribution metrics arrived in Datadog, one per request. A jcmd GC.class_histogram in each JVM showed only NamedPipeClientChannel instances and no UDP channel, so the property pipe was used rather than the fallback.

A JVM agent can set system properties after startup but not environment
variables. serverless-compat-java will set dd.dogstatsd.pipe.name to a
per-function pipe on Azure Functions shared plans, so a client built with
default settings now uses it.

Precedence: explicit builder settings, then the system property, then the
existing DD_DOGSTATSD_URL, DD_DOGSTATSD_PIPE_NAME and DD_AGENT_HOST
environment variables.

If the system-property pipe can't be opened at build time, the client
falls back to UDP (DD_AGENT_HOST and DD_DOGSTATSD_PORT, else
localhost:8125) instead of throwing. The serverless compat binary also
listens on UDP, so this covers a cold start where the client starts before
the binary creates its pipe. Explicit and environment-variable pipes still
throw as before.

SVLS-8246
The fallback from dd.dogstatsd.pipe.name to UDP was silent. The client now
passes one StatsDClientException to the error handler when it falls back.
It happens once, while the client is built, so it can't repeat per
message.

SVLS-8246
@vickenty

Copy link
Copy Markdown
Contributor

Why the JVM agent can't pass the correct value to the client directly during construction?

@Lewis-E

Lewis-E commented Oct 16, 2026 •

Copy link
Copy Markdown
Author

@vickenty Apologies for the unclear initial description/PR! I've revised it to explain the various serverless cases where we need to get the value after construction; didn't expect you to be taking a look at the draft, but appreciate the quick review regardless. Basically, Azure does not do isolation the way you would expect in certain serverless environments, and serverless does not do instrumentation the way you would expect with the main datadog agent, so we want to handle some edge cases where the pipe name is generated after construction.

@Lewis-E
Lewis-E marked this pull request as ready for review October 16, 2026 18:51
@Lewis-E
Lewis-E requested a review from a team as a code owner October 16, 2026 18:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T18:58:08.250195Z c548a8c Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants