From f267a7396fccadfae32a61665e0556350f4055b4 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 19 Jul 2020 12:31:12 -0700 Subject: [PATCH] metrics: add LabelMap.GetFloat --- metrics/metrics.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/metrics/metrics.go b/metrics/metrics.go index 0ffc8fbac..d057f270c 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -40,3 +40,10 @@ func (m *LabelMap) Get(key string) *expvar.Int { m.Add(key, 0) return m.Map.Get(key).(*expvar.Int) } + +// GetFloat returns a direct pointer to the expvar.Float for key, creating it +// if necessary. +func (m *LabelMap) GetFloat(key string) *expvar.Float { + m.AddFloat(key, 0.0) + return m.Map.Get(key).(*expvar.Float) +}