Metrics are usually exposed over HTTP, to be read by the Prometheus server.
The easiest way to do this is via start_http_server, which will start a HTTP server in a daemon thread on the given port:
from prometheus_client import start_http_server
Visit http://localhost:8000/ to view the metrics.
To add Prometheus exposition to an existing HTTP server, see the MetricsHandler class which provides a BaseHTTPRequestHandler. It also serves as a simple example of how to write a custom endp