Skip to content

Commit 59d69ac

Browse files
committed
use dbauthz.AsSystemRestricted for collector flush
1 parent 0561f8d commit 59d69ac

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

coderd/workspaceapps/stats.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"cdr.dev/slog"
1212

1313
"github.com/coder/coder/coderd/database"
14+
"github.com/coder/coder/coderd/database/dbauthz"
1415
)
1516

1617
const (
@@ -293,12 +294,12 @@ func (sc *StatsCollector) rollup() []StatsReport {
293294
}
294295

295296
func (sc *StatsCollector) flush(ctx context.Context) (err error) {
296-
sc.opts.Logger.Debug(sc.ctx, "flushing workspace app stats")
297+
sc.opts.Logger.Debug(ctx, "flushing workspace app stats")
297298
defer func() {
298299
if err != nil {
299-
sc.opts.Logger.Error(sc.ctx, "failed to flush workspace app stats", "error", err)
300+
sc.opts.Logger.Error(ctx, "failed to flush workspace app stats", "error", err)
300301
} else {
301-
sc.opts.Logger.Debug(sc.ctx, "flushed workspace app stats")
302+
sc.opts.Logger.Debug(ctx, "flushed workspace app stats")
302303
}
303304
}()
304305

@@ -361,7 +362,8 @@ func (sc *StatsCollector) start() {
361362
// Ensure we don't hold up this request for too long. Add a few
362363
// seconds to prevent very short intervals from causing a timeout.
363364
ctx, cancel := context.WithTimeout(context.Background(), sc.opts.ReportInterval+5*time.Second)
364-
_ = sc.flush(ctx)
365+
//nolint:gocritic // Inserting app stats is a system function.
366+
_ = sc.flush(dbauthz.AsSystemRestricted(ctx))
365367
cancel()
366368

367369
// For tests.

0 commit comments

Comments
 (0)