Using prometheus collector MustRegister in New{Counter,Gauge} and possible panic
Thanks for the wonderful product! I think it would be fair to point the limitations of calling New in the documentation, since calling New again calls panic.
A great point! :)
Is this a bug or a documentation issue? If it is a bug, I would like to have a look at it.
Hmm, it could be either. The easiest fix would be to update the docs to mention it can panic, but a better fix would probably be a new constructor with took an e.g. prometheus.Registerer into which the metrics would be registered, and refactoring the existing constructor (with updated doc comment) to call the new constructor with prometheus.DefaultRegisterer (or whatever it's called).
I also ran into this issue (the day this was filed interestingly) and implemented a Delete function for each of the metric types that calls Unregister: https://github.com/AshleyDumaine/kit/commit/5af035392e452f045fe5a180edf41ac5a7f428cd
Would this be an acceptable solution?
I don't think Delete is the answer — metrics generally should be singletons in your component graph. If we need something more it would probably be to take an explicit Registerer.
Hi @TimSatke , are you still looking at this? If not I would like to have a go at it.
I didn’t look at it, since I didn’t consider any answer a clear „go“, so yes, take it