From 51dc82d6a4de6ebb08c8c5cce0b3ce9a6a4b3083 Mon Sep 17 00:00:00 2001 From: sashaodessa <140454972+sashaodessa@users.noreply.github.com> Date: Tue, 18 Nov 2025 21:59:09 +0100 Subject: [PATCH] Update writer.go --- metrics/writer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metrics/writer.go b/metrics/writer.go index 2a41f8e1fe..6ad2baf902 100644 --- a/metrics/writer.go +++ b/metrics/writer.go @@ -11,7 +11,9 @@ import ( // Write sorts writes each metric in the given registry periodically to the // given 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) } }