Skip to content

Commit

Permalink
Initialise counters w/o using CounterVec#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 `v0.9.0-pre1`.
Simply calling the counter with a label initialises it, so that is what we are now doing.
If not calling it at all, then the metric is not exposed for this label 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 10, 2017
1 parent ef46cbe commit 920a5c5
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 unregister the counter vector, in case already registered for some reason,
// e.g. double initialisation/configuration done by mistake by the end-user.
Expand Down

0 comments on commit 920a5c5

Please sign in to comment.