dskit icon indicating copy to clipboard operation
dskit copied to clipboard

Avoid using promauto for metrics registration

Open tpaschalis opened this issue 2 years ago • 2 comments

Recently, https://github.com/grafana/dskit/pull/342 migrated packages from weaveworks/common to dskit.

One of the changes was to replaced the use of prometheus with promauto which in cases of downstream users who try to instantiate multiple instances of objects (eg. due to configuration reloads) triggers "duplicate metrics collector registration attempted" panics, for example here and here.

We should allow downstream consumers of packages to pass in their own Prometheus registerers for these metrics, or default to the global one if nil is passed.

tpaschalis avatar Oct 09 '23 09:10 tpaschalis

Avoid using promauto for metrics registration

Let's use promauto.With(reg)... with supplied registrerer.

pstibrany avatar Oct 09 '23 10:10 pstibrany

More detail required on why you think promauto is involved. Most of the errors you point to don't even include dskit in the stack.

bboreham avatar Oct 09 '23 10:10 bboreham