fix: put Serilog event ID / shard ID in same scope as Sentry error ID

This commit is contained in:
spiral 2022-01-20 23:38:58 -05:00
parent 7aae41c080
commit 84529f6f32
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31

View File

@ -153,14 +153,14 @@ public class Bot
return;
}
using var _ = LogContext.PushProperty("EventId", Guid.NewGuid());
using var __ = LogContext.Push(await serviceScope.Resolve<SerilogGatewayEnricherFactory>().GetEnricher(shardId, evt));
_logger.Verbose("Received gateway event: {@Event}", evt);
try
{
var queue = serviceScope.ResolveOptional<HandlerQueue<T>>();
using var _ = LogContext.PushProperty("EventId", Guid.NewGuid());
using var __ = LogContext.Push(await serviceScope.Resolve<SerilogGatewayEnricherFactory>().GetEnricher(shardId, evt));
_logger.Verbose("Received gateway event: {@Event}", evt);
// Also, find a Sentry enricher for the event type (if one is present), and ask it to put some event data in the Sentry scope
var sentryEnricher = serviceScope.ResolveOptional<ISentryEnricher<T>>();
sentryEnricher?.Enrich(serviceScope.Resolve<Scope>(), shardId, evt);