Make registry optional for MultiProcessCollector#249
Make registry optional for MultiProcessCollector#249marksteward wants to merge 1 commit intoprometheus:masterfrom
Conversation
What is there to change? |
|
It's usually expected that you will pass the registry to a collector, rather than having to register it yourself. I'm not sure what you are proposing is actually saving code. |
To make PlatformCollector default to not registering itself with the default registry, except for the default instance. So: This is more explicit and means someone creating their own PlatformCollector instance doesn't end up with one already registered to the default registry by accident. |
This wasn't clear. The README has: but then: There's no mention of explicitly passing When I first looked at this, I assumed MultiProcessCollector was doing some sort of quirky transformation on the registry, rather than just registering itself. My hope is to make multiproc more self-explanatory and fit better with patterns used in Django, Flask, etc. I'm happy to change the README instead if it should go the other way. |
|
So collectors are meant to auto-register with the default registry by default. The MultiProcessCollector in unusual in that you never use it with the default registry, and use a custom registry instead. |
|
I'll raise a separate PR to improve the README. |
@brian-brazil this is a trivial first PR to make it possible to make it easier to add more collectors during a multiproc scrape. This is so the pattern eventually can be:
instead of having to explicitly pass None to each Collector.
I would also have included the change for PlatformCollector, but I'm concerned that might break existing code. Should it be accompanied by deprecation warnings, or is it not worth doing?