zerodriver
zerodriver copied to clipboard
feature request: sentry integration
I think it's common pattern that logging error and sending events to monitoring service like Sentry, when an error happens.
so it's nice if this logger support sentry, like https://github.com/archdx/zerolog-sentry
some requirements image:
- can enable/disable sentry sending per each
.Msg()call - automatically set sentry event's error level according to logger's error level
- works with sentry's additional package like https://docs.sentry.io/platforms/go/guides/http/ (automatically set http request info to sentry events)
- automatically set logger's label data to sentry events
note:
works with sentry's additional package like https://docs.sentry.io/platforms/go/guides/http/ (automatically set http request info to sentry events)
below snippet will works on sentry side by using http request info.
hub := sentry.GetHubFromContext(ctx)
if hub != nil {
hub.WithScope(func(scope *sentry.Scope) {
scope.SetLevel(level)
hub.CaptureException(exception)
})
} else {
sentry.WithScope(func(scope *sentry.Scope) {
scope.SetLevel(level)
sentry.CaptureException(exception)
})
}