Skip to content

feat(core): Add spanExceptionsIntegration to capture exceptions recorded on spans - #26115

Open
xcscxr wants to merge 1 commit into
getsentry:developfrom
xcscxr:yuuki/span-exceptions-integration
Open

xcscxr wants to merge 1 commit into
getsentry:developfrom
xcscxr:yuuki/span-exceptions-integration

Conversation

@xcscxr

@xcscxr xcscxr commented Nov 4, 2026 •

Copy link
Copy Markdown

Why: With enableOpenTelemetrySetup: true, OpenTelemetry instrumentation records errors through span.recordException(), which is a no-op on Sentry spans, so those errors never reach Sentry. spanExceptionsIntegration() captures them, linked to the span; it's opt-in because instrumentation also records errors the app handles, which is why #11221 removed the span processor version.

How to review: Start with packages/core/src/integrations/spanExceptions.ts and the recordException hook both span classes now emit; the rest is re-exports. It skips exceptions recorded while tracing is suppressed and captures with tracing suppressed, so the SDK's own failing requests or I/O in beforeSend can't loop back into it.

Unsure about:

  • The name, proposed in Capture exceptions from OpenTelemetry span events #16015 and easy to change.
  • If a span records an error before an SDK handler captures the same object, the first event, with this integration's handled: true mechanism, is the one kept.
  • BullMQ forwards retried Redis and lock errors to recordException(), so those are captured too, and a job that then fails is also reported as job failed.
  • Only the SDK's suppressTracing() is honored, not OpenTelemetry's own suppression key, because core can't read the OpenTelemetry context.

Closes #16015

…ded on spans

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the external PR from an external contributor label Nov 4, 2026
@xcscxr
xcscxr marked this pull request as ready for review November 4, 2026 19:08
@xcscxr
xcscxr requested review from a team as code owners November 4, 2026 19:08
@xcscxr
xcscxr requested review from chargome, isaacs, logaretm, mydea and s1gr1d and removed request for a team November 4, 2026 19:08

This branch has not been deployed

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

Labels

external PR from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Capture exceptions from OpenTelemetry span events

1 participant