diff options
Diffstat (limited to 'plugins/metrics/rpc.go')
-rw-r--r-- | plugins/metrics/rpc.go | 12 |
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)) } |