-
-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sentry-rails' controller span nesting #1973
Conversation
Codecov ReportBase: 98.61% // Head: 98.61% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1973 +/- ##
=======================================
Coverage 98.61% 98.61%
=======================================
Files 157 157
Lines 9880 9902 +22
=======================================
+ Hits 9743 9765 +22
Misses 137 137
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. |
Yep let's make this a separate change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just one question
ced34ad
to
4c4cdb9
Compare
This makes sure all spans generated inside the controller call will be attached under the controller span instead of the request span.
Now we wrap controller action inside `Sentry.with_child_span`, we don't need to register the `ActionControllerSubscriber` anymore. However, we still can't remove it because users may reference the constant directly when customizing the tracing subscribers config.
begin | ||
result = yield | ||
ensure | ||
child_span.set_http_status(response.status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we guard for response
being nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Rails, the controller's request and response object are all generated at the beginning of the request. So in this case, we don't need to worry about it being nil
🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, see comment and ignore if not needed
As described in #1899, the controller span's nesting is not correct because we record it through ActiveSupport instrumentation.
So this PR I did a few things:
Span#with_child_span
finishes the span properly when exceptions occurred, so users don't have to add boilerplate code in every call.Sentry.with_child_span
around Rails' controller action so spans generated during actions can be attached to the controller span.ActionControllerSubscriber
. This is because tracing subscribers are public classes and removing them should be considered a breaking change.Fixes #1899