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
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).
| Environment variable | System property | Meaning and default |
|---|---|---|
| DD_SERVICE | dd.service | The name of the set of processes doing the same work. The unit for aggregating statistics |
| DD_ENV | dd.env | The environment, such as production or staging |
| DD_VERSION | dd.version | The application version. A string such as 2.5 or 202003181415 |
| DD_AGENT_HOST | dd.agent.host | The host of the Agent to send traces to. Ignored if DD_TRACE_AGENT_URL is present |
| DD_TRACE_AGENT_PORT | dd.trace.agent.port | The port the Agent listens on. Default is 8126 |
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).
| Startup form | Where to write it | What to write |
|---|---|---|
| Direct startup with java -jar | Command line | Put -javaagent and -Ddd.* before -jar |
| Spring Boot executable jar | my_app.conf in the same location as my_app.jar | JAVA_OPTS=-javaagent:/path/to/dd-java-agent.jar |
| Tomcat (Linux) | setenv.sh | Add -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.conf | Add -javaagent to JAVA_OPTS |
| Container | Dockerfile | Pull in the jar with ADD and put -javaagent in the startup command |
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).
| Form | Agent side | Application Pod side |
|---|---|---|
| Unix domain socket (standard) | Enable APM. The socket is created in a directory on the host | Mount 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 firewall | Put status.hostIP via fieldRef into DD_AGENT_HOST |
| Admission Controller | Enable the Cluster Agent's Admission Controller | Environment variables and mounts are injected automatically into new Pods |
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).
| Java version | Support level | Notes |
|---|---|---|
| 8 to 17 | GA (x86 / x86-64) | arm64 on Linux and Mac is Preview |
| 18 to 26 | GA | Including arm64 |
| 27 and later | Preview | New features and fixes are best effort |
| 7 | v0 series only, End-of-life | Not covered by v1 |
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.
| Symptom | Candidate causes | Where to look |
|---|---|---|
| Not a single trace arrives | The Agent address is wrong. When DD_TRACE_AGENT_URL is present, DD_AGENT_HOST and DD_TRACE_AGENT_PORT are ignored | The 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 instrumented | System properties come after -jar. Classes loaded by a remote ClassLoader | The order of arguments. The official page notes that classes from a remote ClassLoader are not automatically instrumented |
| The same application splits into multiple services | DD_SERVICE contains a hostname or per-environment values | The same DD_SERVICE on all instances. Express environment differences with DD_ENV |
| env or version differs from what was expected | Both env / version in DD_TAGS and DD_ENV / DD_VERSION were written | DD_ENV and DD_VERSION override the same-named tags in DD_TAGS |
| Some traces are not visible | Ingestion is being narrowed with DD_TRACE_SAMPLE_RATE or DD_TRACE_SAMPLING_RULES | The sample rate (0.0 to 1.0), and the per-second cap (default 100) that takes effect when a rate or rules are specified |
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.