Skip to content

Changes to allow each HTTP request to be a seperate thread#139

Merged
brian-brazil merged 3 commits into
prometheus:masterfrom
jamessewell:master
Feb 14, 2017
Merged

Changes to allow each HTTP request to be a seperate thread#139
brian-brazil merged 3 commits into
prometheus:masterfrom
jamessewell:master

Conversation

@jamessewell

Copy link
Copy Markdown
Contributor

@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

Comment thread prometheus_client/exposition.py Outdated

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"""

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread prometheus_client/exposition.py Outdated
from BaseHTTPServer import BaseHTTPRequestHandler
from BaseHTTPServer import HTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from SocketServer import ThreadingMixIn

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

Copy link
Copy Markdown
Contributor Author

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:

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread 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."""

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, fixed

@brian-brazil brian-brazil merged commit ce5542b into prometheus:master Feb 14, 2017
@brian-brazil

Copy link
Copy Markdown
Contributor

Thanks!

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.

2 participants