From f17036063ccad42582f6c48a43bb4496af3f7461 Mon Sep 17 00:00:00 2001 From: Juha Hyttinen Date: Fri, 30 Oct 2020 12:31:01 +0200 Subject: [PATCH] Support counter and gauge get. Needed in some rare cases Change-Id: I950b04e2c96e9ae9657ad86414d15ed3d52162ce Signed-off-by: Juha Hyttinen --- pkg/xapp/metrics.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/xapp/metrics.go b/pkg/xapp/metrics.go index 96f407c..f85c488 100644 --- a/pkg/xapp/metrics.go +++ b/pkg/xapp/metrics.go @@ -52,6 +52,12 @@ func (met *MetricGroupsCache) CIs(metric string) bool { return ok } +func (met *MetricGroupsCache) CGet(metric string) Counter { + met.RLock() + defer met.RUnlock() + return met.counters[metric] +} + func (met *MetricGroupsCache) CInc(metric string) { met.RLock() defer met.RUnlock() @@ -71,6 +77,12 @@ func (met *MetricGroupsCache) GIs(metric string) bool { return ok } +func (met *MetricGroupsCache) GGet(metric string) Gauge { + met.RLock() + defer met.RUnlock() + return met.gauges[metric] +} + func (met *MetricGroupsCache) GSet(metric string, val float64) { met.RLock() defer met.RUnlock() -- 2.16.6