Skip to content

Commit c12ac24

Browse files
authored
Added basic docs for basic otel support in Python SDK. (#5962)
1 parent 1f157e3 commit c12ac24

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Note>
2+
3+
Sentry requires `opentelemetry-distro` version `0.350b0` or higher.
4+
5+
</Note>
6+
7+
```bash
8+
pip install --upgrade 'sentry-sdk[opentelemetry]'
9+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Initialize Sentry for tracing and set the `instrumenter` to `otel`:
2+
3+
```python
4+
import sentry_sdk
5+
6+
sentry_sdk.init(
7+
dsn="___PUBLIC_DSN___",
8+
traces_sample_rate=1.0,
9+
# set the instrumenter to use OpenTelemetry instead of Sentry
10+
instrumenter="otel",
11+
)
12+
```
13+
14+
This disables all Sentry instrumentation and relies on the chosen OpenTelemetry tracers for creating spans.
15+
16+
Next, configure OpenTelemetry as you need and hook in the Sentry span processor and propagator:
17+
18+
```python
19+
from opentelemetry import trace
20+
from opentelemetry.propagate import set_global_textmap
21+
from sentry_sdk.integrations.opentelemetry import SentrySpanProcessor, SentryPropagator
22+
23+
provider = trace.get_tracer_provider()
24+
provider.add_span_processor(SentrySpanProcessor())
25+
set_global_textmap(SentryPropagator())
26+
```

src/platforms/common/performance/instrumentation/opentelemetry.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
title: OpenTelemetry Support
33
sidebar_order: 20
44
supported:
5-
- node
65
- javascript.nextjs
6+
- node
7+
- python
78
- ruby
89
notSupported:
910
- javascript
10-
- python
1111
- dart
1212
- flutter
1313
- react-native

0 commit comments

Comments
 (0)