mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix(coderd/agentapi/metadatabatcher): use clock.Since instead of time.Since in flush (#22841)
The `flush` method sets `start := b.clock.Now()` but later computes duration with `time.Since(start)` instead of `b.clock.Since(start)` for the `FlushDuration` metric and the debug log. Line 352 already uses `b.clock.Since(start)` correctly — this makes the rest consistent. Test output before fix: ``` flush complete count=100 elapsed=19166h12m30.265728663s reason=scheduled ``` After fix: ``` flush complete count=100 elapsed=0s reason=scheduled ```
This commit is contained in:
committed by
GitHub
parent
3f939375fa
commit
95bd099c77
@@ -387,9 +387,9 @@ func (b *Batcher) flush(ctx context.Context, reason string) {
|
||||
b.Metrics.BatchSize.Observe(float64(count))
|
||||
b.Metrics.MetadataTotal.Add(float64(count))
|
||||
b.Metrics.BatchesTotal.WithLabelValues(reason).Inc()
|
||||
b.Metrics.FlushDuration.WithLabelValues(reason).Observe(time.Since(start).Seconds())
|
||||
elapsed = b.clock.Since(start)
|
||||
b.Metrics.FlushDuration.WithLabelValues(reason).Observe(elapsed.Seconds())
|
||||
|
||||
elapsed = time.Since(start)
|
||||
b.log.Debug(ctx, "flush complete",
|
||||
slog.F("count", count),
|
||||
slog.F("elapsed", elapsed),
|
||||
|
||||
Reference in New Issue
Block a user