Support recording exception frame's local variables for requests#1580
Merged
Support recording exception frame's local variables for requests#1580
Conversation
2716e5e to
515adbb
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1580 +/- ##
==========================================
- Coverage 98.53% 98.47% -0.06%
==========================================
Files 127 127
Lines 7022 7091 +69
==========================================
+ Hits 6919 6983 +64
- Misses 103 108 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
845ae21 to
f6aecf2
Compare
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.
Introduction
This PR introduces a new feature to capture local variables when an exception is raised. For example, given this script:
The captured exception will contain the value of local variable
aandb.Here are some screenshots:
From this SDK's demo application
From my company's application with a real error
This feature needs to be activated with the new
capture_exception_frame_localsconfig option:So if you don't want to use it, it won't affect your application.
Reason
It's the dream, isn't it 😉
Limitations & Caveats
Sentry::CaptureExceptionsmiddleware. Background job support will come later.Fullstacktrace view.Rails.application.config.filter_parameters.Performance Impact
TL;DR:
Benchmark (with Ruby 2.7.4)
When the local-capturing
TracePointis enable, exception handling slows down significantly.However, our applications don't just raise exceptions and do nothing. So let's simulate some extra timespent on other stuff with sleep (just 50 ms):
Since Ruby's exception raising/rescuing are pretty fast, the extra overhead added by
TracePointisn't even observable in this case.Future Development
If this approach is proved working, we can enhance it in 2 directions:
The 2nd enhancement may be the most-desirable feature to add. However, its overhead may be significant because the SDK will need to walk through every frame for collecting local variables, and do that for every exception raised. So it's possible that we need to introduce it with extra configurations to reduce the overhead (e.g. only capture certain number of frames or certain exceptions).