Skip to content

Spring Boot OpenTelemetry instrumentation

There are two supported ways to instrument a Spring Boot service:

  • Option A — the OpenTelemetry Java agent. Attach opentelemetry-javaagent.jar at startup. No code or build changes, and the broadest library coverage. This is the recommended path for most services.
  • Option B — the OpenTelemetry Spring Boot starter. Add opentelemetry-spring-boot-starter as a dependency. Instrumentation ships inside your application artifact, configured through Spring properties. Use this when you cannot attach an agent — for example, GraalVM native images.

Pick one. Running both at once produces duplicate telemetry.

  • A Spring Boot application. The starter supports Spring Boot 3.x, and 2.6+ works with the same artifact.
  • Your Osuite ingest endpoint (ingest.<region>.osuite.io:443) and token (<your-ingest-token>).
  • Outbound network access from the application host to the ingest endpoint on port 443.

Option A: Attach the OpenTelemetry Java agent

Section titled “Option A: Attach the OpenTelemetry Java agent”

The agent reads its configuration from environment variables. Pick your deployment target — every tab is a complete, self-contained path.

Terminal window
curl -L -o opentelemetry-javaagent.jar \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.osuite.io:443"
export OTEL_EXPORTER_OTLP_PROTOCOL="grpc"
export OTEL_EXPORTER_OTLP_HEADERS="x-osuite-ingest-token=<your-ingest-token>"
export OTEL_SERVICE_NAME="orders-service"
export OTEL_RESOURCE_ATTRIBUTES="service.environment=production"
java -javaagent:./opentelemetry-javaagent.jar -jar orders-service.jar

The -javaagent flag must come before -jar.

Option B: Add the OpenTelemetry Spring Boot starter

Section titled “Option B: Add the OpenTelemetry Spring Boot starter”

Add the starter and its BOM to your build. The BOM keeps every OpenTelemetry artifact on a compatible version.

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-bom</artifactId>
<version>2.11.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
</dependency>
</dependencies>

Configure the exporter in application.properties. The starter reads both otel.* properties and the standard OTEL_* environment variables. Keep the token in an environment variable rather than in source control:

spring.application.name=orders-service
otel.exporter.otlp.endpoint=https://ingest.<region>.osuite.io:443
otel.exporter.otlp.protocol=grpc
otel.exporter.otlp.headers=x-osuite-ingest-token=${OSUITE_INGEST_TOKEN}
otel.resource.attributes=service.environment=production

The starter derives service.name from spring.application.name. Set OSUITE_INGEST_TOKEN in the runtime environment, then start the application normally with java -jar orders-service.jar.

What you should see

Start the service and send it some traffic. It appears in APM within a minute, emitting request-rate, error-rate, and latency metrics, and its requests show up as traces in the trace explorer.

For agent-attach, duplicate-span, and native-image problems, see Java troubleshooting.

No data in Osuite after a few minutes? Work through these checks.

  • Endpoint — confirm the exporter targets exactly ingest.<region>.osuite.io:443 for your region, over TLS.
  • Token — confirm the ingest header carries a valid <your-ingest-token> and has not been rotated.
  • Pipeline — confirm the signal you expect (traces, logs, or metrics) is wired into an active pipeline with the otlp/osuite exporter attached.
  • Export errors — check the application or Collector logs for OTLP export failures (auth, DNS, TLS, connection refused).
  • Network — confirm the host has outbound access to the ingest endpoint on port 443.
  • Timing — allow up to a minute for the first data to appear before assuming a failure.

Still stuck? Ask the Investigation Agent or contact support.