Skip to content
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

sentrycore: set generated exceptionType on last exception instead of the first #60

Merged
merged 1 commit into from
May 23, 2023

Conversation

bobheadxi
Copy link
Member

@bobheadxi bobheadxi commented May 19, 2023

Every once in a while an unhelpfully formatted error shows up in our Sentry reporting:

image

After digging into this because it bothers me, turns out that even though the Sentry library says "first" exception is used for the title it actually uses the last one! Sure enough, this is mentioned in the cockroach error source:

https://github.com/cockroachdb/errors/blob/26622367a22260fa287d2f7aa2a085b0324c74ee/report/report.go#L324-L325

and we see it in action in the Sentry UI, the title is the exception we don't overwrite when there are multiple:

image

Another example: https://sourcegraph.sentry.io/issues/4193949796/?project=6583153

The errors where the title is what we want all have only 1 generated exception.

I originally thought that maybe we should overwrite each detected exception individually with a different generated message that has been tidied up, but the Sentry exception struct is a bit weird so I figured whatever, we can revisit this next time.

@bobheadxi bobheadxi requested review from a team and unknwon May 19, 2023 19:34
@bobheadxi bobheadxi changed the title sentrycore: always add generated exceptionType sentrycore: set generated exceptionType on last exception instead of the first May 19, 2023
// Source: https://github.com/cockroachdb/errors/blob/26622367a22260fa287d2f7aa2a085b0324c74ee/report/report.go#L324-L325
// We've observed this behaviour in practice as well. So here, make sure we are
// overwriting Type on the LAST exception instead of the first.
event.Exception[len(event.Exception)-1].Type = fmt.Sprintf("[%s] %s: %s",
errCtx.Scope, errCtx.Message, errors.Cause(errCtx.Error).Error())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhchabran do you recall why we take errors.Cause here? Seems like it would be helpful to have the full error, i.e. x: y: z: foobar

Copy link
Member

@unknwon unknwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bobheadxi bobheadxi merged commit ad2d71b into main May 23, 2023
@bobheadxi bobheadxi deleted the sentrycore-always-add-exception branch May 23, 2023 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants