Install & Compatibility
Where this runs
tested against v23.12.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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.236s · 19.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.9s · import 0.214s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Counter
✓ from aioprometheus import Counter
Gauge
✓ from aioprometheus import Gauge
Histogram
✓ from aioprometheus import Histogram
Summary
✓ from aioprometheus import Summary
MetricsMiddleware
✓ from aioprometheus import MetricsMiddleware
✗ from aioprometheus.middleware import MetricsMiddleware
Old import path removed in 21.x
Service
✓ from aioprometheus import Service
render
✓ from aioprometheus import render
✗ from aioprometheus.renderer import render
Renderer was refactored; use top-level render
Create a Counter, register it with a Service, and expose metrics on port 8080.
from aioprometheus import Counter, Service
import asyncio
async def main():
counter = Counter("requests_total", "Total requests")
counter.inc({"endpoint": "/"})
service = Service()
service.prometheus_metrics.add_collector(counter)
await service.start(addr="0.0.0.0", port=8080)
try:
await asyncio.Event().wait()
finally:
await service.stop()
asyncio.run(main())
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aioprometheus.metrics'
Importing from old submodules removed in version 21.
fixUse `from aioprometheus import Counter` instead.
ValueError: The 'labels' argument must be a dict
Passing labels as keyword arguments or non-dict.
fixPass labels as a dictionary: `counter.inc({"endpoint": "/"})`. Upgrade
Version history
23.12.0latest on PyPI · released Dec 27, 2023
Audit
Dependencies
No dependency data recorded yet.