From d6089ae0ad6a4bdba970b8d1df0c5870cef79d96 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 19 Sep 2023 16:19:39 +0300 Subject: [PATCH] fix(coderd/batchstats): use debug log on context cancellation in flush (#9777) --- coderd/batchstats/batcher.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coderd/batchstats/batcher.go b/coderd/batchstats/batcher.go index c97745f02a..d0b3e4fb6c 100644 --- a/coderd/batchstats/batcher.go +++ b/coderd/batchstats/batcher.go @@ -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 }