client_golang icon indicating copy to clipboard operation
client_golang copied to clipboard

Consider eliminating MustRegister, moving global registry to promauto.

Open beorn7 opened this issue 5 years ago • 2 comments

With the additions to the promauto package in #713 , the need for MustRegister is diminished: Whoever doesn't care about panicking, can and should use promauto constructors, no matter if they want the local or the global registry. Whoever wants to play safe, won't use MustRegister anyway. With the notable exception of custom collectors. One might argue that those are rare enough to get registered with the normal Register call and subsequent error handling (even if it is just a panic(err)). This would have the advantage of making the Registerer interface leaner.

Another consideration is that users of the global registry have gravitated towards promauto for a while now. So perhaps it's better to have the global registry in promauto, perhaps with a Register top-level function there for use with custom collectors.

This would pave the road for a registry package, which was discussed before, so that registry concerns would be all in that package, making the prometheus package much cleaner

beorn7 avatar Feb 13 '20 21:02 beorn7

Hm, I like the promauto in a way that making this part auto-registered and panicking and removing panicking part from prometheus seems like a clean and reasonable separation. :+1:

bwplotka avatar Feb 13 '20 22:02 bwplotka

I mostly assigned this to myself as a “default” because I used to be the maintainer of this repo. Therefore, I'm un-assigning this from myself no. New maintainers @bwplotka & @kakkoyun, please deal with this as you see fit.

beorn7 avatar Jun 02 '21 18:06 beorn7