Skip to content

Span#with_child_span should finish the span even with exception raised#1982

Merged
st0012 merged 2 commits intomasterfrom
handle-with_child_span-exception
Jan 9, 2023
Merged

Span#with_child_span should finish the span even with exception raised#1982
st0012 merged 2 commits intomasterfrom
handle-with_child_span-exception

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Jan 7, 2023

This saves users from doing complicated exception handling logic inside their operation block to save the span data, such as

span.with_child_span do |child_span|
  begin
    do_something
  rescue
    child_span.finish
    raise
  end
end

Now users only need:

span.with_child_span do |child_span|
  do_something
end

I consider this a bug fix because I thought it's already working this way 😅

This saves users from doing complicated exception handling logic inside
their operation block to save the span data, such as

```rb
span.with_child_span do |child_span|
  begin
    do_something
  rescue
    child_span.finish
    raise
  end
end
```
@st0012 st0012 added this to the 5.8.0 milestone Jan 7, 2023
@st0012 st0012 self-assigned this Jan 7, 2023
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 7, 2023

Codecov Report

Base: 98.62% // Head: 98.62% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (7b00f43) compared to base (31e5423).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1982   +/-   ##
=======================================
  Coverage   98.62%   98.62%           
=======================================
  Files         157      157           
  Lines        9870     9881   +11     
=======================================
+ Hits         9734     9745   +11     
  Misses        136      136           
Impacted Files Coverage Δ
sentry-ruby/lib/sentry/span.rb 100.00% <100.00%> (ø)
sentry-ruby/spec/sentry/span_spec.rb 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@st0012 st0012 requested a review from sl0thentr0py January 7, 2023 17:39
Copy link
Copy Markdown
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

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

yep, this matches python behaviour now since there it's a context manager which automatically does the rescue

@st0012 st0012 merged commit c1948a8 into master Jan 9, 2023
@st0012 st0012 deleted the handle-with_child_span-exception branch January 9, 2023 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants