https://github.com/hynek/prometheus-async
Async Python helpers for the official prometheus-client.
https://github.com/hynek/prometheus-async
async asyncio metrics prometheus prometheus-exporter python twisted
Last synced: 5 months ago
JSON representation
Async Python helpers for the official prometheus-client.
- Host: GitHub
- URL: https://github.com/hynek/prometheus-async
- Owner: hynek
- License: apache-2.0
- Created: 2015-10-02T11:35:14.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2025-05-05T17:27:36.000Z (5 months ago)
- Last Synced: 2025-05-05T18:44:17.049Z (5 months ago)
- Topics: async, asyncio, metrics, prometheus, prometheus-exporter, python, twisted
- Language: Python
- Homepage: https://prometheus-async.readthedocs.io/
- Size: 413 KB
- Stars: 173
- Watchers: 6
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# prometheus-async
*prometheus-async* adds support for asynchronous frameworks to the official [Python client](https://github.com/prometheus/client_python) for the [Prometheus](https://prometheus.io/) metrics and monitoring system.
Currently [*asyncio*](https://docs.python.org/3/library/asyncio.html) and [Twisted](https://twisted.org) are supported.
It works by wrapping the metrics from the official client:
```python
import asynciofrom aiohttp import web
from prometheus_client import Histogram
from prometheus_async.aio import timeREQ_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](https://github.com/hynek/prometheus-async) and the documentation on [Read the Docs](https://prometheus-async.readthedocs.io/).
## Credits
*prometheus-async* is written and maintained by [Hynek Schlawack](https://hynek.me/).
The development is kindly supported by my employer [Variomedia AG](https://www.variomedia.de/), *prometheus-async*’s [Tidelift subscribers][TL], and all my amazing [GitHub Sponsors](https://github.com/sponsors/hynek).
## *prometheus-async* for Enterprise
Available as part of the [Tidelift Subscription][TL].
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.[TL]: https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek