-
Notifications
You must be signed in to change notification settings - Fork 799
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
Support metric help text in multiprocess mode #804
Conversation
39f0d37
to
0337a8f
Compare
Issue prometheus#211 Add support for storing the metrics help text in the multiprocess map. The help will come from the first process read, but it should be the same for all metrics. Signed-off-by: Cian Butler <[email protected]>
0337a8f
to
f6a2b4a
Compare
Thanks for the PR! I just got back from holiday and will put this on the list to review soon. |
"""Format a key for use in the mmap file.""" | ||
# ensure labels are in consistent order for identity | ||
labels = dict(zip(labelnames, labelvalues)) | ||
return json.dumps([metric_name, name, labels], sort_keys=True) | ||
return json.dumps([metric_name, name, labels, help_text], sort_keys=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I am trying to think of the ramifications of adding the help text to the mmap key. In the case where help text may change then the key would no longer work properly. I don't think there is a way to change help text though outside of a custom collector which is not supported in multiprocess mode anyway?
I guess the downside of this would be that if we do support custom collectors in multiprocess mode in the future help text might have to be ignored or redone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you wanted to add multiprocess support to the custom collectors you'd need to make the same sacrifice of the first write to help text win and ignore all future writes.
I struggle to think of any reason a metrics help text should change in a running application
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I agree, I applications generally should not change help text. The help text is also marked as a private field on the metric types now so shouldn't be changed by users of this library outside of custom collectors.
One thing I would love to see in this PR is either an additional test or some additional assertions in test_collect
in test_multiprocess.py
. I will let you know if I come up with other concerns in the meantime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ive not had time to get back to this but looks like @evgenymarkov has written some tests in #866
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry. I didn't find this pull request. You can cherry-pick 89e3193 and then I will close my PR.
Signed-off-by: Evgeny Markov <[email protected]>
Hi @csmarchbanks! Sorry for ping, but can you recheck this PR? It would be cool to get a release with this code 🙏 |
Thanks for updating this PR, I will take another look soon and give it a bit more thought! It will probably be next week as this week is pretty busy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thank you to both of you!
Pass through extra arguments to mmap_key after prometheus/client_python#804
Pass through extra arguments to mmap_key after prometheus/client_python#804
* chore(deps): update minor updates * fix(deps): prometheus_client 0.16 compat Pass through extra arguments to mmap_key after prometheus/client_python#804 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jakob van Santen <[email protected]>
Issue #211
Add support for storing the metrics help text in the multiprocess map.
The help will come from the first process read, but it should be the
same for all metrics.
@csmarchbanks not sure if i missed anything but let me know if you need anything changed