🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

prometheus-async

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prometheus-async

Async helpers for prometheus_client.

25.1.0
100

Supply Chain Security

100

Vulnerability

100

Quality

100

Maintenance

80

License

Maintainers
1

prometheus-async

Documentation License: Apache 2.0 PyPI version Downloads / Month

prometheus-async adds support for asynchronous frameworks to the official Python client for the Prometheus metrics and monitoring system.

Currently asyncio and Twisted are supported.

It works by wrapping the metrics from the official client:

import asyncio

from aiohttp import web
from prometheus_client import Histogram
from prometheus_async.aio import time

REQ_TIME = Histogram("req_time_seconds", "time spent in requests")

@time(REQ_TIME)
async def req(request):
      await asyncio.sleep(1)
      return web.Response(body=b"hello")

Even for synchronous applications, the metrics exposure methods can be useful since they are more powerful than the one shipped with the official client. For that, helper functions have been added that run them in separate threads (asyncio-only).

The source code is hosted on GitHub and the documentation on Read the Docs.

Credits

prometheus-async is written and maintained by Hynek Schlawack.

The development is kindly supported by my employer Variomedia AG, prometheus-async’s Tidelift subscribers, and all my amazing GitHub Sponsors.

prometheus-async for Enterprise

Available as part of the Tidelift Subscription.

The maintainers of prometheus-async and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts