OpenTelemetry Java: Java Agent, SDK and Spring Boot Setup

By the OpenTelemetry.app editorial team 4 min readUpdated November 16, 2026
Illustrated cover for the guide: OpenTelemetry Java: Java Agent, SDK and Spring Boot Setup

Java has one of the most mature OpenTelemetry implementations: traces, metrics and logs are all Stable per the official status table, and profiles are in Development. Most teams start with the Java agent, which instruments applications without code changes.

Key takeaways

  • The Java agent JAR instruments Java 8+ apps without code changes.
  • Configure with -Dotel.* properties or OTEL_* environment variables.
  • Traces, metrics and logs are all Stable for Java.
  • Spring Boot can use the agent or the Spring Boot starter.

The OpenTelemetry Java agent

The agent is a single JAR — opentelemetry-javaagent.jar — published on the releases page of the opentelemetry-java-instrumentation repository. It attaches to any Java 8+ application and injects bytecode to capture telemetry from many popular libraries and frameworks.

java -javaagent:path/to/opentelemetry-javaagent.jar \
     -Dotel.service.name=orders \
     -jar myapp.jar

If you cannot change the start command, use JAVA_TOOL_OPTIONS:

export JAVA_TOOL_OPTIONS="-javaagent:path/to/opentelemetry-javaagent.jar"
export OTEL_SERVICE_NAME=orders
java -jar myapp.jar

Configuring the agent

Configuration comes from system properties (-Dotel.*) or environment variables (OTEL_*). Common settings:

Common Java agent settings
SettingPurpose
OTEL_SERVICE_NAMEName shown in your backend
OTEL_EXPORTER_OTLP_ENDPOINTCollector or backend address
OTEL_TRACES_SAMPLERSampling strategy
OTEL_RESOURCE_ATTRIBUTESExtra resource info such as environment

By default the agent exports via OTLP.

Adding manual spans

Use the API alongside the agent to add business context:

import io.opentelemetry.instrumentation.annotations.WithSpan;

@WithSpan("price-order")
public Money priceOrder(Order order) {
    // the agent records this method as a span
}

Spring Boot options

Spring Boot applications can use the Java agent, which needs no code changes, or the OpenTelemetry Spring Boot starter, which configures OpenTelemetry through Spring properties — useful for native images or where agents are not allowed. The agent usually covers more libraries out of the box.

Overhead and production tips

  • Measure startup time and CPU in a staging environment; the project publishes a performance reference.
  • Disable instrumentations you do not need to reduce noise.
  • Use sampling for high-traffic services.
  • Pin the agent version and upgrade deliberately after reading release notes.

Troubleshooting the Java agent

  • No data exported: enable the agent's debug logging with -Dotel.javaagent.debug=true and check the endpoint and protocol.
  • Missing spans for a library: check the agent's supported-libraries list and the library version.
  • Agent and SDK both configured: avoid creating a second SDK in code when the agent is attached; use GlobalOpenTelemetry instead.
  • Containers: copy the JAR into the image and set JAVA_TOOL_OPTIONS in the deployment.

Extending the agent

Extensions let you add custom instrumentation, samplers or exporters to the agent without building your own distribution. For most teams, annotations and environment variables are enough; extensions are for platform teams standardising behaviour across many services.

Java signal status

Status from the official opentelemetry.io language table, checked November 16, 2026.
SignalJava status
TracesStable
MetricsStable
LogsStable
ProfilesDevelopment

Frequently asked questions

Where do I download the OpenTelemetry Java agent?

From the releases page of the open-telemetry/opentelemetry-java-instrumentation repository on GitHub.

Which Java versions are supported?

The agent attaches to Java 8 or later; some individual instrumentations require newer Java versions.

Do I need to change my code?

No for the basics — the agent captures common libraries automatically. Add annotations or API calls for business-specific spans.

Get OpenTelemetry from the official source

Free and open source (Apache 2.0) — the Go source .zip downloads straight from GitHub.

Download OpenTelemetry

Downloads the OpenTelemetry Go source code (.zip, main branch) from the official GitHub repository — you stay on this page.