8000 Adds support for the WSGI server to read from a different registry · sonlinux/client_python@5c5d997 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5c5d997

Browse files
author
Thomas Desrosiers
committed
Adds support for the WSGI server to read from a different registry
1 parent f005a78 commit 5c5d997

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

prometheus_client/exposition.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@
2828
'''Content type of the latest text format'''
2929

3030

31-
def make_wsgi_app():
32-
'''Create a WSGI app which serves the metrics from the registry.'''
31+
def make_wsgi_app(registry=core.REGISTRY):
32+
'''Create a WSGI app which serves the metrics from a registry.'''
3333
def prometheus_app(environ, start_response):
3434
status = str('200 OK')
3535
headers = [(str('Content-type'), CONTENT_TYPE_LATEST)]
3636
start_response(status, headers)
37-
return [generate_latest(core.REGISTRY)]
37+
return [generate_latest(registry)]
3838
return prometheus_app
3939

4040

41-
def start_wsgi_server(port, addr=''):
41+
def start_wsgi_server(port, addr='', registry=core.REGISTRY):
4242
"""Starts a WSGI server for prometheus metrics as a daemon thread."""
4343
class PrometheusMetricsServer(threading.Thread):
4444
def run(self):
45-
httpd = make_server(addr, port, make_wsgi_app())
45+
httpd = make_server(addr, port, make_wsgi_app(registry))
4646
httpd.serve_forever()
4747
t = PrometheusMetricsServer()
4848
t.daemon = True

0 commit comments

Comments
 (0)
0