Skip to content

Commit 4942be3

Browse files
committed
register metrics once
Signed-off-by: Maroon Ayoub <[email protected]>
1 parent 814bcd9 commit 4942be3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/kvcache/metrics/collector.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package metrics
22

33
import (
44
"context"
5+
"sync"
56
"time"
67

78
"github.com/prometheus/client_golang/prometheus"
@@ -46,9 +47,13 @@ func Collectors() []prometheus.Collector {
4647
}
4748
}
4849

50+
var registerMetricsOnce = sync.Once{}
51+
4952
// Register registers all metrics with K8s registry.
5053
func Register() {
51-
metrics.Registry.MustRegister(Collectors()...)
54+
registerMetricsOnce.Do(func() {
55+
metrics.Registry.MustRegister(Collectors()...)
56+
})
5257
}
5358

5459
// StartMetricsLogging spawns a goroutine that logs current metric values every

0 commit comments

Comments
 (0)