MCPcopy Index your code
hub / github.com/prometheus/client_python / start_wsgi_server

Function start_wsgi_server

prometheus_client/exposition.py:233–259  ·  view source on GitHub ↗

Starts a WSGI server for prometheus metrics as a daemon thread.

(
        port: int,
        addr: str = '0.0.0.0',
        registry: Collector = REGISTRY,
        certfile: Optional[str] = None,
        keyfile: Optional[str] = None,
        client_cafile: Optional[str] = None,
        client_capath: Optional[str] = None,
        protocol: int = ssl.PROTOCOL_TLS_SERVER,
        client_auth_required: bool = False,
)

Source from the content-addressed store, hash-verified

231
232
233def start_wsgi_server(
234 port: int,
235 addr: str = '0.0.0.0',
236 registry: Collector = REGISTRY,
237 certfile: Optional[str] = None,
238 keyfile: Optional[str] = None,
239 client_cafile: Optional[str] = None,
240 client_capath: Optional[str] = None,
241 protocol: int = ssl.PROTOCOL_TLS_SERVER,
242 client_auth_required: bool = False,
243) -> Tuple[WSGIServer, threading.Thread]:
244 """Starts a WSGI server for prometheus metrics as a daemon thread."""
245
246 class TmpServer(ThreadingWSGIServer):
247 """Copy of ThreadingWSGIServer to update address_family locally"""
248
249 TmpServer.address_family, addr = _get_best_family(addr, port)
250 app = make_wsgi_app(registry)
251 httpd = make_server(addr, port, app, TmpServer, handler_class=_SilentHandler)
252 if certfile and keyfile:
253 context = _get_ssl_ctx(certfile, keyfile, protocol, client_cafile, client_capath, client_auth_required)
254 httpd.socket = context.wrap_socket(httpd.socket, server_side=True)
255 t = threading.Thread(target=httpd.serve_forever)
256 t.daemon = True
257 t.start()
258
259 return httpd, t
260
261
262start_http_server = start_wsgi_server

Callers

nothing calls this directly

Calls 4

_get_best_familyFunction · 0.85
make_wsgi_appFunction · 0.85
_get_ssl_ctxFunction · 0.85
startMethod · 0.80

Tested by

no test coverage detected