Skip to content

Commit ca89272

Browse files
authored
feat(develop): Add capture_exceptions section to OTLP (#15838)
## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs)
1 parent 4261611 commit ca89272

File tree

1 file changed

+13
-2
lines changed
  • develop-docs/sdk/telemetry/traces

1 file changed

+13
-2
lines changed

develop-docs/sdk/telemetry/traces/otlp.mdx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ Concurrently to the above SDK work, we also shipped first-class support for inge
2323
The new integration MUST be called `OTLPIntegration` with the following signature:
2424

2525
```python
26-
OTLPIntegration(setup_otlp_traces_exporter=True, setup_propagator=True)
26+
OTLPIntegration(setup_otlp_traces_exporter=True, setup_propagator=True, capture_exceptions=False)
2727
```
2828

29-
The arguments `setup_otlp_traces_exporter` and `setup_propagator` MUST be booleans that default to `True` and can be turned off if needed by the user.
29+
The arguments `setup_otlp_traces_exporter`, `setup_propagator` and `capture_exceptions` MUST be booleans that default to `True`, `True` and `False` respectively and can be turned off if needed by the user.
3030

3131
It MUST consist of and setup the following components:
3232

3333
* A `SpanExporter` that automatically configures the OTLP ingestion endpoint from the DSN
3434
* A `Propagator` that ensures Distributed Tracing works with other upstream and downstream services using Sentry SDKs
3535
* Note that we use the `sentry-trace` (NOT `traceparent`) and `baggage` headers here
3636
* An `external_propagation_context` that extracts the active `trace_id` and `span_id` from the OpenTelemetry SDK
37+
* An interceptor for OpenTelemetry's `Span.record_exception` method that sends those exceptions to Sentry
3738

3839
### SpanExporter
3940

@@ -93,6 +94,16 @@ See the reference Python implementation:
9394
<GitHubCodePreview url="https://github.com/getsentry/sentry-python/blob/c68c3d6b5152b879bc107f76d9a9c78e95792235/sentry_sdk/integrations/otlp.py#L23-L33" />
9495
<GitHubCodePreview url="https://github.com/getsentry/sentry-python/blob/c68c3d6b5152b879bc107f76d9a9c78e95792235/sentry_sdk/integrations/otlp.py#L70" />
9596

97+
### Exception interceptor
98+
99+
OpenTelemetry users and instrumentation use `Span.record_exception` to record exceptions on spans during the execution flow. For convenience, where possible, we
100+
setup a monkeypatch for this method that intercepts and reports this exception to Sentry as well IF `capture_exceptions` is enabled on the integration.
101+
102+
Caveat: Most of the time, some existing Sentry integration will capture those exceptions too so depending on which one is captured first, the `DedupeIntegration` will typically drop either the Sentry or the OpenTelemetry captured exception which is fine from a product experience POV.
103+
104+
See the reference Python implementation:
105+
<GitHubCodePreview url="https://github.com/getsentry/sentry-python/blob/e275c9e94323b429f39196881fb992d81a2e52ea/sentry_sdk/integrations/otlp.py#L93-L119" />
106+
96107
## Comparison to POTEL
97108

98109
Note the difference in components above to the components in the POTEL implementation:

0 commit comments

Comments
 (0)