Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 1bdcc1e

Browse files
authored
feat(otel): Add otel context to errors (#838)
1 parent 7cd539a commit 1bdcc1e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/docs/sdk/performance/opentelemetry.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ function generateSentryErrorsFromOtelSpan(otelSpan) {
384384

385385
Sentry.captureException(syntheticError, {
386386
contexts: {
387+
otel: {
388+
attributes: otelSpan.attributes,
389+
resource: otelSpan.resource.attributes,
390+
},
387391
trace: {
388392
trace_id: otelSpan.spanContext().traceId,
389393
span_id: otelSpan.spanContext().spanId,
@@ -722,7 +726,7 @@ OpenTelemetry, has the concept of [Span Events](https://github.com/open-telemetr
722726
723727
In Sentry, we have two options for how to treat span events. First, we can add them as breadcrumbs to the transaction the span belongs to. Second, we can create an artificial "point-in-time" span (a span with 0 duration), and add it to the span tree. TODO on what approach we take here.
724728

725-
In the special case that the span event is an exception span, [where the `name` of the span event is `exception`](https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/exceptions/), we also have the possibility of generating a Sentry error from an exception. In this case, we can create this [exception based on the attributes of an event](https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/exceptions/#attributes), which include the error message and stacktrace. This exception can also inherit all other attributes of the span event + span as tags on the event.
729+
In the special case that the span event is an exception span, [where the `name` of the span event is `exception`](https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/exceptions/), we also have the possibility of generating a Sentry error from an exception. In this case, we can create this [exception based on the attributes of an event](https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/exceptions/#attributes), which include the error message and stacktrace. This exception can also inherit all other attributes of the span event + span as tags on the event. This is addressed by Step 7, where you add `generateSentryErrorsFromOtelSpan` to the `SpanProcessor` pipeline.
726730

727731
In the OpenTelemetry Sentry exporter, we've used this [strategy to generate Sentry errors](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/8eda2f80b6dbd5aea03ca699c3ad1454714156d0/exporter/sentryexporter/sentry_exporter.go#L169-L196).
728732

@@ -759,8 +763,6 @@ interface OpenTelemetryContext {
759763
}
760764
```
761765

762-
The reason sdk and service are split are so they can be indexed as top level fields in the future for easier usage within Sentry.
763-
764766
## SDK Spec
765767

766768
- SpanProcessor: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#span-processor

0 commit comments

Comments
 (0)