# Aiogram Prometheus Collector
Aiogram Based Metrics Collection for Prometheus
[![PyPI](https://img.shields.io/pypi/v/aiogram-prometheus)](https://pypi.org/project/aiogram-prometheus/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aiogram-prometheus)](https://pypi.org/project/aiogram-prometheus/)
[![Docs](https://img.shields.io/badge/docs-exists-blue)](https://projects.rocshers.com/open-source/aiogram-prometheus)
[![Downloads](https://static.pepy.tech/badge/aiogram-prometheus)](https://pepy.tech/project/aiogram-prometheus)
[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/aiogram-prometheus)](https://gitlab.com/rocshers/python/aiogram-prometheus)
[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/aiogram-prometheus)](https://gitlab.com/rocshers/python/aiogram-prometheus)
## Functionality
- Monitoring the `status` of bots and dispatchers
- Middleware for monitoring the bot's `network activity`
- Middleware for monitoring the `event handler performance`
![example](https://gitlab.com/rocshers/python/aiogram-prometheus/-/raw/release/docs/grafana_example.png)
## Installation
`pip install aiogram-prometheus`
## Quick start
- **aiogram_prometheus.PrometheusWrapperStorage** - Collecting `storage` usage metrics
- **aiogram_prometheus.PrometheusUpdatesMiddleware** - Collecting information about dispatcher `updates`
```python
import os
import aiogram
from aiogram import Bot, Dispatcher
from aiogram.fsm.storage.memory import MemoryStorage
from aiogram_prometheus import PrometheusUpdatesMiddleware, PrometheusWrapperStorage
bot = Bot(os.environ['ENV_TG_BOT'])
dp = Dispatcher(storage=PrometheusWrapperStorage(MemoryStorage()))
dp.update.middleware(PrometheusUpdatesMiddleware())
if __name__ == '__main__':
asyncio.run(dp.start_polling(bot))
```
## Classes
### aiogram_prometheus.PrometheusWrapperStorage
A wrapper around any storage you use that will collect usage metrics
```python
from aiogram import Bot, Dispatcher
from aiogram.fsm.storage.memory import MemoryStorage
from aiogram_prometheus import PrometheusWrapperStorage
dp = Dispatcher(storage=PrometheusWrapperStorage(MemoryStorage()))
```
### aiogram_prometheus.PrometheusUpdatesMiddleware
Intermediate layer for collecting metrics of updates processing
```python
from aiogram import Dispatcher
from aiogram_prometheus import PrometheusUpdatesMiddleware
dp = Dispatcher()
dp.update.middleware(PrometheusUpdatesMiddleware())
```
## Contribute
Issue Tracker: <https://gitlab.com/rocshers/python/aiogram-prometheus/-/issues>
Source Code: <https://gitlab.com/rocshers/python/aiogram-prometheus>
Before adding changes:
```bash
make install-dev
```
After changes:
```bash
make format test
```
Raw data
{
"_id": null,
"home_page": "https://projects.rocshers.com/open-source/aiogram-prometheus",
"name": "aiogram-prometheus",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.12",
"maintainer_email": null,
"keywords": "aiogram, prometheus",
"author": "Aleksei Marusich",
"author_email": "aleksei.marusich@rocshers.com",
"download_url": "https://files.pythonhosted.org/packages/fb/d1/342d5ac94506903637d0aada569ecff287a747dbbeddd3f89751a8c1d3ff/aiogram_prometheus-0.3.0.tar.gz",
"platform": null,
"description": "# Aiogram Prometheus Collector\n\nAiogram Based Metrics Collection for Prometheus\n\n[![PyPI](https://img.shields.io/pypi/v/aiogram-prometheus)](https://pypi.org/project/aiogram-prometheus/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aiogram-prometheus)](https://pypi.org/project/aiogram-prometheus/)\n[![Docs](https://img.shields.io/badge/docs-exists-blue)](https://projects.rocshers.com/open-source/aiogram-prometheus)\n\n[![Downloads](https://static.pepy.tech/badge/aiogram-prometheus)](https://pepy.tech/project/aiogram-prometheus)\n[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/aiogram-prometheus)](https://gitlab.com/rocshers/python/aiogram-prometheus)\n[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/aiogram-prometheus)](https://gitlab.com/rocshers/python/aiogram-prometheus)\n\n## Functionality\n\n- Monitoring the `status` of bots and dispatchers\n- Middleware for monitoring the bot's `network activity`\n- Middleware for monitoring the `event handler performance`\n\n![example](https://gitlab.com/rocshers/python/aiogram-prometheus/-/raw/release/docs/grafana_example.png)\n\n## Installation\n\n`pip install aiogram-prometheus`\n\n## Quick start\n\n- **aiogram_prometheus.PrometheusWrapperStorage** - Collecting `storage` usage metrics\n- **aiogram_prometheus.PrometheusUpdatesMiddleware** - Collecting information about dispatcher `updates`\n\n```python\nimport os\n\nimport aiogram\nfrom aiogram import Bot, Dispatcher\nfrom aiogram.fsm.storage.memory import MemoryStorage\n\nfrom aiogram_prometheus import PrometheusUpdatesMiddleware, PrometheusWrapperStorage\n\nbot = Bot(os.environ['ENV_TG_BOT'])\n\ndp = Dispatcher(storage=PrometheusWrapperStorage(MemoryStorage()))\ndp.update.middleware(PrometheusUpdatesMiddleware())\n\nif __name__ == '__main__':\n asyncio.run(dp.start_polling(bot))\n\n```\n\n## Classes\n\n### aiogram_prometheus.PrometheusWrapperStorage\n\nA wrapper around any storage you use that will collect usage metrics\n\n```python\nfrom aiogram import Bot, Dispatcher\nfrom aiogram.fsm.storage.memory import MemoryStorage\n\nfrom aiogram_prometheus import PrometheusWrapperStorage\n\ndp = Dispatcher(storage=PrometheusWrapperStorage(MemoryStorage()))\n```\n\n### aiogram_prometheus.PrometheusUpdatesMiddleware\n\nIntermediate layer for collecting metrics of updates processing\n\n```python\nfrom aiogram import Dispatcher\nfrom aiogram_prometheus import PrometheusUpdatesMiddleware\n\ndp = Dispatcher()\ndp.update.middleware(PrometheusUpdatesMiddleware())\n```\n\n## Contribute\n\nIssue Tracker: <https://gitlab.com/rocshers/python/aiogram-prometheus/-/issues> \nSource Code: <https://gitlab.com/rocshers/python/aiogram-prometheus>\n\nBefore adding changes:\n\n```bash\nmake install-dev\n```\n\nAfter changes:\n\n```bash\nmake format test\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Aiogram Based Metrics Collection for Prometheus",
"version": "0.3.0",
"project_urls": {
"Documentation": "https://projects.rocshers.com/open-source/aiogram-prometheus/docs",
"Homepage": "https://projects.rocshers.com/open-source/aiogram-prometheus",
"Repository": "https://gitlab.com/rocshers/python/aiogram-prometheus"
},
"split_keywords": [
"aiogram",
" prometheus"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1552027686765bb69b27bd4ef29c9b58accbebda5f0b7bd6ce1941802525c0ed",
"md5": "11182b10f2f29d5ab3892c30733e0533",
"sha256": "4d27cce7b4f44c87fe8bf7cfc9a63866dbea3c9626cb6e5896c9271f586805c9"
},
"downloads": -1,
"filename": "aiogram_prometheus-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "11182b10f2f29d5ab3892c30733e0533",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.12",
"size": 8132,
"upload_time": "2024-09-30T20:48:51",
"upload_time_iso_8601": "2024-09-30T20:48:51.801700Z",
"url": "https://files.pythonhosted.org/packages/15/52/027686765bb69b27bd4ef29c9b58accbebda5f0b7bd6ce1941802525c0ed/aiogram_prometheus-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fbd1342d5ac94506903637d0aada569ecff287a747dbbeddd3f89751a8c1d3ff",
"md5": "874cb6f90661666139544fdd04342f89",
"sha256": "e42febc6b893e3f01b3e8fd2ba3d42645b11f9d49979b8681dc75a1c4f7746dd"
},
"downloads": -1,
"filename": "aiogram_prometheus-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "874cb6f90661666139544fdd04342f89",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.12",
"size": 6077,
"upload_time": "2024-09-30T20:48:53",
"upload_time_iso_8601": "2024-09-30T20:48:53.644071Z",
"url": "https://files.pythonhosted.org/packages/fb/d1/342d5ac94506903637d0aada569ecff287a747dbbeddd3f89751a8c1d3ff/aiogram_prometheus-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-30 20:48:53",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "rocshers",
"gitlab_project": "python",
"lcname": "aiogram-prometheus"
}