Update writer.go

This commit is contained in:
sashaodessa 2025-11-18 21:59:09 +01:00 committed by GitHub
parent e0d81d1e99
commit 51dc82d6a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,7 +11,9 @@ import (
// Write sorts writes each metric in the given registry periodically to the // Write sorts writes each metric in the given registry periodically to the
// given io.Writer. // given io.Writer.
func Write(r Registry, d time.Duration, w io.Writer) { func Write(r Registry, d time.Duration, w io.Writer) {
for range time.Tick(d) { ticker := time.NewTicker(d)
defer ticker.Stop()
for range ticker.C {
WriteOnce(r, w) WriteOnce(r, w)
} }
} }