-
Notifications
You must be signed in to change notification settings - Fork 0
feat(reporter/sentry): filtering funcs to set custom error level on sentry #18
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
Conversation
reporter/sentry/options.go
Outdated
|
|
||
| var ( | ||
| defaultErrorLevelFuncs = []ErrorLevelFunc{ | ||
| ErrorIsFunc(context.DeadlineExceeded, sentry.LevelWarning), |
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.
Won't this hide some big errors ? Like deadlock or things like that ?
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.
Thankfully this doesn't hide them, simply marks them as severity "Warning", which will allow us to have 2 different boards (one for errors, one for warnings), which ought to filter a lot of the noise.
We'll still notice if we have 3000 warnings rise up all of a sudden 👀
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.
Yeah ok nice :)
lordteka
left a comment
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.
Nice improvment, also nice effort on the doc/comment
reporter/sentry/options.go
Outdated
| } | ||
| } | ||
|
|
||
| // ErrorCauseTextContainsFunc an ErrorLevelFunc of the passed level that checks |
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.
missing a word here
karitham
left a comment
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.
🚀
reporter/sentry/options.go
Outdated
| } | ||
|
|
||
| // AppendErrorLevelFuncs adds the passed funcs to the ErrorLevelFuncs of the Reporter | ||
| func AppendErrorLevelFuncs(funcs []ErrorLevelFunc) Option { |
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.
| func AppendErrorLevelFuncs(funcs []ErrorLevelFunc) Option { | |
| func AppendErrorLevelFuncs(funcs ...ErrorLevelFunc) Option { |
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.
clever man
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.
UX improvements through the roof.
You can do the replace one as well but I think that one is less important, and it makes sense there to pass nil to remove any filtering, wheras ReplaceErrorLevelFuncs() isn't really self-descriptive
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.
Yeap, and I feel like it expects a "whole" array for replacement rather than a variadic
It most likely also won't be used much 😄
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.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| } | ||
|
|
||
| return "" | ||
| } |
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.
Nil error causes panic in ErrorCauseTextContainsLevel mapper
The ErrorCauseTextContainsLevel function doesn't handle nil errors gracefully. Calling base.UnwrapAll(nil).Error() will panic because UnwrapAll(nil) returns nil, and invoking .Error() on a nil error interface causes a nil pointer dereference. This is inconsistent with ErrorIsLevel and ErrorIsOfTypeLevel, which both handle nil errors safely (via uerrors.Is and uerrors.IsOfType). While current usage is protected by the nil check in buildEvent, this public API function could panic if used directly with a nil error.
| stringPrefix(reporter.HTTPRequestHeaderKeyPrefix), | ||
| stringPrefix(reporter.HTTPRequestQueryValuesKeyPrefix), | ||
| }, | ||
| type ErrorLevelMapper func(error) sentry.Level |
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.
I saw that you applied the comment https://github.com/upfluence/errors/pull/18/changes#r2578258351 in the reporter.go file can you apply the comment in this file as well
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.
Well, for exported names, we had that conversation previously with @Sypheos and @karitham : #18 (comment), not sure it's a very good idea for clarity's sake to just call them LevelFuncs, for instance, unless you have a better idea?
For private constructions I don't mind
What does this PR do?
Fixes #
What are the observable changes?
Good PR checklist
Additional Notes
Note
Adds configurable error-level mapping to Sentry events and updates reporter behavior accordingly.
ErrorLevelMapperand helpers (ErrorIsLevel,ErrorIsOfTypeLevel[T],ErrorCauseTextContainsLevel) withdefaultErrorLevelMappersmapping common transient errors (e.g.,context.DeadlineExceeded,io.EOF, TLS handshake timeouts) towarningOptionswithErrorLevelMappersand new option funcs:AppendErrorLevelMappersandReplaceErrorLevelMappersdefaultOptionsvar withdefaultOptions()and wireslevelMappersintoReporterbuildEventnow setsevt.LevelviacomputeLevel(err)(defaults toerrorwhen no mapper matches)Written by Cursor Bugbot for commit c51e6c2. This will update automatically on new commits. Configure here.