prometheus-async provides asynchronous helpers for the `prometheus_client` library, making it easier to expose metrics from `asyncio` and `Twisted` applications. Maintained by Hynek Schlawack, the library is currently at version 26.1.0 and receives regular updates, often focusing on type hinting and internal improvements, with occasional breaking changes for major Python versions.
pip install prometheus-asyncVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to start a Prometheus HTTP server using `prometheus_async.aio.web.start_http_server` and how to apply the `prometheus_async.aio.time` decorator to an asynchronous function. The metrics server runs in the background, making metrics available at `/metrics` on the specified port.
Upgrade your Python environment to 3.9 or a later version. For older Python versions, use `prometheus-async<22.1.0` (not recommended for new projects).
Remove the `loop` argument when calling `start_http_server()`. Modern `asyncio` manages the event loop automatically, making explicit `loop` passing generally unnecessary and discouraged.
Verify that your imports (e.g., `prometheus_async.aio.web.start_http_server`) match the asynchronous framework you are using in your application.