From 05b60bd0be615584a57069fb5e072ac39fb12a86 Mon Sep 17 00:00:00 2001 From: Amir Abushareb Date: Thu, 20 Jul 2023 18:01:50 +0100 Subject: [PATCH] stats: use *time.Ticker instead of time.After() (#13492) Signed-off-by: Amir Abushareb Signed-off-by: Manan Gupta Co-authored-by: Manan Gupta --- go/stats/rates.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go/stats/rates.go b/go/stats/rates.go index 7aa4f7d3ce7..cc57c45910e 100644 --- a/go/stats/rates.go +++ b/go/stats/rates.go @@ -94,9 +94,11 @@ func NewRates(name string, countTracker CountTracker, samples int, interval time } func (rt *Rates) track() { + t := time.NewTicker(rt.interval) + defer t.Stop() for { rt.snapshot() - <-time.After(rt.interval) + <-t.C } }