Skip to content

Conversation

@Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Nov 6, 2025

The root cause was that with_sentry_transaction() created a new Hub with the transaction context, but then in worker.rs the code called .bind_hub(Hub::current()) which bound the future to the original Hub instead of the new one. This meant all child tracing spans were attached to the wrong Hub that lacked the transaction context, so Sentry never saw them as children of the transaction.

The fix moves the .bind_hub(hub) call inside with_sentry_transaction() so the callback future executes with the correct Hub that has the transaction, ensuring all child spans are properly associated with the parent transaction.


Disclaimer: Claude Code figured this out. At first it looked in entirely the wrong places, but once I nudged it into looking at the right areas it found the issue. I didn't trust it, so I tested it out on staging and it indeed seems to solve the problem

Before

Bildschirmfoto 2025-11-06 um 12 50 50

After

Bildschirmfoto 2025-11-06 um 12 50 40

The root cause was that `with_sentry_transaction()` created a new Hub
with the transaction context, but then in `worker.rs` the code called
`.bind_hub(Hub::current())` which bound the future to the original Hub
instead of the new one. This meant all child tracing spans were
attached to the wrong Hub that lacked the transaction context, so
Sentry never saw them as children of the transaction.

The fix moves the `.bind_hub(hub)` call inside `with_sentry_transaction()`
so the callback future executes with the correct Hub that has the
transaction, ensuring all child spans are properly associated with
the parent transaction.
@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Nov 6, 2025
@Turbo87 Turbo87 requested a review from a team November 6, 2025 12:50
Copy link
Contributor

@LawnGnome LawnGnome left a comment

Choose a reason for hiding this comment

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

I obviously don't know the Sentry API well, but that makes intuitive sense to me based on my past life as an observability developer, so combined with it working on staging: 👍

@Turbo87 Turbo87 merged commit 346b111 into rust-lang:main Nov 6, 2025
10 checks passed
@Turbo87 Turbo87 deleted the sentry-tracing branch November 6, 2025 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants