fix(coderd/batchstats): use debug log on context cancellation in flush (#9777)

This commit is contained in:
Mathias Fredriksson
2023-09-19 16:19:39 +03:00
committed by GitHub
parent 7bc98c296b
commit d6089ae0ad

View File

@ -243,6 +243,10 @@ func (b *Batcher) flush(ctx context.Context, forced bool, reason string) {
err = b.store.InsertWorkspaceAgentStats(ctx, *b.buf)
elapsed := time.Since(start)
if err != nil {
if xerrors.Is(err, context.Canceled) {
b.log.Debug(ctx, "context canceled, skipping insert of workspace agent stats", slog.F("elapsed", elapsed))
return
}
b.log.Error(ctx, "error inserting workspace agent stats", slog.Error(err), slog.F("elapsed", elapsed))
return
}