Skip to content

feat: Log spans dropped for finishing after their transaction - #1367

Open
sentry-junior[bot] wants to merge 9 commits into
masterfrom
szokeasaurusrex/log-late-spans
Open

sentry-junior[bot] wants to merge 9 commits into
masterfrom
szokeasaurusrex/log-late-spans

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

If a span finishes after its transaction was already sent, the SDK drops it silently. This happens, for example, when a library such as sqlx's SQLite driver keeps a clone of a tracing span on a worker thread: sentry-tracing only finishes the Sentry span once the last handle to the tracing span is dropped, which can be after the transaction was finished.

This PR makes the drop easier to find:

  • Span::finish_with_timestamp now logs a debug message (with debug: true) when it drops a span because its transaction was already sent. It only logs for sampled traces, since spans in unsampled or disabled traces would not be sent anyway.
  • The sentry-tracing docs briefly explain how spans can finish after their transaction.

No client report is recorded for these spans. None of the current discard reasons in the client report spec fits this case.

The real fix is likely moving to the new span protocol (#1049, RUST-179).

Resolves #1354
Resolves RUST-291

via @szokeasaurusrex.

--

View Junior Session [Sentry]

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 6b4bc12

@linear-code

linear-code Bot commented Oct 20, 2026

Copy link
Copy Markdown

RUST-291

Comment thread sentry-tracing/src/lib.rs Resolved
Comment thread sentry-tracing/src/lib.rs Resolved
Comment thread sentry-tracing/src/lib.rs Resolved
sentry-junior Bot and others added 5 commits October 29, 2026 13:27
When a span finishes after its transaction was already sent, the SDK
silently dropped it. Log a debug message in this case, and document in
sentry-tracing how this can happen when a library keeps a clone of a
tracing span, along with a workaround.

Refs #1354
Refs RUST-291

Co-Authored-By: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>

Co-Authored-By: Dr. Daniel Szokenstein <7881302+szokeasaurusrex@users.noreply.github.com>
Co-Authored-By: Dr. Daniel Szokenstein <7881302+szokeasaurusrex@users.noreply.github.com>
Co-Authored-By: Dr. Daniel Szokenstein <7881302+szokeasaurusrex@users.noreply.github.com>
Co-Authored-By: Dr. Daniel Szokenstein <7881302+szokeasaurusrex@users.noreply.github.com>
Co-Authored-By: Dr. Daniel Szokenstein <7881302+szokeasaurusrex@users.noreply.github.com>
@sentry-junior
sentry-junior Bot force-pushed the szokeasaurusrex/log-late-spans branch from 0359473 to f9fb8df Compare October 29, 2026 13:29
Co-Authored-By: Dr. Daniel Szokenstein <7881302+szokeasaurusrex@users.noreply.github.com>
@szokeasaurusrex
szokeasaurusrex marked this pull request as ready for review October 29, 2026 13:34
@szokeasaurusrex
szokeasaurusrex requested a review from a team as a code owner October 29, 2026 13:34

@szokeasaurusrex szokeasaurusrex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please resolve merge conflict

@szokeasaurusrex

Copy link
Copy Markdown
Member

fix conflict again

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sentry-tracing: Instrumenteded sqlx queries sometimes missing from their transaction (span closed late on sqlx worker thread)

2 participants