feat: capture logged errors and forward them to sentry when enabled
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good

This commit is contained in:
2024-09-27 10:15:08 +02:00
parent 169578c25d
commit 867e7c549f
16 changed files with 43 additions and 39 deletions

View File

@ -56,7 +56,7 @@ func newRedisClient(conf config.RedisConfig) redis.UniversalClient {
for range timer.C {
if _, err := client.Ping(ctx).Result(); err != nil {
logger.Error(ctx, "redis disconnected", logger.E(errors.WithStack(err)))
logger.Error(ctx, "redis disconnected", logger.CapturedE(errors.WithStack(err)))
connected = false
continue
}

View File

@ -34,6 +34,10 @@ func SetupSentry(ctx context.Context, conf config.SentryConfig, release string)
return nil, errors.WithStack(err)
}
logger.SetCaptureFunc(func(err error) {
sentry.CaptureException(err)
})
flush := func() {
sentry.Flush(time.Duration(*conf.FlushTimeout))
}