File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
docs/content/exporting/http Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,15 @@ start_http_server(8000)
1818
1919Visit [ http://localhost:8000/ ] ( http://localhost:8000/ ) to view the metrics.
2020
21+ The function will return the HTTP server and thread objects, which can be used
22+ to shutdown the server gracefully:
23+
24+ ``` python
25+ server, t = start_http_server(8000 )
26+ server.shutdown()
27+ t.join()
28+ ```
29+
2130To add Prometheus exposition to an existing HTTP server, see the ` MetricsHandler ` class
2231which provides a ` BaseHTTPRequestHandler ` . It also serves as a simple example of how
2332to write a custom endpoint.
Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ def start_wsgi_server(
210210 client_capath : Optional [str ] = None ,
211211 protocol : int = ssl .PROTOCOL_TLS_SERVER ,
212212 client_auth_required : bool = False ,
213- ) -> None :
213+ ) -> Tuple [ WSGIServer , threading . Thread ] :
214214 """Starts a WSGI server for prometheus metrics as a daemon thread."""
215215
216216 class TmpServer (ThreadingWSGIServer ):
@@ -226,6 +226,8 @@ class TmpServer(ThreadingWSGIServer):
226226 t .daemon = True
227227 t .start ()
228228
229+ return httpd , t
230+
229231
230232start_http_server = start_wsgi_server
231233
You can’t perform that action at this time.
0 commit comments