aboutsummaryrefslogtreecommitdiff
path: root/plugin/metrics/metrics.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/metrics/metrics.go')
-rw-r--r--plugin/metrics/metrics.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/plugin/metrics/metrics.go b/plugin/metrics/metrics.go
index 8efeff1e7..6b496cccc 100644
--- a/plugin/metrics/metrics.go
+++ b/plugin/metrics/metrics.go
@@ -57,7 +57,15 @@ func New(addr string) *Metrics {
}
// MustRegister wraps m.Reg.MustRegister.
-func (m *Metrics) MustRegister(c prometheus.Collector) { m.Reg.MustRegister(c) }
+func (m *Metrics) MustRegister(c prometheus.Collector) {
+ err := m.Reg.Register(c)
+ if err != nil {
+ // ignore any duplicate error, but fatal on any other kind of error
+ if _, ok := err.(prometheus.AlreadyRegisteredError); !ok {
+ log.Fatalf("Cannot register metrics collector: %s", err)
+ }
+ }
+}
// AddZone adds zone z to m.
func (m *Metrics) AddZone(z string) {