fix(webui): make metrics history immune to system-clock changes
Every sample was stamped with time.Now(), so a timezone switch or NTP step punched a multi-hour gap into the series: old points collapsed to the left edge, new points bunched at the right, joined by one diagonal. Stamp rows from a monotonic seqClock instead — seeded once from the wall clock (or the newest persisted row) and thereafter advanced only by the monotonic elapsed time between writes. Rebase Downsample/Prune on the newest sample rather than time.Now() so a clock step just before the hourly compaction can't drop fresh data. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GofKhuF9xQHaz3UFfncR6D
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
4953bb33b2
commit
f31971f440
@@ -393,9 +393,8 @@ func (h *handler) startMetricsCollector() {
|
||||
h.setLatestMetric(sample)
|
||||
case <-pruneTicker.C:
|
||||
if h.metricsDB != nil {
|
||||
now := time.Now().UTC()
|
||||
_ = h.metricsDB.Downsample(now.Add(-metricsDownsampleAge), now.Add(-metricsRetainWindow))
|
||||
_ = h.metricsDB.Prune(now.Add(-metricsRetainWindow))
|
||||
_ = h.metricsDB.Downsample(metricsDownsampleAge, metricsRetainWindow)
|
||||
_ = h.metricsDB.Prune(metricsRetainWindow)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user