Registry / observability / prometheus-async

prometheus-async

JSON →
library26.1.0pypypiunverified

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-async
INSTALL
IMPORT
SIG · PROMETHEUS-ASYNC
P
prometheus-async
observabilitypythonv26.1.0
Install
2.1s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v26.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.1s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

start_http_server
from prometheus_async.aio.web import start_http_server
from prometheus_async.aio.web import start_http_server

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.

import asyncio from prometheus_client import Gauge from prometheus_async.aio.web import start_http_server from prometheus_async.aio import time # Define a metric MY_GAUGE = Gauge('my_async_gauge', 'Description of my async gauge') @time(MY_GAUGE) async def some_async_function(): """An example async function that does some work.""" print("Running some_async_function...") MY_GAUGE.set(10) await asyncio.sleep(0.5) MY_GAUGE.set(20) print("some_async_function finished.") async def main(): # Start the Prometheus HTTP server in the background # It will expose metrics on http://localhost:8000/metrics by default server = await start_http_server(port=8000) print("Prometheus metrics server started on port 8000") # Run our async function await some_async_function() print("Application finished. Metrics server still running. Press Ctrl+C to exit.") # Keep the event loop running to allow the metrics server to serve requests await asyncio.Future() # This will run forever until cancelled if __name__ == "__main__": try: asyncio.run(main()) except KeyboardInterrupt: print("\nExiting.")
Debug
Known issues
breakingDropped support for Python 2.7, 3.5, and 3.6. `prometheus-async` now requires Python 3.9 or newer.
fix
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).
affects: >=22.1.0
breakingThe `loop` argument has been removed from `prometheus_async.aio.web.start_http_server()`.
fix
Remove the `loop` argument when calling `start_http_server()`. Modern `asyncio` manages the event loop automatically, making explicit `loop` passing generally unnecessary and discouraged.
affects: >=22.1.0
gotchaEnsure you import from the correct asynchronous backend (`aio` for asyncio/aiohttp or `twisted` for Twisted). Mixing them or using the wrong one will lead to `AttributeError` or unexpected behavior.
fix
Verify that your imports (e.g., `prometheus_async.aio.web.start_http_server`) match the asynchronous framework you are using in your application.
affects: all
Upgrade
Version history
26.1.0latest on PyPI · released Mar 24, 2026
Audit
Dependencies
prometheus_clientrequiredCore dependency for Prometheus metrics functionality.
Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
2
Resources
prometheus-async — pip install prometheus-async · libregistry