---
title: "OpenTelemetry OTLP"
description: "Using OpenTelemetry OTLP export with Sentry."
url: https://docs.sentry.io/platforms/java/guides/spring-boot/opentelemetry/setup/otlp/
---

# OpenTelemetry OTLP | Sentry for Spring Boot

Use the `sentry-opentelemetry-otlp` module when you want OpenTelemetry to handle tracing (with spans exported via OTLP to Sentry) while Sentry handles errors, logs, and metrics. Sentry reads trace and span IDs from the OpenTelemetry `Context` so that all Sentry events are correlated with your OpenTelemetry traces.

Unlike the [Agent](https://docs.sentry.io/platforms/java/guides/spring-boot/opentelemetry/setup/agent.md) and [Agentless](https://docs.sentry.io/platforms/java/guides/spring-boot/opentelemetry/setup/agentless.md) integrations, this module does not use OpenTelemetry for scope storage or span creation within the Sentry SDK.

## [Install](https://docs.sentry.io/platforms/java/guides/spring-boot/opentelemetry/setup/otlp.md#install)

```groovy
implementation 'io.sentry:sentry-opentelemetry-otlp-spring:8.52.0'
```

*Other available variations of the above snippet: Maven*

This includes `sentry-opentelemetry-otlp` and the OpenTelemetry Spring Boot starter as transitive dependencies.

## [OpenTelemetry Dependency Alignment](https://docs.sentry.io/platforms/java/guides/spring-boot/opentelemetry/setup/otlp.md#opentelemetry-dependency-alignment)

Sentry's Java OpenTelemetry integrations are tested with a specific OpenTelemetry dependency set. If your application also imports a BOM that manages OpenTelemetry versions, such as Spring Boot dependency management, it can override transitive OpenTelemetry dependencies and create a mixed OpenTelemetry classpath.

Import `io.sentry:sentry-opentelemetry-bom` manually when another BOM manages OpenTelemetry versions in your application.

When using Gradle with Spring dependency management, import Sentry's OpenTelemetry BOM:

```groovy
dependencyManagement {
    imports {
        mavenBom 'io.sentry:sentry-opentelemetry-bom:8.52.0'
    }
}
```

When using Maven, import Sentry's OpenTelemetry BOM before `spring-boot-dependencies`:

```xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry-opentelemetry-bom</artifactId>
            <version>8.52.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring-boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
```

If you use `spring-boot-starter-parent`, import Sentry's OpenTelemetry BOM in the child POM's `dependencyManagement` section.

## [Setup](https://docs.sentry.io/platforms/java/guides/spring-boot/opentelemetry/setup/otlp.md#setup)

You need to configure both OpenTelemetry (to export spans via OTLP to Sentry) and Sentry (to read trace/span IDs from OpenTelemetry).

The OTLP endpoint and authentication details are shown in the code examples below. You can also find the **OTLP Traces Endpoint** and **OTLP Traces Endpoint Headers** in your Sentry project under **Settings > Projects > \[Project] > Client Keys (DSN)**.

Add the following to your `application.properties`:

```properties
sentry.dsn=https://<key>@o<orgId>.ingest.sentry.io/<projectId>

otel.propagators=tracecontext,baggage,sentry
otel.traces.exporter=otlp
otel.exporter.otlp.traces.endpoint=https://o<orgId>.ingest.sentry.io/api/<projectId>/integration/otlp/v1/traces
otel.exporter.otlp.traces.protocol=http/protobuf
otel.exporter.otlp.traces.headers=x-sentry-auth=sentry sentry_key=<your-public-key>
otel.logs.exporter=none
otel.metrics.exporter=none
```

Register the `OpenTelemetryOtlpEventProcessor` as a Spring bean to link Sentry events to OpenTelemetry traces:

```java
import io.sentry.opentelemetry.otlp.OpenTelemetryOtlpEventProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SentryConfig {
    @Bean
    public OpenTelemetryOtlpEventProcessor openTelemetryOtlpEventProcessor() {
        return new OpenTelemetryOtlpEventProcessor();
    }
}
```

## [Sampling](https://docs.sentry.io/platforms/java/guides/spring-boot/opentelemetry/setup/otlp.md#sampling)

The Sentry propagator inherits the sampling decision from the incoming `sentry-trace` header. When no sampling flag is present (deferred decision), it defaults to sampled.

##### Deferred Sampling

If you need to control sampling for deferred traces, you have to implement a custom OpenTelemetry `Sampler`.
