sentry-go icon indicating copy to clipboard operation
sentry-go copied to clipboard

Adding context.Context hub extractor for sentry-logrus integration

Open 090809 opened this issue 2 years ago • 2 comments

Ho-ho-ho!

Problem: When using sentry-logrus integration, it's no option for capturing events with connected traces, 'cause scopes between global sentry and hook integration isn't same.

Probably solution: There no way to "just add hook.NewFromHub(levels, hub)", -> it will race condition.

Solution: Adding custom extraction for sentry.Hub from current context (with using logrus.WithContext(ctx) and injected sentry.Hub to ctx via SetHubOnContext, or any middlewares, or smth else) solves this clearly.

Current change doesn't broke current API, but it gives ability for resolving explained problem.

P.S.: Probably, test isn't clearly, but I not found any more clear solution for test this, whithout more API changing

090809 avatar Jan 01 '23 15:01 090809

Hello, @cleptric. Any comments for this? Do I need to resolve typo, or smth else?

090809 avatar Jan 12 '23 11:01 090809

@090809 Thanks for the contribution. We are currently busy with other things but will take a look as soon as we wrap up.

cleptric avatar Jan 12 '23 11:01 cleptric