client_python
client_python copied to clipboard
Allow adding arbitrary labels to metrics when generating output
It's useful to be able to apply a label across all metrics, for example when using a multi-processing framework to apply a label for worker ID to all metrics (including from builtin collector types). This change alows passing a dictionary of labels and values to generate_latest which will then be applied to all generated metrics.
Signed-off-by: Will Newton [email protected]
Let me know if this approach looks viable to you, happy to rework it if you have suggestions for how to do it in a better way.
I opened a new PR #741 that adds a new collector type. It's a little more complex but conceptually cleaner that way I think.