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

Skip to content

Conversation

@jamessewell
Copy link
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


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
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
Contributor Author

Choose a reason for hiding this comment

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

Done

from BaseHTTPServer import BaseHTTPRequestHandler
from BaseHTTPServer import HTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from SocketServer import ThreadingMixIn
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

Done

from wsgiref.simple_server import make_server

from . import core
try:
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

Done

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