From a7eab788e44c2701b2839c0a70f79383dd734642 Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Sat, 18 Feb 2023 09:31:01 -0800 Subject: [PATCH] metrics: add SetInt64 to ease using LabelMap for gauge metrics Set is provided by the underlying Map. Signed-off-by: Maisem Ali --- metrics/metrics.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/metrics/metrics.go b/metrics/metrics.go index 94d4a01ac..5a323dc38 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -33,6 +33,11 @@ type LabelMap struct { expvar.Map } +// SetInt64 sets the *Int value stored under the given map key. +func (m *LabelMap) SetInt64(key string, v int64) { + m.Get(key).Set(v) +} + // Get returns a direct pointer to the expvar.Int for key, creating it // if necessary. func (m *LabelMap) Get(key string) *expvar.Int {