From 7a7f2846aaa90d6196199bd615b9ab8242a903a4 Mon Sep 17 00:00:00 2001 From: Marc CARRE Date: Mon, 9 Oct 2017 15:20:50 +0100 Subject: [PATCH] Initialise counters w/o using Set. CounterVec#Set was present in v0.8.0 but has been removed in 0.9.0-pre1. Simply calling the counter with a label seems to initialise it. If not calling it, then the metric/label is not exposed until actually incremented, which is probably not the desired behaviour -- i.e. people would most likely still want to know that the number of debug/info/warning/error log messages is zero, and to confirm that their monitoring is not broken. --- promrus.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promrus.go b/promrus.go index 4c20ab8..90720d1 100644 --- a/promrus.go +++ b/promrus.go @@ -22,7 +22,7 @@ func NewPrometheusHook() (*PrometheusHook, error) { }, []string{"level"}) // Initialise counters for all supported levels: for _, level := range supportedLevels { - counterVec.WithLabelValues(level.String()).Set(0) + counterVec.WithLabelValues(level.String()) } // Try to register the counter vector: err := prometheus.Register(counterVec)