{"library":"prometheus-async","title":"Prometheus Async","description":"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.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install prometheus-async"],"cli":null},"imports":["from prometheus_async.aio.web import start_http_server","from prometheus_async.aio import time","from prometheus_async.aio import track_inprogress","from prometheus_async.aio import monitor"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import asyncio\nfrom prometheus_client import Gauge\nfrom prometheus_async.aio.web import start_http_server\nfrom prometheus_async.aio import time\n\n# Define a metric\nMY_GAUGE = Gauge('my_async_gauge', 'Description of my async gauge')\n\n@time(MY_GAUGE)\nasync def some_async_function():\n    \"\"\"An example async function that does some work.\"\"\"\n    print(\"Running some_async_function...\")\n    MY_GAUGE.set(10)\n    await asyncio.sleep(0.5)\n    MY_GAUGE.set(20)\n    print(\"some_async_function finished.\")\n\nasync def main():\n    # Start the Prometheus HTTP server in the background\n    # It will expose metrics on http://localhost:8000/metrics by default\n    server = await start_http_server(port=8000)\n    print(\"Prometheus metrics server started on port 8000\")\n\n    # Run our async function\n    await some_async_function()\n\n    print(\"Application finished. Metrics server still running. Press Ctrl+C to exit.\")\n    # Keep the event loop running to allow the metrics server to serve requests\n    await asyncio.Future() # This will run forever until cancelled\n\nif __name__ == \"__main__\":\n    try:\n        asyncio.run(main())\n    except KeyboardInterrupt:\n        print(\"\\nExiting.\")\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"26.1.0","pypi_latest":"26.1.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"20M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"21.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"22M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"12.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"12.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"13M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"18.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"prometheus-async","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.5,"import_time_s":null,"mem_mb":null,"disk_size":"19M"}]}}