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

Exporter not IPv6-capable #132

Closed
danrl opened this issue Jan 29, 2017 · 4 comments
Closed

Exporter not IPv6-capable #132

danrl opened this issue Jan 29, 2017 · 4 comments

Comments

@danrl
Copy link

danrl commented Jan 29, 2017

The exporter does not listen on IPv6 addresses. Explicitly asking it to listen to IPv6 address(es) gives an "unknown address family" error.

I used this example code:

from prometheus_client import start_http_server, Summary
import random
import time

# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')

# Decorate function with metric.
@REQUEST_TIME.time()
def process_request(t):
    """A dummy function that takes some time."""
    time.sleep(t)

if __name__ == '__main__':
    # Start up the server to expose the metrics.
    start_http_server(8000)
    # Generate some requests.
    while True:
        process_request(random.random())

To reproduce the error message, replace

start_http_server(8000)

by

start_http_server(8000, addr="::")
@yrro
Copy link

yrro commented Feb 17, 2017

This is a shortcoming in the Python standard library; see https://bugs.python.org/issue24209.

@danrl
Copy link
Author

danrl commented Feb 17, 2017

Got it working by setting address_family = socket.AF_INET6 in exposition.py.

@brian-brazil
Copy link
Contributor

Nothing for us to do here it seems.

@genofire
Copy link

It should be fixed in python 3.8.0 till it is package by your distro the workaround from @danrl works nice:
Here the correcht place in your exposition.py :

class _ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
    """Thread per request HTTP server."""
    # Make worker threads "fire and forget". Beginning with Python 3.7 this
    # prevents a memory leak because ``ThreadingMixIn`` starts to gather all
    # non-daemon threads in a list in order to join on them at server close.
    # Enabling daemon threads virtually makes ``_ThreadingSimpleServer`` the
    # same as Python 3.7's ``ThreadingHTTPServer``.
    daemon_threads = True
    address_family = socket.AF_INET6

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

No branches or pull requests

4 participants