---
title: "OpenTelemetry (OTLP)"
description: "Learn about using OTLP to automatically send OpenTelemetry Traces to Sentry using the Python SDK."
url: https://docs.sentry.io/platforms/python/integrations/otlp/
---

# OpenTelemetry (OTLP) for Python

The OTLP integration configures the Sentry SDK to automatically send trace data instrumented by an OpenTelemetry SDK to Sentry's [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otel/protocol/) [ingestion endpoint](https://docs.sentry.io/concepts/otlp.md).

## [Install](https://docs.sentry.io/platforms/python/integrations/otlp.md#install)

Install `sentry-sdk` from PyPI with the `opentelemetry-otlp` extra.

```bash
pip install "sentry-sdk[opentelemetry-otlp]"
```

*Other available variations of the above snippet: uv*

## [Configure](https://docs.sentry.io/platforms/python/integrations/otlp.md#configure)

You need to configure both the OpenTelemetry and Sentry SDKs to get trace data.

### [OpenTelemetry](https://docs.sentry.io/platforms/python/integrations/otlp.md#opentelemetry)

For the OpenTelemetry SDK, you need to [configure instrumentation](https://opentelemetry.io/docs/languages/python/getting-started/#instrumentation) you want to capture.

### [Sentry](https://docs.sentry.io/platforms/python/integrations/otlp.md#sentry)

For the Sentry SDK, add the `OTLPIntegration` to your existing configuration.

Error Monitoring

```python
import sentry_sdk
from sentry_sdk.integrations.otlp import OTLPIntegration

sentry_sdk.init(
    dsn="https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
    # Check https://docs.sentry.io/platforms/python/data-management/data-collected/ to configure what data is collected
    data_collection={
        "user_info": True,
    },
    integrations=[
        OTLPIntegration(),
    ],
)
```

## [Behavior](https://docs.sentry.io/platforms/python/integrations/otlp.md#behavior)

Under the hood, the `OTLPIntegration` sets up the following parts:

* A [`SpanExporter`](https://opentelemetry.io/docs/concepts/components/#exporters) that automatically configures the OTLP ingestion endpoint from your Sentry DSN. This enables tracing in Sentry. **Note:** *Do not* also set up tracing via the Python SDK (i.e. do not set `traces_sample_rate` or `traces_sampler`).
* Optionally, a Sentry [`Propagator`](https://opentelemetry.io/docs/concepts/context-propagation/#propagation) for compatibility with services using Sentry's native tracing (see the `setup_propagator` option below)
* Trace/Span linking for all other Sentry events such as Errors, Logs, and Metrics

Cross-service trace propagation uses OTel's default W3C `traceparent` headers and does not require additional configuration. See [Exporters, Event Linking, and Propagation](https://docs.sentry.io/concepts/otlp/sentry-with-otel.md#exporters-event-linking-and-propagation) for details.

## [Options](https://docs.sentry.io/platforms/python/integrations/otlp.md#options)

You can pass the following keyword arguments to `OTLPIntegration()`:

* `setup_otlp_traces_exporter`:

  Automatically configure an Exporter to send OTLP traces to the right project from the DSN or `collector_url`, defaults to `True`.

  Set to `False` to set up the TracerProvider manually.

* `collector_url`:

  URL of your own OpenTelemetry collector. When set, the exporter will send traces to this URL instead of the Sentry OTLP endpoint derived from the DSN.

* `setup_propagator`:

  Replace the global OpenTelemetry propagator with the Sentry propagator, which uses Sentry's `sentry-trace` and `baggage` headers. Defaults to `False`, so distributed tracing uses the propagators configured in OpenTelemetry (by default, W3C `traceparent` and `baggage`). In SDK versions prior to `3.0`, the default is `True`.

  To propagate both W3C and Sentry headers, set up the `SentryOTLPPropagator` manually instead:

  ```python
  from opentelemetry.propagate import set_global_textmap
  from opentelemetry.propagators.composite import CompositePropagator
  from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator

  from sentry_sdk.integrations.otlp import SentryOTLPPropagator

  set_global_textmap(
      CompositePropagator([TraceContextTextMapPropagator(), SentryOTLPPropagator()])
  )
  ```

* `capture_exceptions`:

  Set to `True` to intercept and capture exceptions on the OpenTelemetry Span recorded with `Span.record_exception` in Sentry as well, defaults to `False`.

  Caveat: Since Sentry already captures most exceptions, duplicate exceptions might be dropped by [`DedupeIntegration`](https://docs.sentry.io/platforms/python/integrations/default-integrations.md#deduplication) but that should not affect your overall product experience on the [Issues](https://docs.sentry.io/product/issues.md) page.

## [Supported Versions](https://docs.sentry.io/platforms/python/integrations/otlp.md#supported-versions)

* Python: 3.7+
* opentelemetry-distro: 0.35b0+
