-
-
Notifications
You must be signed in to change notification settings - Fork 494
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
Support capturing low-level errors propagated to Puma #2026
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #2026 +/- ##
===========================================
- Coverage 98.59% 83.20% -15.40%
===========================================
Files 159 119 -40
Lines 10499 5638 -4861
===========================================
- Hits 10352 4691 -5661
- Misses 147 947 +800
... and 82 files with indirect coverage changes 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 in Codecov by Sentry. |
This PR implements Puma's error reporting by patching `Puma::Server#lowlevel_error`. I thought about using the `lowlevel_error_handler` API to add a Sentry error handler, but it's not possible to do that after `puma.rb` is loaded (which is extremely early in a normal app setup, way before the SDK is loaded). There is also no good ways to fetch and update the server's `lowlevel_error_handler` option. So the only option left is to patch the method.
fc66bc9
to
c26bd01
Compare
@st0012 @sl0thentr0py Is it possible to opt-out from this? This makes Sentry by default catch the generally non-actionable |
How does this behave if you already use Sentry in the |
I think it'll send 2 events in this case. So I'd advise removing the custom
Sorry that I wasn't aware such exceptions would be captured too. Does adding it to |
that's is not a great solution, that handler is also used to define the HTTP response you want you application to have
I assume so (we have done that now) but I haven't verified it |
Can you consider raising a feature request on the Puma repository to facilitate doing this in a less intrusive way? (You could contribute the feature if we reach some good idea how to do it) |
Sorry I'm not saying not using that handler, just not sending events to Sentry from it now that we have this integration. |
Sentry ruby 5.9 ensured that low level puma errors were captured [1] and propagated to sentry. This ended up in a lot of noise [2] in sentry when applications were bumped to this version of sentry ruby, particularly with Puma::HttpParser errors. These errors are often unactionable and we believe a result of crawler activity. This suppresses these errors in order to reduce sentry noise. 1: getsentry/sentry-ruby#2026 2: https://govuk.sentry.io/issues/4154286086/?project=202217
There's also |
We started to see |
Apologies for the delayed response. I believe the core issue here is that I failed to implement proper exception filtering along with the feature. I will address this in a subsequent patch.
I'm open to creating a feature proposal for this, but I'm unclear about how a less intrusive API would function. Based on the comments in this thread, the problem isn't that the patch causes an infinite loop or interferes with other projects' patches, is it? As for exception captures, wouldn't |
It is not easy to opt-out of the monkey patch (even impossible perhaps?)
Yes, but if the user have a low level handler invoking Yeah, the problem was rolling this out as opt-in by default without any exclusions. You could have made it opt-in but I guess you thought the adoption of the feature would have been slow then. |
Yeah so if the problem is exception filtering, I'm sorry for not including it in the first place. However, given that
I don't plan to initiate a new API for this feature. But if you do plan to propose one, I'd love to participate the discussion and become early adopters 😄 |
No need to capture exceptions manually in the low-level error handler since getsentry/sentry-ruby#2026 Close #242
No need to capture exceptions manually in the low-level error handler since getsentry/sentry-ruby#2026 Close #242
This PR implements Puma's error reporting by patching
Puma::Server#lowlevel_error
.I thought about using the
lowlevel_error_handler
API to add a Sentry error handler, but it's not possible to do that afterpuma.rb
is loaded (which is extremely early in a normal app setup, way before the SDK is loaded). There is also no good ways to fetch and update the server'slowlevel_error_handler
option. So the only option left is to patch the method.Notes:
lowlevel_error
patch is compatible with Puma 3.0+ (current latest is 6.1). So it's pretty stable and I'm not sure if it'd be worth introducing another test matrix for Puma versions.spec_helper
as the nonappearance of the library should also be tested. This is why I added the spec underisolated
folder.I also want to improve theSentry.register_patch
API as we now have 3 patches using it and I've spotted some common boilerplate code.Closes #1511