Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9219044

Browse files
authored
fix(coderd/metricscache): avoid logging error for no rows (#12988)
Fixes #12938
1 parent 6b4eb03 commit 9219044

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

coderd/metricscache/metricscache.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func (c *Cache) refreshDeploymentStats(ctx context.Context) error {
162162
}
163163

164164
func (c *Cache) run(ctx context.Context, name string, interval time.Duration, refresh func(context.Context) error) {
165+
logger := c.log.With(slog.F("name", name), slog.F("interval", interval))
165166
ticker := time.NewTicker(interval)
166167
defer ticker.Stop()
167168

@@ -173,15 +174,13 @@ func (c *Cache) run(ctx context.Context, name string, interval time.Duration, re
173174
if ctx.Err() != nil {
174175
return
175176
}
176-
c.log.Error(ctx, "refresh", slog.Error(err))
177+
if xerrors.Is(err, sql.ErrNoRows) {
178+
break
179+
}
180+
logger.Error(ctx, "refresh metrics failed", slog.Error(err))
177181
continue
178182
}
179-
c.log.Debug(
180-
ctx,
181-
name+" metrics refreshed",
182-
slog.F("took", time.Since(start)),
183-
slog.F("interval", interval),
184-
)
183+
logger.Debug(ctx, "metrics refreshed", slog.F("took", time.Since(start)))
185184
break
186185
}
187186

0 commit comments

Comments
 (0)