-
Notifications
You must be signed in to change notification settings - Fork 801
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
instance_ip_grouping_key
does not work on macOS
#629
Comments
Thank you for your report, it is certainly an issue, and there is even a test that is ignored on macOS: https://github.com/prometheus/client_python/blob/master/tests/test_exposition.py#L379 I don't have a macOS environment, but would be happy to review a PR to enable macOS. |
@csmarchbanks Does this look like an acceptable solution? Edit: I've submitted a PR #687 It's adapted from this StackOverflow answer: https://stackoverflow.com/a/28950776 def instance_ip_grouping_key():
"""Grouping key with instance set to the IP Address of this host."""
with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as s:
s.connect(('10.255.255.255', 1))
return {'instance': s.getsockname()[0]} It works on my M1 MacbookPro: >>> from contextlib import closing
>>>
>>> def instance_ip_grouping_key():
... """Grouping key with instance set to the IP Address of this host."""
... with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as s:
... s.connect(('10.255.255.255', 1))
... return {'instance': s.getsockname()[0]}
...
>>> instance_ip_grouping_key()
{'instance': '192.168.0.189'} |
Fixes prometheus#629 The solution is adapted from this StackOverflow answer: https://stackoverflow.com/a/28950776
Fixes prometheus#629 The solution is adapted from this StackOverflow answer: https://stackoverflow.com/a/28950776 Signed-off-by: Jethro Muller <[email protected]>
* Fix instance_ip_grouping_key not working on macOS Fixes #629 The solution is adapted from this StackOverflow answer: https://stackoverflow.com/a/28950776 Signed-off-by: Jethro Muller <[email protected]> * Remove conditional skip for macos Signed-off-by: Jethro Muller <[email protected]> * Add platform check with explanatory comment Signed-off-by: Jethro Muller <[email protected]>
macOS 11.1
Python 3.8.5
prometheus-client 0.9.0
To reproduce:
What happens?
The text was updated successfully, but these errors were encountered: