-
Notifications
You must be signed in to change notification settings - Fork 818
Changes to allow each HTTP request to be a seperate thread #139
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
Conversation
prometheus_client/exposition.py
Outdated
@@ -97,10 +97,13 @@ def log_message(self, format, *args): | |||
|
|||
|
|||
def start_http_server(port, addr=''): | |||
"""Starts a HTTP server for prometheus metrics as a daemon thread.""" | |||
"""Spawns each HTTPServer in a new thread to prevent blocking""" |
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 should still mention the daemon thread, as that's more important.
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.
Done
prometheus_client/exposition.py
Outdated
from BaseHTTPServer import BaseHTTPRequestHandler | ||
from BaseHTTPServer import HTTPServer | ||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | ||
from SocketServer import ThreadingMixIn |
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.
extra space
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.
Done
@@ -12,8 +12,8 @@ | |||
|
|||
from . import core | |||
try: |
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.
You also need to change Python3
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.
Done
prometheus_client/exposition.py
Outdated
class ThreadingSimpleServer(ThreadingMixIn, HTTPServer): | ||
pass | ||
"""Starts a HTTP server for prometheus metrics in a new thread""" | ||
"""Starts a HTTP server for prometheus metrics as a daemon thread.""" |
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.
The daemon thread should be mentioned in start_http_server, as that's the primary docs the user will see.
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.
Ah, fixed
Thanks! |
@brian-brazil
This change allows each HTTP request to be served by a separate thread (I think!).
This came about because of a network issue, which was causing one Prometheus to keep a connection open - causing all other Proms to fail the exporter as they couldn't get a connection.
This is also consistent with the Go exporter behavior.
Cheers,
James