@@ -11,6 +11,7 @@ import (
11
11
"cdr.dev/slog"
12
12
13
13
"github.com/coder/coder/coderd/database"
14
+ "github.com/coder/coder/coderd/database/dbauthz"
14
15
)
15
16
16
17
const (
@@ -293,12 +294,12 @@ func (sc *StatsCollector) rollup() []StatsReport {
293
294
}
294
295
295
296
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" )
297
298
defer func () {
298
299
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 )
300
301
} else {
301
- sc .opts .Logger .Debug (sc . ctx , "flushed workspace app stats" )
302
+ sc .opts .Logger .Debug (ctx , "flushed workspace app stats" )
302
303
}
303
304
}()
304
305
@@ -361,7 +362,8 @@ func (sc *StatsCollector) start() {
361
362
// Ensure we don't hold up this request for too long. Add a few
362
363
// seconds to prevent very short intervals from causing a timeout.
363
364
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 ))
365
367
cancel ()
366
368
367
369
// For tests.
0 commit comments