Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Convert MetricFamily labels -> list #184

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

Merged
merged 2 commits into from
Aug 7, 2017

Conversation

manics
Copy link
Contributor

@manics manics commented Aug 5, 2017

On Python 3 the labels of the python_info metric is a reference to the dict_keys of the data object used to create it. This PR ensures all labelnames in MetricFamilies it are a static tuple instead.

This PR is motivated by some broken tests in https://github.com/korfuri/django-prometheus with recent versions of prometheus-client: django-commons/django-prometheus#46 (comment)

Although the docs do not say Metrics should be serializable this change seems more in keeping with the intention that labels should be owned by the Metric and not a reference to an external object.

@brian-brazil
Copy link
Contributor

This doesn't seem like the right fix, this should be down in GaugeMetricFamily I think. Also a unittest would be good.

@manics
Copy link
Contributor Author

manics commented Aug 5, 2017

Do you mean GaugeMetricFamily should ensure labels is a list of strings in __init__?: https://github.com/prometheus/client_python/blob/master/prometheus_client/core.py#L215

@brian-brazil
Copy link
Contributor

Yes

@manics manics changed the title Convert python_info labels dict_keys -> list Convert MetricFamily labels -> list Aug 7, 2017
@manics
Copy link
Contributor Author

manics commented Aug 7, 2017

@brian-brazil I've force-pushed away the original commit, and converted labelnames to a tuple in all MetricFamilies

@brian-brazil brian-brazil merged commit 7fb5058 into prometheus:master Aug 7, 2017
@brian-brazil
Copy link
Contributor

Thanks!

@manics manics deleted the pickleable branch August 7, 2017 11:34
@zoidyzoidzoid
Copy link

Yay, thanks for this PR. 🎉

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