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

feature request: sentry integration #20

Open
yokomotod opened this issue Sep 24, 2021 · 1 comment
Open

feature request: sentry integration #20

yokomotod opened this issue Sep 24, 2021 · 1 comment

Comments

@yokomotod
Copy link

yokomotod commented Sep 24, 2021

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
@yokomotod
Copy link
Author

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)
		})
	}

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

No branches or pull requests

1 participant