mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
Updates to Elastic logging
This commit is contained in:
parent
ae9ed0f4ee
commit
ae82bb4168
18 changed files with 150 additions and 97 deletions
|
|
@ -176,14 +176,13 @@ namespace PluralKit.Bot
|
|||
async Task HandleEventInner()
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
using var _ = LogContext.PushProperty("EventId", Guid.NewGuid());
|
||||
_logger
|
||||
.ForContext("Elastic", "yes?")
|
||||
.Verbose("Gateway event: {@Event}", evt);
|
||||
|
||||
|
||||
await using var serviceScope = _services.BeginLifetimeScope();
|
||||
|
||||
using var _ = LogContext.PushProperty("EventId", Guid.NewGuid());
|
||||
using var __ = LogContext.Push(serviceScope.Resolve<SerilogGatewayEnricherFactory>().GetEnricher(shard, 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>(), shard, evt);
|
||||
|
|
@ -218,9 +217,7 @@ namespace PluralKit.Bot
|
|||
// Make this beforehand so we can access the event ID for logging
|
||||
var sentryEvent = new SentryEvent(exc);
|
||||
|
||||
_logger
|
||||
.ForContext("Elastic", "yes?")
|
||||
.Error(exc, "Exception in event handler: {SentryEventId}", sentryEvent.EventId);
|
||||
_logger.Error(exc, "Exception in event handler: {SentryEventId}", sentryEvent.EventId);
|
||||
|
||||
// If the event is us responding to our own error messages, don't bother logging
|
||||
if (evt is MessageCreateEvent mc && mc.Author.Id == shard.User?.Id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue