-
Notifications
You must be signed in to change notification settings - Fork 813
gauge.set_function() doesn't work in multiprocess mode #504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This classifies as a custom collector, which it's not possible to make work with multiprocess mode. |
Makes sense, I'll look/ask about ways to work around that in the mailing list. |
Clarifying in the Multiprocess Mode instructions that gauge.set_function is also a custom collector. prometheus#504
Clarifying in the Multiprocess Mode instructions that gauge.set_function is also a custom collector. prometheus#504
Given that multiprocess is getting some traction is it worth re-opening this? |
I'm still not sure how this could be done in multiprocess mode. You would need to run the function for each process which is not a pattern we have today and would need to integrate with whatever is starting the process I believe. If there is a simpler way I am all ears, but otherwise I think it should probably be kept as closed. |
Perhaps just documentation or a failure logged. Right now you just have to wonder |
👍 Documentation on the function is a good idea to avoid confusion. |
Signed-off-by: Aapeli <git@aapelivuorinen.com>
Multiprocess mode's collect() reads the registry files and aggregates metrics that have been written to
prometheus_multiproc_dir
.This doesn't work with
gauge.set_function()
which does not record its value. The provided function is just called during collection.That means with the following code:
The output will be:
Current side effects:
all
orliveall
is used, thepid
tag won't be included. This results in duplicate metrics being reported to Prometheus. Prometheus currently only uses the first metric it reads, which is non-deterministic due to iteration over the registry's dictionary.registry=None
to avoid double reporting, only the default value of0.0
is reported.all
and to ignore gauges in Prometheus and with the tagpid
.Proposal:
I'm not sure how you could incorporate
set_function
into the multiprocess registry and I'm not convinced how useful of a feature it would be. Is it reasonable to add a newmultiprocess_mode: exclude
which would prevent the incorrect 0.0 value being reported? Or would it be better to just add documentation to recommend using two independent registries?The text was updated successfully, but these errors were encountered: