Skip to content

fix(tracing): report spans that outlive their sent parent - #1163

Open
solnic wants to merge 1 commit into
masterfrom
fix/otel-orphan-span-promotion
Open

fix(tracing): report spans that outlive their sent parent#1163
solnic wants to merge 1 commit into
masterfrom
fix/otel-orphan-span-promotion

Conversation

@solnic

@solnic solnic commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

A span that outlives its transaction root (ie async work via Tasks/Broadway/Oban continuing a trace after the root was reported) was either corrupted or lost:

  • If it was still running when the root ended, it was serialized into the root transaction with "timestamp": null — Relay patches that into a zero-duration span with a bogus deadline_exceeded status (first screenshot; the span actually ran for 500ms and succeeded).
  • Once it finished, it was silently dropped.

Unfinished children are now excluded from the transaction payload, and sent transaction roots leave a short-lived marker in span storage. A span ending with a marked parent is promoted to a follow-up transaction in the same trace - same trace_id, parent_span_id pointing at the sent root, tagged sentry.parent_span_already_sent: true.

Before

image image

After

image

Fixes #1011

@solnic solnic changed the title fix(tracing): report spans that outlive their sent parent (#1011) fix(tracing): report spans that outlive their sent parent Aug 7, 2026
@solnic
solnic marked this pull request as ready for review August 7, 2026 13:49
Comment thread lib/sentry/opentelemetry/span_processor.ex Outdated
Comment thread lib/sentry/opentelemetry/span_processor.ex
Comment thread lib/sentry/opentelemetry/span_processor.ex Outdated
Comment thread lib/sentry/opentelemetry/span_processor.ex
@solnic
solnic force-pushed the fix/otel-orphan-span-promotion branch from b822b9b to 203b3c5 Compare August 7, 2026 14:44
Comment thread lib/sentry/opentelemetry/span_processor.ex Outdated
Comment thread lib/sentry/opentelemetry/span_processor.ex
@solnic
solnic marked this pull request as draft August 13, 2026 09:04
@solnic
solnic force-pushed the fix/otel-orphan-span-promotion branch from 203b3c5 to b9a2229 Compare August 13, 2026 09:09
@solnic
solnic marked this pull request as ready for review August 13, 2026 11:58

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b9a2229. Configure here.

Comment thread lib/sentry/opentelemetry/span_storage.ex
Comment thread lib/sentry/opentelemetry/span_processor.ex
@solnic
solnic force-pushed the fix/otel-orphan-span-promotion branch from b9a2229 to c15942f Compare August 13, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SpanProcessor drops child spans that start after the root ends

1 participant