Commit a0a12174 authored by Roman Proskuryakov's avatar Roman Proskuryakov

Add Meter::Reset method

parent eca53f81
......@@ -53,6 +53,16 @@ func (m *Meter) Snapshot() Snapshot {
return m.snapshot
}
// Reset sets accumulator, total and rate to zero and last update to current time.
func (m *Meter) Reset() {
globalSweeper.snapshotMu.Lock()
defer globalSweeper.snapshotMu.Unlock()
atomic.StoreUint64(&m.accumulator, 0)
m.snapshot.Rate = 0
m.snapshot.Total = 0
m.snapshot.LastUpdate = time.Now()
}
func (m *Meter) String() string {
return m.Snapshot().String()
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment