Skip to content
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

Merged
merged 2 commits into from
Dec 22, 2022

Conversation

butlerx
Copy link
Contributor

@butlerx butlerx commented May 3, 2022

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

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]>
@csmarchbanks
Copy link
Member

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)
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

@evgenymarkov evgenymarkov Dec 4, 2022

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]>
@evgenymarkov
Copy link
Contributor

Hi @csmarchbanks! Sorry for ping, but can you recheck this PR? It would be cool to get a release with this code 🙏

@csmarchbanks
Copy link
Member

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.

Copy link
Member

@csmarchbanks csmarchbanks left a 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!

@csmarchbanks csmarchbanks merged commit 781e3e1 into prometheus:master Dec 22, 2022
jvansanten added a commit to AmpelProject/Ampel-core that referenced this pull request Feb 6, 2023
Pass through extra arguments to mmap_key after prometheus/client_python#804
jvansanten added a commit to AmpelProject/Ampel-core that referenced this pull request Feb 6, 2023
Pass through extra arguments to mmap_key after prometheus/client_python#804
jvansanten added a commit to AmpelProject/Ampel-core that referenced this pull request Feb 6, 2023
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants