From 3bfe23dc2063bfcde7b17ae10295d30a04d96b59 Mon Sep 17 00:00:00 2001 From: Shankar Nair Date: Mon, 30 Oct 2023 15:50:12 -0700 Subject: [PATCH] fix reset of slices --- scope.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scope.go b/scope.go index 48f87f0..dd31018 100644 --- a/scope.go +++ b/scope.go @@ -302,7 +302,16 @@ func (s *scope) processLoop(interval time.Duration) { s.reportChanges(counters, gauges) s.cachedReporter.Flush() // Reset the changed counters and gauges + var zeroCounter *counter + for i := range counters { + counters[i] = zeroCounter + } counters = counters[:0] + + var zeroGauge *gauge + for i := range gauges { + gauges[i] = zeroGauge + } gauges = gauges[:0] default: return