Repository navigation
fix(tracing): finish child spans when blocks unwind - #3207
Open
itsrayeedscodespace wants to merge 1 commit into
Open
itsrayeedscodespace wants to merge 1 commit into
itsrayeedscodespace wants to merge 1 commit into
Conversation
Finish child spans in ensure so nonlocal return, break, throw, and exceptions outside StandardError cannot leave unfinished spans that disappear from transaction events. Preserve block control flow, exception propagation, and the direct Span return value. Co-Authored-By: GPT-6 <gpt-6@noreply.example.com>
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.
Description
Sentry.with_child_spanloses spans when the block exits throughbreak, a nonlocalreturn,throw, or an exception outsideStandardError.Span#with_child_spanonly finishes after a normal yield or in itsrescuebranch. The hub restores its parent scope, but the child retains a nil timestamp andTransactionEventexcludes it.Move finalization into
ensure, scoped around the block execution. Keep the existing StandardError status handling, exception propagation, and directSpan#with_child_spanreturn value.Four public-API regression specs fail on unchanged master: the captured transaction has zero child spans. They pass with the fix and verify that the span reaches the transaction event, the parent scope is restored, and control-flow values/original exceptions are preserved. Existing specs continue covering normal completion and StandardError status handling.
Validation (Ruby 3.4.12, committed
ruby-3.4_rack-3_redis-4matrix cell):git diff --checkFixes #3206
Related: the original exception-handling fix in #1982.
Linear: RUBY-243