Skip to content

[SVLS-8245] Give each Windows Azure Function its own named pipes - #43

Merged
Lewis-E merged 14 commits into
mainfrom
lewis/SVLS-9467/java-pipe-names
Nov 24, 2026
Merged

Lewis-E merged 14 commits into
mainfrom
lewis/SVLS-9467/java-pipe-names

Conversation

@Lewis-E

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

Copy link
Copy Markdown
Contributor

What does this PR do?

Give each function app its own trace and DogStatsD named pipes for Java-based Azure Functions.

  • premainpassesdd.trace.pipe.nameanddd.dogstatsd.pipe.namesystem properties todd-java-agent`.
  • The binary gets the same names as DD_APM_WINDOWS_PIPE_NAME and DD_DOGSTATSD_WINDOWS_PIPE_NAME, plus DD_DOGSTATSD_PORT=8125 unless the customer already set a port.

NamedPipeNames follows the .NET CompatibilityLayer order for each pipe:

  1. DD_APM_WINDOWS_PIPE_NAME / DD_DOGSTATSD_WINDOWS_PIPE_NAME, used as written.
  2. A name the customer already set for the tracer: -Ddd.trace.pipe.name / -Ddd.dogstatsd.pipe.name, else DD_TRACE_PIPE_NAME / DD_DOGSTATSD_PIPE_NAME.
  3. A generated dd_trace_<guid> / dd_dogstatsd_<guid>.

It logs a warning when a customer-set name differs from the *_WINDOWS_PIPE_NAME value, and when a name is longer than 256 characters.

Safety Gate

The binary always gets pipes; dd-java-agent gets them only when it is new enough. If the tracer is older, missing, or unreadable, the agent logs why at INFO and sets no system properties, so the tracer keeps today's TCP 8126 and UDP 8125 behavior, or pipe settings a customer configured by hand.

The gate exists because no released dd-trace-java can use a pipe. Releases that include DataDog/dd-trace-java#12898 can handle these properties without hanging or crashing.

TracerVersionGate.MINIMUM_TRACER_VERSION is 1.69.0, the first dd-trace-java release with those fixes (DataDog/dd-trace-java#12898). serverless-components#181 is also a requirement for this release. Without it, customer java-dogstatsd-client code that sends to localhost:8125 loses its metrics.

Motivation

SVLS-9467 / SVLS-8245. Java function apps that share an Elastic Premium or Dedicated plan also share instances. Their binaries collide on one pipe name or port. Per-function pipes fixed this for .NET (datadog-serverless-compat-dotnet#20) and Node (datadog-serverless-compat-js#46). Java implements this functionality with system properties instead of environment variables because a JVM can't change its own environment after it starts, and dd-trace-java's Config already reads dd.*.pipe.name properties ahead of environment variables.

Additional Notes

Describe how to test/QA your changes

mvn test passes, including these new tests:

  • NamedPipeNamesTest covers the name order, JVM options beating environment variables, empty values, generated names, and both warnings.
  • ServerlessCompatAgentTest checks that the binary gets both pipe names and DD_DOGSTATSD_PORT=8125, that a port the customer set wins, that a passing gate sets both tracer system properties, and that a failed gate still gives the binary pipes but sets no tracer system properties.
  • TracerVersionGateTest checks that the minimum, later versions, and dev builds of the minimum (1.69.0-SNAPSHOT, 1.69.0-105-gefa6bd64) pass. Older (including 1.68.2), missing, non-jar, unversioned, and unparseable tracers fail. One test renames the tracer jar to prove the gate matches on Premain-Class. The tests write real jars with manifests to a temp directory.

I also ran the gate in a JVM started with this agent and a real dd-java-agent-1.59.0.jar as -javaagent options. It skipped the compat jar, found the tracer, and reported 1.59.0 as older than 1.68.0, the minimum at the time. The premain wiring has no unit test. An end-to-end run in serverless-compat-self-monitoring covers it: on shared EP1 and B2 plans, with dev builds of the binary, this agent, and dd-trace-java, each Java app got its own pipes, and traces, tracer metrics, and custom metrics all arrived. That run predates the DD_DOGSTATSD_PORT change, so I'll rerun it.

With a pipe set, the binary listens on UDP only when DD_DOGSTATSD_PORT is
set, so it doesn't take 8125 from a neighbor whose binary has no pipe.
The .NET and Node layers point their in-process clients at the pipe, but
a JVM can't change its own environment after it starts. A DogStatsD
client that doesn't read dd.dogstatsd.pipe.name, or can't open the pipe,
still sends to UDP 8125, so compat-java sets DD_DOGSTATSD_PORT=8125 for
its binary. A port the customer already set wins.
On Windows Azure Functions, compat-java now always passes pipe names and
DD_DOGSTATSD_PORT to the binary, as the .NET compatibility layer gives its
binary pipes whether or not a tracer is present. Only dd-java-agent's
system properties still depend on the version gate.

With a pipe, a taken UDP 8125 or TCP 8126 makes the binary warn and keep
running instead of panicking, so Java apps with an older or missing
tracer stop crashing next to a neighbor that owns the port. Their tracer
keeps TCP and UDP: dd-java-agent learns a pipe name only from its own
configuration, never from the binary.
The JVM runs -javaagent premains in command-line order. A tracer listed first can read its settings before the compat layer sets the pipe system properties, and then keeps TCP and UDP. The gate now notes the order, and the compat layer logs a warning when the tracer would get pipes but comes first.
1.69.0 is the first dd-trace-java release with named pipe support
(DataDog/dd-trace-java#12898). 1.68.2, released later from a patch
branch, does not include it.
@Lewis-E
Lewis-E force-pushed the lewis/SVLS-9467/java-pipe-names branch from ef35d9c to 62ac771 Compare November 23, 2026 20:01
@Lewis-E
Lewis-E marked this pull request as ready for review November 23, 2026 20:34
@Lewis-E
Lewis-E requested a review from a team as a code owner November 23, 2026 20:34
@Lewis-E
Lewis-E requested review from duncanpharvey and removed request for a team November 23, 2026 20:34
- Replace the stale placeholder comment on the minimum tracer version.
- Store the minimum as numbers, removing the test-only overload and the
  invalid-minimum branch.
- Add TracerVersionGate.failed so failure results don't carry the
  listed-first flag nobody reads.
- Group each pipe's settings in a NamedPipe enum instead of passing four
  strings in a row.
- Reword the configureNamedPipes Javadoc, the gate log lines, and the
  mismatch warning, which now says only that the binary uses the
  *_WINDOWS_PIPE_NAME value.
- Fold the pipe setup in premain into one block.
- Test that a passing gate sets both tracer system properties; merge a
  duplicate test and use literals for Premain-Class values.
Check the pipe name length in one place, and say whether dd-java-agent uses the binary's pipe name or keeps its own when the customer set two different names.
Drop the claim that dd-java-agent keeps its own settings, which is wrong when there is no tracer, and say the binary only tries the TCP and UDP ports.
@Lewis-E
Lewis-E merged commit 24cdb16 into main Nov 24, 2026
1 check passed
@Lewis-E
Lewis-E deleted the lewis/SVLS-9467/java-pipe-names branch November 24, 2026 17:26
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