Add POST /api/admin/reset-latency endpoint

Zeroes block-update latency counters (count, sum, last, wasted work)
in both memory and the kv store. Used by the StartOS reset-latency
action to let operators start fresh after tuning.
This commit is contained in:
satoshi
2026-05-11 02:18:14 +03:00
parent 6acff6280f
commit 72890d900b
2 changed files with 24 additions and 0 deletions
+18
View File
@@ -113,6 +113,24 @@ func (a *Aggregator) IngestLatencyEvents(ctx context.Context, events <-chan logm
}
}
// ResetLatency zeroes the block-update latency counters both in memory
// and in the persistent kv store.
func (a *Aggregator) ResetLatency() {
a.mu.Lock()
a.latencyCount = 0
a.latencySumMs = 0
a.latencyLastMs = 0
a.staleWorkHashes = 0
a.mu.Unlock()
if a.Store != nil {
_ = a.Store.SetKV(kvLatencyCount, "0")
_ = a.Store.SetKV(kvLatencySumMs, "0")
_ = a.Store.SetKV(kvLatencyLastMs, "0")
_ = a.Store.SetKV(kvStaleWorkHashes, "0")
}
a.Log.Info("block latency stats reset")
}
// IngestBlockEvents reads block events from the tailer and appends them
// to the snapshot's block history. Runs until ctx is cancelled.
func (a *Aggregator) IngestBlockEvents(ctx context.Context, events <-chan logmon.BlockEvent) {