# 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.33.0'
```

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

## [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=___PUBLIC_DSN___

otel.propagators=sentry
otel.traces.exporter=otlp
otel.exporter.otlp.traces.endpoint=___OTLP_TRACES_URL___
otel.exporter.otlp.traces.protocol=http/protobuf
otel.exporter.otlp.traces.headers=x-sentry-auth=sentry sentry_key=___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();
    }
}
```
