Skip to content

Commit

Permalink
stats: use *time.Ticker instead of time.After() (#13492)
Browse files Browse the repository at this point in the history
Signed-off-by: Amir Abushareb <yields@icloud.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
Co-authored-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
yields and GuptaManan100 authored Jul 20, 2023
1 parent daedc54 commit 05b60bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/stats/rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 05b60bd

Please sign in to comment.