feat(reporter/sentry): filtering funcs to set custom error level on sentry#18
feat(reporter/sentry): filtering funcs to set custom error level on sentry#18
Conversation
reporter/sentry/options.go
Outdated
|
|
||
| var ( | ||
| defaultErrorLevelFuncs = []ErrorLevelFunc{ | ||
| ErrorIsFunc(context.DeadlineExceeded, sentry.LevelWarning), |
There was a problem hiding this comment.
Won't this hide some big errors ? Like deadlock or things like that ?
There was a problem hiding this comment.
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 👀
lordteka
left a comment
There was a problem hiding this comment.
Nice improvment, also nice effort on the doc/comment
reporter/sentry/options.go
Outdated
| } | ||
| } | ||
|
|
||
| // ErrorCauseTextContainsFunc an ErrorLevelFunc of the passed level that checks |
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.
| func AppendErrorLevelFuncs(funcs []ErrorLevelFunc) Option { | |
| func AppendErrorLevelFuncs(funcs ...ErrorLevelFunc) Option { |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.