Adding Datadog APM to Java - The javaagent Procedure

Adopting Datadog APM in a Java application starts with nothing more than having the JVM load dd-java-agent.jar via -javaagent. What you decide are three tags (service name, environment, version) and the destination for reaching the Agent; this article follows through to where to write it in Spring Boot and how to correlate with logs.

Download One jar and Load It with -javaagent, and Instrumentation Begins

Java APM has no step of adding a library to your dependencies as other languages do. Download a single dd-java-agent.jar and add -javaagent:/path/to/dd-java-agent.jar to the JVM startup arguments, and the SDK inserts instrumentation when the JVM loads classes. The official page lists three ways to fetch it from https://dtdg.co/latest-java-tracer, wget, curl, and ADD in a Dockerfile, and directs you to the form https://dtdg.co/java-tracer-vX when you want to pin the major version (as of September 2026; source: Tracing Java Applications).

java -javaagent:/path/to/dd-java-agent.jar -Ddd.service=my-app -Ddd.env=staging -Ddd.version=1.0 -jar path/to/your/app.jar
  • 1. Prepare the Agent first - The Datadog Agent that serves as the receiving end for traces must be running
  • 2. Fetch dd-java-agent.jar - Place it where the application's run user can read it
  • 3. Add -javaagent to the JVM arguments - Put system properties before -jar
  • 4. Decide the service name, environment, and version - When the three tags are in place, it appears as one service in the UI
The four stages of Java instrumentation. Source: the Getting started section of Tracing Java Applications, reorganized into four stages

This procedure is the method of loading the SDK yourself; the choice between it and Single Step Instrumentation, where the Agent side inserts the SDK automatically, is left to the APM explanation and the auto-instrumentation entry.

What You Decide: Three Tags and Two Destination Values

After adding -javaagent, there are five values to decide, and their meanings divide into two groups: "what to call this process" and "where to send traces." They can be specified either as environment variables or as system properties, and the conversion rule is simply to lowercase the variable name and replace _ with . (DD_SERVICE → dd.service).

The five values passed to the Java SDK (as of September 2026. System property names derived from the conversion rule)
Environment variableSystem propertyMeaning and default
DD_SERVICEdd.serviceThe name of the set of processes doing the same work. The unit for aggregating statistics
DD_ENVdd.envThe environment, such as production or staging
DD_VERSIONdd.versionThe application version. A string such as 2.5 or 202003181415
DD_AGENT_HOSTdd.agent.hostThe host of the Agent to send traces to. Ignored if DD_TRACE_AGENT_URL is present
DD_TRACE_AGENT_PORTdd.trace.agent.portThe port the Agent listens on. Default is 8126
Source: Tracing Java Applications / Configuring the Java SDK

The first three are the three-piece set of unified service tagging, and the service list and deployment tracking are bundled by these values. Since DD_SERVICE is defined as "the name of the set of processes doing the same work," the premise is that if you run the same application on multiple hosts, all of them use the same value; mixing in a hostname or container ID splits it into separate services. The latter two are the destination, and using DD_TRACE_AGENT_URL overrides the host and port specifications and lets you consolidate the destination into a single value as a URL that can include a Unix socket (as of September 2026; source: Configuring the Java SDK).

Where to Write -javaagent for Spring Boot and Tomcat

When the startup form differs, so does where you write -javaagent. The official page lists the location for each application server. For a Spring Boot executable jar, write it as JAVA_OPTS in a .conf file with the same name as the jar; for Tomcat on Linux, in CATALINA_OPTS in setenv.sh; for a Windows service, in Java Options in the maintenance utility; and so on (as of September 2026; source: Tracing Java Applications).

Where to write -javaagent by startup form (as of September 2026)
Startup formWhere to write itWhat to write
Direct startup with java -jarCommand linePut -javaagent and -Ddd.* before -jar
Spring Boot executable jarmy_app.conf in the same location as my_app.jarJAVA_OPTS=-javaagent:/path/to/dd-java-agent.jar
Tomcat (Linux)setenv.shAdd -javaagent to CATALINA_OPTS
Tomcat (Windows service)tomcat maintenance utility → Java tab → Java Options-javaagent:C:\path\to\dd-java-agent.jar
JBoss (standalone)End of standalone.confAdd -javaagent to JAVA_OPTS
ContainerDockerfilePull in the jar with ADD and put -javaagent in the startup command
Source: the Add the Java SDK to the JVM section of Tracing Java Applications

When running in containers, passing the three tags as environment variables on the deployment side rather than baking them into the Dockerfile lets you reuse the same image across multiple environments. On Java 24 and later, a warning about JNI native access may appear, and the official page shows how to suppress it by adding --enable-native-access=ALL-UNNAMED.

On Kubernetes, Decide the Route to the Agent First - UDS or hostIP

On Kubernetes the Agent lives in a separate Pod (a DaemonSet per node), so traces will not arrive unless you decide "which address to send to" from the application Pod. The official page treats the Unix domain socket (UDS) as the standard: when you enable APM on the Agent side (features.apm.enabled for the Operator, datadog.apm.socketEnabled for Helm), /var/run/datadog/apm.socket is created on the host. On the application side, mount that directory and write unix:///var/run/datadog/apm.socket in DD_TRACE_AGENT_URL (as of September 2026; source: Kubernetes APM - Trace Collection).

Three forms for delivering traces to the Agent on Kubernetes (as of September 2026)
FormAgent sideApplication Pod side
Unix domain socket (standard)Enable APM. The socket is created in a directory on the hostMount the host directory and put the unix:// path in DD_TRACE_AGENT_URL
TCP (hostIP:8126)Open hostPort 8126. There is a note about restricting the source with a firewallPut status.hostIP via fieldRef into DD_AGENT_HOST
Admission ControllerEnable the Cluster Agent's Admission ControllerEnvironment variables and mounts are injected automatically into new Pods
Source: the Setup / Additional configuration sections of Kubernetes APM - Trace Collection

How to install the Agent itself with Helm and how to decide the values are covered in the Kubernetes installation article. Single Step Instrumentation, where the Agent inserts the SDK automatically at Pod startup, has the premise explicitly stated on the official page that it "is automatically disabled when custom instrumentation is detected," so it is mutually exclusive with the manual -javaagent method in this article (source: Single Step APM Instrumentation). For details of the mechanism, see the auto-instrumentation entry.

Logs and Traces Are Correlated with DD_LOGS_INJECTION

Whether you can jump from a trace to "the logs for this request" changes investigation time. In the Java SDK, enabling DD_LOGS_INJECTION (dd.logs.injection as a system property) automatically injects the trace ID and span ID into the logging framework's MDC, so that on the Log Management side, logs and traces sharing the same ID can be navigated back and forth (as of September 2026; source: Tracing Java Applications). Since what gets injected are MDC keys, the application side needs a setting that either includes those keys in the log output pattern or outputs in JSON format carrying the whole MDC. Remote Configuration is enabled by default and lets you change trace settings via the Agent without a restart. To disable it, use DD_REMOTE_CONFIG_ENABLED=false.

How to Check Compatibility - The JVM Version and Framework Tables

Two things to check before installing are the JVM version and whether the framework you use is a target of automatic instrumentation. Java Tracer v1 targets JVM 8 and later, and the official compatibility page tabulates the support level for each Java version (as of September 2026; source: Java Compatibility Requirements).

JVMs supported by Java Tracer v1 (as of September 2026)
Java versionSupport levelNotes
8 to 17GA (x86 / x86-64)arm64 on Linux and Mac is Preview
18 to 26GAIncluding arm64
27 and laterPreviewNew features and fixes are best effort
7v0 series only, End-of-lifeNot covered by v1
Source: the Supported Java runtimes section of Java Compatibility Requirements

Support levels are defined in five tiers, Unsupported, Preview, GA, Maintenance, and End-of-life, and Preview is described as "an initial implementation without all features, with fixes on a best-effort basis." In the framework table, Spring Boot 1.5 to 3.x, Tomcat 5.5 and later, and Jetty 7.0 to 12.x are listed as Fully Supported, and Servlet-compatible application servers are stated to be covered automatically by that instrumentation. Since some integrations are disabled by default, when spans from the framework you are targeting do not appear, check the "disabled by default" list on the compatibility page before enabling them.

Where to Look When Traces Do Not Arrive, Names Are Inconsistent, or Sampling Drops Them

Let us look at the reasons nothing appears in the UI after running, in the order of route, name, and sampling.

Symptoms of getting stuck with Java APM and where to look (as of September 2026)
SymptomCandidate causesWhere to look
Not a single trace arrivesThe Agent address is wrong. When DD_TRACE_AGENT_URL is present, DD_AGENT_HOST and DD_TRACE_AGENT_PORT are ignoredThe precedence of the three values, and on Kubernetes the route (UDS or TCP) and the receiving end on the Agent side
-javaagent was added but nothing is instrumentedSystem properties come after -jar. Classes loaded by a remote ClassLoaderThe order of arguments. The official page notes that classes from a remote ClassLoader are not automatically instrumented
The same application splits into multiple servicesDD_SERVICE contains a hostname or per-environment valuesThe same DD_SERVICE on all instances. Express environment differences with DD_ENV
env or version differs from what was expectedBoth env / version in DD_TAGS and DD_ENV / DD_VERSION were writtenDD_ENV and DD_VERSION override the same-named tags in DD_TAGS
Some traces are not visibleIngestion is being narrowed with DD_TRACE_SAMPLE_RATE or DD_TRACE_SAMPLING_RULESThe sample rate (0.0 to 1.0), and the per-second cap (default 100) that takes effect when a rate or rules are specified
Source: Configuring the Java SDK / Tracing Java Applications

Sampling is not "broken" but a state of reducing as designed, so in situations where you want to follow a specific request with distributed tracing, the decision is to raise the rate with a rule for that service only. The profiler can be enabled from the same jar with DD_PROFILING_ENABLED, but it is a feature for which the official page notes the impact on billing, and what increases is left to the Continuous Profiler explanation and the APM pricing article.

References

Share