summaryrefslogtreecommitdiff
path: root/plugins/metrics/rpc.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-14 19:13:53 +0300
committerValery Piashchynski <[email protected]>2020-11-14 19:13:53 +0300
commit2d2d876af7e72c6cc448d8bce243b717481558d0 (patch)
tree9eb76da47fdf0def8f9d230609651732dda9a61d /plugins/metrics/rpc.go
parent06cda58dd9e50928c5473425fefcd4b4be4598c2 (diff)
Complete tests for the Metrics plugin
Diffstat (limited to 'plugins/metrics/rpc.go')
-rw-r--r--plugins/metrics/rpc.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/metrics/rpc.go b/plugins/metrics/rpc.go
index d0f071ef..f6455bdf 100644
--- a/plugins/metrics/rpc.go
+++ b/plugins/metrics/rpc.go
@@ -112,7 +112,11 @@ func (rpc *rpcServer) Observe(m *Metric, ok *bool) error {
return errors.E(op, errors.Errorf("required labels for collector `%s`", m.Name))
}
- c.WithLabelValues(m.Labels...).Observe(m.Value)
+ observer, err := c.GetMetricWithLabelValues(m.Labels...)
+ if err != nil {
+ return errors.E(op, err)
+ }
+ observer.Observe(m.Value)
case prometheus.Histogram:
c.Observe(m.Value)
@@ -122,7 +126,11 @@ func (rpc *rpcServer) Observe(m *Metric, ok *bool) error {
return errors.E(op, errors.Errorf("required labels for collector `%s`", m.Name))
}
- c.WithLabelValues(m.Labels...).Observe(m.Value)
+ observer, err := c.GetMetricWithLabelValues(m.Labels...)
+ if err != nil {
+ return errors.E(op, err)
+ }
+ observer.Observe(m.Value)
default:
return errors.E(op, errors.Errorf("collector `%s` does not support method `Observe`", m.Name))
}