Metadata-Version: 2.1
Name: prometheus-async
Version: 22.1.0
Summary: Async helpers for prometheus_client.
Keywords: metrics,prometheus,twisted,asyncio,async
Author-email: Hynek Schlawack <hs@ox.cx>
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: prometheus_client >= 0.8.0
Requires-Dist: typing_extensions >= 3.10.0; python_version<'3.10'
Requires-Dist: wrapt
Requires-Dist: aiohttp>=3 ; extra == "aiohttp"
Requires-Dist: aiohttp>=3 ; extra == "consul"
Requires-Dist: pre-commit ; extra == "dev"
Requires-Dist: pytest-twisted ; extra == "dev"
Requires-Dist: tomli ; extra == "dev"
Requires-Dist: cogapp ; extra == "dev"
Requires-Dist: mypy ; extra == "dev"
Requires-Dist: coverage[toml] ; extra == "dev"
Requires-Dist: pytest ; extra == "dev"
Requires-Dist: pytest-asyncio ; extra == "dev"
Requires-Dist: aiohttp ; extra == "dev"
Requires-Dist: furo ; extra == "dev"
Requires-Dist: myst-parser ; extra == "dev"
Requires-Dist: sphinx-notfound-page ; extra == "dev"
Requires-Dist: sphinx ; extra == "dev"
Requires-Dist: sphinxcontrib-asyncio ; extra == "dev"
Requires-Dist: twisted ; extra == "dev"
Requires-Dist: aiohttp ; extra == "docs"
Requires-Dist: furo ; extra == "docs"
Requires-Dist: myst-parser ; extra == "docs"
Requires-Dist: sphinx-notfound-page ; extra == "docs"
Requires-Dist: sphinx ; extra == "docs"
Requires-Dist: sphinxcontrib-asyncio ; extra == "docs"
Requires-Dist: twisted ; extra == "docs"
Requires-Dist: coverage[toml] ; extra == "tests"
Requires-Dist: pytest ; extra == "tests"
Requires-Dist: pytest-asyncio ; extra == "tests"
Requires-Dist: twisted ; extra == "twisted"
Project-URL: Changelog, https://prometheus-async.readthedocs.io/en/stable/changelog.html
Project-URL: Documentation, https://prometheus-async.readthedocs.io/
Project-URL: Funding, https://hynek.me/say-thanks/
Project-URL: Ko-fi, https://ko-fi.com/the_hynek
Project-URL: Source Code, https://github.com/hynek/prometheus-async/
Provides-Extra: aiohttp
Provides-Extra: consul
Provides-Extra: dev
Provides-Extra: docs
Provides-Extra: tests
Provides-Extra: twisted

# prometheus-async

<a href="https://prometheus-async.readthedocs.io/en/stable/">
   <img src="https://img.shields.io/badge/Docs-Read%20The%20Docs-black" alt="Documentation" />
</a>
<a href="https://github.com/hynek/prometheus-async/blob/main/LICENSE">
   <img src="https://img.shields.io/badge/license-Apache--2.0-C06524" alt="License: Apache 2.0" />
</a>
<a href="https://pypi.org/project/prometheus-async/">
   <img src="https://img.shields.io/pypi/v/prometheus-async" alt="PyPI version" />
</a>
<a href="https://pepy.tech/project/prometheus-async">
   <img src="https://static.pepy.tech/personalized-badge/prometheus-async?period=month&amp;units=international_system&amp;left_color=grey&amp;right_color=blue&amp;left_text=Downloads%20/%20Month" alt="Downloads / Month" />
</a>

<!-- teaser-begin -->

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

Currently [*asyncio*] and [*Twisted*] on Python 3.7 and later are supported.

It works by wrapping the metrics from the official client:

```python
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].


[*asyncio*]: https://docs.python.org/3/library/asyncio.html
[Python client]: https://github.com/prometheus/client_python
[*Prometheus*]: https://prometheus.io/
[*Twisted*]: https://twisted.org
[GitHub]: https://github.com/hynek/prometheus-async
[Read The Docs]: https://prometheus-async.readthedocs.io/

