The OpenTelemetry Java agent instruments a running JVM without touching your source. It hooks more than a hundred libraries — servlets, Spring, JDBC, Kafka, gRPC, the HTTP clients — and emits traces, metrics and logs. Works with Spring Boot, Quarkus, Micronaut, Dropwizard and plain Tomcat or Jetty.

Install the agent

The latest URL always resolves to the current release. Pin a version in production if you want reproducible builds.

Configure

The last line attaches MDC values and exception stack traces to exported log records, which is what makes a log line searchable by trace id later.

Run

-javaagent must come before -jar. Anything after -jar is passed to your application rather than the JVM, which is the usual reason the agent appears to do nothing at all.

In a container

Custom spans

The agent covers framework and library calls. Add spans by hand only for business operations worth naming.
Depend on opentelemetry-api only. The agent supplies the implementation at runtime — adding the SDK as well gives you two providers and no data.