Skip to content

debug(tracing): Instrument cross-thread span flake [DO NOT MERGE]#1238

Draft
lcian wants to merge 3 commits into
masterfrom
lcian/debug/cross-thread-tx-flake
Draft

debug(tracing): Instrument cross-thread span flake [DO NOT MERGE]#1238
lcian wants to merge 3 commits into
masterfrom
lcian/debug/cross-thread-tx-flake

Conversation

@lcian

@lcian lcian commented Jul 10, 2026

Copy link
Copy Markdown
Member

Do not merge — temporary debugging

Adds throwaway instrumentation to diagnose the flaky future_cross_thread_info_span test in sentry-tracing, which intermittently (~1/30 under cargo llvm-cov) observes 0 envelopes where it expects exactly one transaction.

What it records

A global buffer (sentry_tracing::repro_diag) captures:

  • on_new_span: whether the sentry object built is a Transaction or a child Span (+ span id, thread id).
  • on_close: whether SentrySpanData was found and finish() ran, on which thread — or which no-op branch was taken (no tracing span / no SentrySpanData).

The test dumps the full buffer when the envelope count != 1, so a CI reproduction tells us definitively whether:

  1. the span was ever created as a child Span instead of a Transaction (finishing a child span emits no envelope), or
  2. on_close/finish simply never ran on the joined thread before the assertion.

Plan

Reproduce on CI via repeated reruns of the Code Coverage job, read the captured diagnostics, then revert this branch.

TEMPORARY instrumentation to diagnose the flaky
`future_cross_thread_info_span` test that intermittently observes 0
envelopes. Records, via a global buffer, whether `on_new_span` builds a
Transaction or child Span, and whether `on_close`/`finish` runs (and on
which thread). The test dumps the buffer when the envelope count is wrong.

Not for merge; used to capture a real CI reproduction.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MUAsFPraMdxyRXe8Qpswaq
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Instrument cross-thread span flake [DO NOT MERGE] ([#1238](https://github.com/getsentry/sentry-rust/pull/1238))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 9b56623

lcian and others added 2 commits July 10, 2026 16:03
Second instrumentation round for the cross-thread flake:
- wrap the future's Span in a Drop-logging newtype to record the thread
  where the future's own handle is released;
- tag thread1/thread2 ids (keyed by span name) and log on_enter/on_exit
  threads to build the cross-thread timeline;
- add a "MAIN read transport" marker to order finish() vs the test read.

Goal: determine whether on_close lands on a third thread (=> a second
Span handle) or on the future's drop thread after a concurrent
enter/exit (=> ordering).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MUAsFPraMdxyRXe8Qpswaq
Log every span in on_new_span *before* the span filter ignores it,
including its contextual parent id. This catches library-emitted
trace/debug spans and reveals whether any span is created with our
transaction's id as its contextual parent (which would clone it and pin
its ref_count until that child closes).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MUAsFPraMdxyRXe8Qpswaq
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.

1 participant