From ef9e9f7c26ca42e482a923ecc1a2f5e33cd64d94 Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Wed, 1 Oct 2025 14:48:45 +0200 Subject: [PATCH] feat(otlp): Add python OTLP integration --- docs/concepts/otlp/index.mdx | 10 +++ docs/platforms/python/integrations/index.mdx | 1 + .../python/integrations/otlp/index.mdx | 66 +++++++++++++++++++ .../tracing/instrumentation/opentelemetry.mdx | 6 ++ 4 files changed, 83 insertions(+) create mode 100644 docs/platforms/python/integrations/otlp/index.mdx diff --git a/docs/concepts/otlp/index.mdx b/docs/concepts/otlp/index.mdx index df76c558f6b07..abe28911cfab5 100644 --- a/docs/concepts/otlp/index.mdx +++ b/docs/concepts/otlp/index.mdx @@ -240,3 +240,13 @@ The following SDKs support the `propagateTraceparent` option: label="React Native" url="/platforms/react-native/configuration/options/#propagateTraceparent" /> + +## Dedicated Integrations + +The following SDKs have dedicated integrations that make setting up OTLP a breeze. + +- diff --git a/docs/platforms/python/integrations/index.mdx b/docs/platforms/python/integrations/index.mdx index 76b7029dab5e2..c3856977405c4 100644 --- a/docs/platforms/python/integrations/index.mdx +++ b/docs/platforms/python/integrations/index.mdx @@ -123,6 +123,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra | ----------------------------------------------------------------------------------------------------------------------------------- | :--------------: | | | | | | | +| | | | | | | | | | | | diff --git a/docs/platforms/python/integrations/otlp/index.mdx b/docs/platforms/python/integrations/otlp/index.mdx new file mode 100644 index 0000000000000..ecf0180c31bf9 --- /dev/null +++ b/docs/platforms/python/integrations/otlp/index.mdx @@ -0,0 +1,66 @@ +--- +title: OpenTelemetry (OTLP) +description: "Learn about using OTLP to automatically send OpenTelemetry Traces to Sentry." +keywords: ["otlp", "otel", "opentelemetry"] +--- + +The OTLP integration configures the Sentry SDK to automatically send trace data instrumented by an [OpenTelemetry](https://opentelemetry.io) SDK to Sentry's [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otel/protocol/) [ingestion endpoint](/concepts/otlp). + +## Install + +Install `sentry-sdk` from PyPI with the `opentelemetry-otlp` extra. + +```bash {tabTitle:pip} +pip install "sentry-sdk[opentelemetry-otlp]" +``` +```bash {tabTitle:uv} +uv add "sentry-sdk[opentelemetry-otlp]" +``` + +## Configure + +You need to configure both the OpenTelemetry and Sentry SDKs to get trace data. + +### OpenTelemetry + +For the OpenTelemetry SDK, you need to [configure instrumentation](https://opentelemetry.io/docs/languages/python/getting-started/#instrumentation) as per your needs. + +### Sentry + +For the Sentry SDK, you simply need to enable our `OTLPIntegration` along with your existing configuration. + + + +```python +import sentry_sdk +from sentry_sdk.integrations.otlp import OTLPIntegration + +sentry_sdk.init( + dsn="___PUBLIC_DSN___", + # Add data like request headers and IP for users, if applicable; + # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info + send_default_pii=True, + # ___PRODUCT_OPTION_START___ logs + # Enable logs to be sent to Sentry + enable_logs=True, + # ___PRODUCT_OPTION_END___ logs + integrations=[ + OTLPIntegration(), + ], +) +``` + +## Behavior + +Under the hood, the `OTLPIntegration` will setup the following parts: + +* A [`SpanExporter`](https://opentelemetry.io/docs/concepts/components/#exporters) that will automatically setup the OTLP ingestion endpoint from your Sentry DSN +* A [`Propagator`](https://opentelemetry.io/docs/concepts/context-propagation/#propagation) that ensures [distributed tracing](/concepts/key-terms/tracing/distributed-tracing/) works +* Trace/Span linking for all other Sentry events such as Errors, Logs, Crons and Metrics + +## Supported Versions + +- Python: 3.7+ +- opentelemetry-distro: 0.35b0+ diff --git a/docs/platforms/python/tracing/instrumentation/opentelemetry.mdx b/docs/platforms/python/tracing/instrumentation/opentelemetry.mdx index 9272b04995157..f76b7b396dc8d 100644 --- a/docs/platforms/python/tracing/instrumentation/opentelemetry.mdx +++ b/docs/platforms/python/tracing/instrumentation/opentelemetry.mdx @@ -4,6 +4,12 @@ description: "Using OpenTelemetry with Sentry Performance." sidebar_order: 20 --- + + +We have a dedicated OTLPIntegration now that can directly ingest OpenTelemetry Traces into Sentry. We recommend moving over to the new setup since it is much simpler. + + + You can configure your [OpenTelemetry SDK](https://opentelemetry.io/) to send traces and spans to Sentry. ## Install