Skip to content

Commit 279511d

Browse files
committed
feat(otlp): Add python OTLP integration
1 parent f06a280 commit 279511d

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

docs/concepts/otlp/index.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,13 @@ The following SDKs support the `propagateTraceparent` option:
240240
label="React Native"
241241
url="/platforms/react-native/configuration/options/#propagateTraceparent"
242242
/>
243+
244+
## Dedicated Integrations
245+
246+
The following SDKs have dedicated integrations that make setting up OTLP a breeze.
247+
248+
- <LinkWithPlatformIcon
249+
platform="python"
250+
label="Python"
251+
url="/platforms/python/integrations/otlp"
252+
/>

docs/platforms/python/integrations/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
123123
| ----------------------------------------------------------------------------------------------------------------------------------- | :--------------: |
124124
| <LinkWithPlatformIcon platform="python.asgi" label="ASGI" url="/platforms/python/integrations/asgi" /> | |
125125
| <LinkWithPlatformIcon platform="python.asyncio" label="asyncio" url="/platforms/python/integrations/asyncio" /> | |
126+
| <LinkWithPlatformIcon platform="python.opentelemetry" label="Opentelemetry (OTLP)" url="/platforms/python/integrations/otlp" /> | |
126127
| <LinkWithPlatformIcon platform="python.pure_eval" label="Enhanced Locals" url="/platforms/python/integrations/pure_eval" /> | |
127128
| <LinkWithPlatformIcon platform="python.gnu_backtrace" label="GNU Backtrace" url="/platforms/python/integrations/gnu_backtrace" /> | |
128129
| <LinkWithPlatformIcon platform="python.rust_tracing" label="Rust Tracing" url="/platforms/python/integrations/rust_tracing" /> | |
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: OpenTelemetry (OTLP)
3+
description: "Learn about using OTLP to automatically send OpenTelemetry Traces to Sentry."
4+
keywords: ["otlp", "otel", "opentelemetry"]
5+
---
6+
7+
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).
8+
9+
## Install
10+
11+
Install `sentry-sdk` from PyPI with the `opentelemetry-otlp` extra.
12+
13+
```bash {tabTitle:pip}
14+
pip install "sentry-sdk[opentelemetry-otlp]"
15+
```
16+
```bash {tabTitle:uv}
17+
uv add "sentry-sdk[opentelemetry-otlp]"
18+
```
19+
20+
## Configure
21+
22+
You need to configure both the OpenTelemetry and Sentry SDKs to get trace data.
23+
24+
### OpenTelemetry
25+
26+
For the OpenTelemetry SDK, you need to [configure instrumentation](https://opentelemetry.io/docs/languages/python/getting-started/#instrumentation) as per your needs.
27+
28+
### Sentry
29+
30+
For the Sentry SDK, you simply need to enable our `OTLPIntegration` along with your existing configuration.
31+
32+
<OnboardingOptionButtons
33+
options={["error-monitoring", "logs"]}
34+
/>
35+
36+
```python
37+
import sentry_sdk
38+
from sentry_sdk.integrations.otlp import OTLPIntegration
39+
40+
sentry_sdk.init(
41+
dsn="___PUBLIC_DSN___",
42+
# Add data like request headers and IP for users, if applicable;
43+
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
44+
send_default_pii=True,
45+
# ___PRODUCT_OPTION_START___ logs
46+
# Enable logs to be sent to Sentry
47+
enable_logs=True,
48+
# ___PRODUCT_OPTION_END___ logs
49+
integrations=[
50+
OTLPIntegration(),
51+
],
52+
)
53+
```
54+
55+
## Behavior
56+
57+
Under the hood, the `OTLPIntegration` will setup the following parts:
58+
59+
* A [`SpanExporter`](https://opentelemetry.io/docs/concepts/components/#exporters) that will automatically setup the OTLP ingestion endpoint from your Sentry DSN
60+
* A [`Propagator`](https://opentelemetry.io/docs/concepts/context-propagation/#propagation) that ensures [distributed tracing](concepts/key-terms/tracing/distributed-tracing/) works
61+
* Trace/Span linking for all other Sentry events such as Errors, Logs, Crons and Metrics
62+
63+
## Supported Versions
64+
65+
- Python: 3.7+
66+
- opentelemetry-distro: 0.35b0+

docs/platforms/python/tracing/instrumentation/opentelemetry.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ description: "Using OpenTelemetry with Sentry Performance."
44
sidebar_order: 20
55
---
66

7+
<Alert>
8+
9+
We have a dedicated <PlatformLink to="/integrations/otlp"> OTLPIntegration </PlatformLink> now that can directly ingest OpenTelemetry Traces into Sentry. We recommend moving over to the new setup since it is much simpler.
10+
11+
</Alert>
12+
713
You can configure your [OpenTelemetry SDK](https://opentelemetry.io/) to send traces and spans to Sentry.
814

915
## Install

0 commit comments

Comments
 (0)