Commit b9edc43 1 parent 9dd6b0d commit b9edc43 Copy full SHA for b9edc43
File tree 2 files changed +12
-1
lines changed
docs/content/exporting/http
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)
18
18
19
19
Visit [ http://localhost:8000/ ] ( http://localhost:8000/ ) to view the metrics.
20
20
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
+
21
30
To add Prometheus exposition to an existing HTTP server, see the ` MetricsHandler ` class
22
31
which provides a ` BaseHTTPRequestHandler ` . It also serves as a simple example of how
23
32
to write a custom endpoint.
Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ def start_wsgi_server(
210
210
client_capath : Optional [str ] = None ,
211
211
protocol : int = ssl .PROTOCOL_TLS_SERVER ,
212
212
client_auth_required : bool = False ,
213
- ) -> None :
213
+ ) -> Tuple [ WSGIServer , threading . Thread ] :
214
214
"""Starts a WSGI server for prometheus metrics as a daemon thread."""
215
215
216
216
class TmpServer (ThreadingWSGIServer ):
@@ -226,6 +226,8 @@ class TmpServer(ThreadingWSGIServer):
226
226
t .daemon = True
227
227
t .start ()
228
228
229
+ return httpd , t
230
+
229
231
230
232
start_http_server = start_wsgi_server
231
233
You can’t perform that action at this time.
0 commit comments