dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

With Unix Domain Socket, DD_AGENT_HOST not ignored despite DD_TRACE_AGENT_URL

Open pukkaone opened this issue 1 year ago • 1 comments

While trying to send traces by Unix Domain Socket, I set both environment variables DD_AGENT_HOST and DD_TRACE_AGENT_URL. The documentation for DD_TRACE_AGENT_URL says:

When set this takes precedence over DD_AGENT_HOST and DD_TRACE_AGENT_PORT.

However, the DD_AGENT_HOST environment variable still affects where traces are sent.

How to reproduce

Execute this shell script:

DD_JAVA_AGENT_VERSION=1.34.0
if [ ! -f dd-java-agent.jar ]; then
  curl https://repo.maven.apache.org/maven2/com/datadoghq/dd-java-agent/$DD_JAVA_AGENT_VERSION/dd-java-agent-$DD_JAVA_AGENT_VERSION.jar --output dd-java-agent.jar
fi

cat <<EOF >HelloWorld.java
public class HelloWorld {
  public static void main(String[] args) throws Exception {
    java.util.concurrent.TimeUnit.SECONDS.sleep(1L);
    System.out.println("Hello, World!");
  }
}
EOF

export DD_AGENT_HOST=should-ignore
export DD_TRACE_AGENT_URL=unix:///var/run/datadog/apm.socket
export DD_TRACE_METHODS='HelloWorld[*]'
java -javaagent:dd-java-agent.jar HelloWorld.java

The DATADOG TRACER CONFIGURATION output to the console includes:

"agent_url":"http://should-ignore:8126",
"agent_unix_domain_socket":"/var/run/datadog/apm.socket"

The console output also includes:

[dd.trace 2024-05-15 15:06:43:904 -0700] [dd-trace-processor] WARN datadog.trace.agent.common.writer.ddagent.DDAgentApi - Error while sending 1 (size=526B) traces. Total: 1, Received: 1, Sent: 0, Failed: 1. java.net.UnknownHostException: should-ignore (Will not log warnings for 5 minutes)

Work around

If I do not set the DD_AGENT_HOST environment variable and set the DD_TRACE_AGENT_URL environment variable, then traces are sent to the intended Unix Domain Socket.

pukkaone avatar May 15 '24 22:05 pukkaone

Hi @pukkaone - thanks for reporting, we'll fix this for the next release

mcculls avatar May 17 '24 07:05 mcculls

Hi @pukkaone - this is fixed by https://github.com/DataDog/dd-trace-java/pull/7094 which will be in the next release (1.35.0)

mcculls avatar May 30 '24 16:05 mcculls

The fix has been delivered in 1.35.0-RC1 freshly released.

amarziali avatar Jun 06 '24 14:06 amarziali

:robot: This issue has been addressed in the latest release. See full details in the Release Notes.

github-actions[bot] avatar Jun 10 '24 11:06 github-actions[bot]