Repository navigation
fix(tracing): establish tracing capture context early enough - #3057
Open
Conversation
solnic
force-pushed
the
3015-railsrackloggers-started-log-line-and-anything-else-logged-before-sentryrailscaptureexceptions-gets-an-unrelated-trace_idspan_id
branch
2 times, most recently
from
September 4, 2026 11:05
cbde3a6 to
ceaba54
Compare
solnic
marked this pull request as ready for review
September 4, 2026 12:44
solnic
force-pushed
the
3015-railsrackloggers-started-log-line-and-anything-else-logged-before-sentryrailscaptureexceptions-gets-an-unrelated-trace_idspan_id
branch
from
October 6, 2026 08:49
5cbb0df to
06d248f
Compare
solnic
force-pushed
the
3015-railsrackloggers-started-log-line-and-anything-else-logged-before-sentryrailscaptureexceptions-gets-an-unrelated-trace_idspan_id
branch
6 times, most recently
from
October 6, 2026 11:41
b287c37 to
6c6ffa7
Compare
solnic
force-pushed
the
3015-railsrackloggers-started-log-line-and-anything-else-logged-before-sentryrailscaptureexceptions-gets-an-unrelated-trace_idspan_id
branch
from
October 6, 2026 12:43
6c6ffa7 to
0d3e728
Compare
solnic
removed this pull request from stack #3059
October 6, 2026 12:46
solnic
changed the base branch from
master
to
fix/debug-transport-log-envelopes
October 6, 2026 12:46
solnic
added this pull request to stack #3114
October 6, 2026 12:46
solnic
force-pushed
the
3015-railsrackloggers-started-log-line-and-anything-else-logged-before-sentryrailscaptureexceptions-gets-an-unrelated-trace_idspan_id
branch
from
October 6, 2026 13:07
0d3e728 to
ef1cd41
Compare
Rails::Rack::Logger's "Started ..." line (and anything logged before CaptureExceptions runs) got an unrelated trace_id, since CaptureExceptions runs after ActionDispatch::ShowExceptions. Add Sentry::Rails::CaptureContext, a minimal middleware unshifted to the front of the stack that establishes the propagation context early. CaptureExceptions now consumes and reuses it instead of regenerating a new trace_id/span_id. Co-Authored-By: GitHub Copilot <noreply@example.com>
solnic
force-pushed
the
3015-railsrackloggers-started-log-line-and-anything-else-logged-before-sentryrailscaptureexceptions-gets-an-unrelated-trace_idspan_id
branch
from
October 6, 2026 13:23
ef1cd41 to
809eae3
Compare
solnic
removed this pull request from stack #3114
October 6, 2026 13:24
solnic
added this pull request to stack #3115
October 6, 2026 13:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is based on #3016
This adds a new
Sentry::Rails::CaptureContextmiddleware that establishes the propagation context once, early.CaptureExceptionsreuses it instead of generating its own, and a transaction with no incoming trace continues the established one rather than fabricating a newtrace_id.It sits
insert_after ActionDispatch::Executor- aboveRails::Rack::Loggerso the fix covers the logging, below the file-serving middlewares so static requests never touch Sentry.Fixes #3015