Skip to content

Capture exceptions from OpenTelemetry span events #16015

Closed as not planned
Closed as not planned

Description

@sadriddin

Problem Statement

I would like to request a way to capture exceptions from OpenTelemetry span events as Sentry errors in my NestJS application. Currently, exceptions that occur and are recorded in OpenTelemetry spans are not being converted to Sentry errors, which limits my error tracking capabilities.

According to the SDK documentation (https://develop.sentry.dev/sdk/telemetry/traces/opentelemetry), exceptions from span events should be converted to Sentry errors. I noticed this feature was removed in PR #11221 with a mention that it might return as an opt-in feature in the future.

Environment

  • Sentry SDK version: "@sentry/nestjs": "^9.9.0"
  • OpenTelemetry version: "@opentelemetry/sdk-node": "0.57.2", "@opentelemetry/api": "1.9.0"
  • Platform/language: Node.js/NestJS

Solution Brainstorm

I would greatly appreciate if this feature could be reintroduced as an opt-in configuration option. I noticed this functionality is already implemented in the .NET SDK https://github.com/getsentry/sentry-dotnet/blob/762c056ea9102bf93c7dd5c4e0055d661dcf1ec8/src/Sentry.OpenTelemetry/SentrySpanProcessor.cs#L447 , which could perhaps serve as a reference for the JavaScript/Node.js implementation.

An opt-in approach would allow users who need this functionality to enable it while not affecting those who don't require it. This would be incredibly helpful for my error monitoring workflow.

Thank you for considering this request!

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 9, 2025
  2. mydea commented on Apr 9, 2025

    @mydea
    Member

    Hey, thanks for raising this. Yes, I think it makes sense to re-add this as an opt-in option! PRs are welcome, I'll put this in the backlog as we are currently pretty swamped with work.

  3. ckblockit commented on Mar 19, 2026

    @ckblockit

    subscribing and thumbs up for this feature

  4. Lms24 commented on Mar 20, 2026

    @Lms24
    Member

    PRs are still welcome :)

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 20, 2026
  6. xcscxr commented on Nov 4, 2026

    @xcscxr

    I'd like to pick this up.

    When the SDK registers its tracer provider (enableOpenTelemetrySetup: true), spans started through @opentelemetry/api are Sentry spans, so instrumentation hands the exception straight to span.recordException(), which is a no-op today.

    Proposed shape:

    • An opt-in spanExceptionsIntegration() in @sentry/core, exported from the server SDKs.
    • With it, recordException(exception) on any span, sampled or not, captures the original exception as an error linked to that span, with mechanism auto.core.span_exceptions and handled: true.
    • An exception the SDK already captured is skipped by the existing already-captured check. Nothing is captured while tracing is suppressed, for example while the SDK sends its own events.
    • Hand-written addEvent('exception', ...) events and spans from a tracer provider you register yourself are out of scope.

    Happy to rename it if you prefer another name.

  7. andreiborza commented on Nov 6, 2026

    @andreiborza
    Member

    We decided to not add this at the moment. Span events are deprecated in OTel and there hasn't been much demand for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions