Skip to content

Commit

Permalink
Initialise counters w/o using Set.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marccarre committed Oct 9, 2017
1 parent 2ab4368 commit 7a7f284
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion promrus.go
Expand Up @@ -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)
Expand Down

0 comments on commit 7a7f284

Please sign in to comment.