Add Elastic-bound logging of (almost) all database update events

This commit is contained in:
Ske
2020-08-27 21:28:36 +02:00
parent 8d27148bdf
commit 9955dc29f9
11 changed files with 182 additions and 45 deletions

View File

@@ -175,14 +175,14 @@ namespace PluralKit.Bot
private async Task UpdatePeriodic()
{
_logger.Information("Running once-per-minute scheduled tasks");
_logger.Debug("Running once-per-minute scheduled tasks");
await UpdateBotStatus();
// Collect some stats, submit them to the metrics backend
await _collector.CollectStats();
await Task.WhenAll(((IMetricsRoot) _metrics).ReportRunner.RunAllAsync());
_logger.Information("Submitted metrics to backend");
_logger.Debug("Submitted metrics to backend");
}
private async Task UpdateBotStatus(DiscordClient specificShard = null)

View File

@@ -101,7 +101,7 @@ namespace PluralKit.Bot
_metrics.Measure.Gauge.SetValue(BotMetrics.WebhookCacheSize, _webhookCache.CacheSize);
stopwatch.Stop();
_logger.Information("Updated metrics in {Time}", stopwatch.ElapsedDuration());
_logger.Debug("Updated metrics in {Time}", stopwatch.ElapsedDuration());
}
public class Counts

View File

@@ -81,7 +81,7 @@ namespace PluralKit.Bot
_logger
.ForContext("RequestUrlRoute", endpoint)
.Information(
.Debug(
"HTTP: {RequestMethod} {RequestUrl} -> {ResponseStatusCode} {ResponseStatusString} (in {RequestDurationMs:F1} ms)",
response.RequestMessage.Method,
response.RequestMessage.RequestUri,

View File

@@ -22,7 +22,6 @@ namespace PluralKit.Bot
var props = new List<LogEventProperty>
{
new LogEventProperty("Type", new ScalarValue(dea.EventType())),
new LogEventProperty("Shard", new ScalarValue(dea.Client.ShardId))
};
void AddMessage(DiscordMessage msg)
@@ -47,6 +46,9 @@ namespace PluralKit.Bot
props.Add(new LogEventProperty("ReactingUserId", new ScalarValue(mra.User.Id)));
props.Add(new LogEventProperty("Emoji", new ScalarValue(mra.Emoji.GetDiscordName())));
}
// Want shard last, just for visual reasons
props.Add(new LogEventProperty("Shard", new ScalarValue(dea.Client.ShardId)));
result = new StructureValue(props);
return true;