-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Configurable SentryExceptionResolver Order for getsentry/sentry-java#681 #1008
Conversation
Now this is a very rough first attempt, slightly hindered by Also, since SentryAutoConfiguration does a plain |
Thanks @timtebeek for the PR! This behaviour of catching all exceptions, even those that were handled with If we go this way, to make it easier for users to configure the SDK, instead of integer property I think a boolean |
I agree the It makes sense to me for a middleware error handler to be the last thing in the pipeline tbqh. The user should be able to handle and error and avoid it being captured completely. There are apps out there that use exceptions as control flow a lot, and throw from controllers and then "have a single place" to deal with them by type to return some known error codes. It's a fair default IMO to only capture exceptions that are not caught by such middlewares, either because they've rethrown, or they errored while processing an exception. And handled exceptions would not be reported to Sentry. In such cases users can also add their own Since this would be a breaking change we don't want to take right now, it's probably fine to go with your suggestion of having an "opt-out" only. An option called I don't have a better suggestion right now though. @marandaneto, @maciejwalkowiak ? |
sentry-spring-boot-starter/src/main/java/io/sentry/spring/boot/SentryProperties.java
Outdated
Show resolved
Hide resolved
yeah I agree with @bruno-garcia here, but not sure about the boolean. a boolean would capture either all the exception (if highest priority) or only unhandled exception if min. priority. looks like an if we decide to go for a boolean, remember that we already have a |
Codecov Report
@@ Coverage Diff @@
## main #1008 +/- ##
============================================
+ Coverage 71.98% 72.06% +0.07%
- Complexity 1322 1324 +2
============================================
Files 135 135
Lines 4816 4829 +13
Branches 492 492
============================================
+ Hits 3467 3480 +13
Misses 1091 1091
Partials 258 258
Continue to review full report at Codecov.
|
That's indeed why I thought to use an int over a boolean first/last; That way people can choose to make the exception resolver second-to-last for instance.
I'd missed that |
Anything I can do to move this issue along? There seems to be some discussion around the preferable configuration option type & name, and whether we want to import |
@maciejwalkowiak mind taking this one? as you've written the other web integrations, your opinion will be the most valuable here, thanks. |
@timtebeek thanks for updates! I will get back to you next week once I am done with some of the performance related changes. |
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.
@timtebeek thank you for your patience.
One issue with this implementation I see is that with Spring (not Spring Boot) integration we have now two ways to configure sentry - some properties using @EnableSentry(...)
annotation and some with Spring environment.
Since we already went with @EnableSentry
, I think this property exceptionResolverOrder
should be added there and the SentryExceptionResolver
as a result would be registered in the SentryHubRegistrar
.
In Spring Boot auto-configuration we would have to create this bean again, but instead of taking taking the value of exceptionResolverOrder
with @Value
we could take it directly from SentryProperties
.
Add also tests please.
@maciejwalkowiak I've updated my pull request with what I think your suggestions were; Hadn't used a |
@timtebeek I moved new property back to Spring Boot specific @marandaneto & @bruno-garcia could you please do another review? |
sentry-spring/src/main/java/io/sentry/spring/SentryHubRegistrar.java
Outdated
Show resolved
Hide resolved
sentry-spring/src/main/java/io/sentry/spring/SentryHubRegistrar.java
Outdated
Show resolved
Hide resolved
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.
thanks for doing this @timtebeek and @maciejwalkowiak :) really appreciate it.
2 small suggestions but rather than that LGTM
@maciejwalkowiak lets not squash-merge this one so you can get the rewards too :)
thanks a lot, @timtebeek and @maciejwalkowiak appreciate it. |
Glad to help, and glad to see this merged; Thanks for the finishing touches! |
📢 Type of change
📜 Description
Make SentryExceptionResolver Order configurable as per #681
💡 Motivation and Context
This allows the spring-boot-starter to be used without reporting all handled web exceptions to Sentry, which up to now blew through our quota.
💚 How did you test it?
No.
📝 Checklist
🔮 Next steps
Critique; Refine; Test; Merge