-
I use Sentry in my Go App - Gin and I set scope in a middleware.
ConfigureScope is configured globally or per each transaction/request that Gin handles? |
Beta Was this translation helpful? Give feedback.
Answered by
cleptric
Apr 10, 2024
Replies: 1 comment 3 replies
-
https://docs.sentry.io/platforms/go/usage/concurrency/ You might end up with something we call scope bleed by using the global function; hence I recommend something like this in your middleware: hub := sentry.GetHubFromContext(ctx)
if hub != nil {
hub.ConfigureScope(func(scope *sentry.Scope) {
scope.SetUser(sentry.User{Email: "[email protected]"})
})
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, the hub is cloned on each request, and the correct scoping is guaranteed per request.
See https://github.com/getsentry/sentry-go/blob/master/gin/sentrygin.go#L54-L59