# FastStream Prometheus Collector
FastStream Based Metrics Collection for Prometheus
[![PyPI](https://img.shields.io/pypi/v/faststream-prometheus)](https://pypi.org/project/faststream-prometheus/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/faststream-prometheus)](https://pypi.org/project/faststream-prometheus/)
[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/faststream-prometheus)](https://gitlab.com/rocshers/python/faststream-prometheus)
[![Docs](https://img.shields.io/badge/docs-exist-blue)](https://projects.rocshers.com/open-source/faststream-prometheus/docs)
[![Test coverage](https://codecov.io/gitlab/rocshers:python/faststream-prometheus/graph/badge.svg)](https://codecov.io/gitlab/rocshers:python/faststream-prometheus)
[![Downloads](https://static.pepy.tech/badge/faststream-prometheus)](https://pepy.tech/project/faststream-prometheus)
[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/faststream-prometheus)](https://gitlab.com/rocshers/python/faststream-prometheus)
## Functionality
- Collection metrics via `middleware`
- Collecting general metrics
- Collecting `details kafka` metrics
## Installation
`pip install faststream-prometheus`
## Quick start
See [example](https://gitlab.com/rocshers/python/faststream-prometheus/-/blob/release/test_app.py) for details
```python
import uvicorn
from fastapi import FastAPI
from faststream.kafka.fastapi import KafkaRouter
from prometheus_fastapi_instrumentator import Instrumentator
# Import Faststream Middleware for collect metrics
from faststream_prometheus import FaststreamPrometheusMiddleware
# Adding middleware
faststream_router = KafkaRouter(
'localhost:9092',
middlewares=[FaststreamPrometheusMiddleware(prefix='test_faststream')],
)
# Setup export metrics via FastAPI -> HTTP GET /metrics
app = FastAPI(lifespan=faststream_router.lifespan_context)
app.include_router(faststream_router)
instrumentator = Instrumentator().instrument(app, metric_namespace='fastapi').expose(app)
```
```bash
# see default metrics
curl localhost:8000/metrics
```
## Contribute
Issue Tracker: <https://gitlab.com/rocshers/python/faststream-prometheus/-/issues>
Source Code: <https://gitlab.com/rocshers/python/faststream-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/faststream-prometheus",
"name": "faststream-prometheus",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.9",
"maintainer_email": null,
"keywords": "faststream, prometheus",
"author": "Aleksei Marusich",
"author_email": "aleksei.marusich@rocshers.com",
"download_url": "https://files.pythonhosted.org/packages/3b/ce/cabbd854f6cedc55eb4866c3de2f5adf858c786cc7434cd6bb4927edc721/faststream_prometheus-0.1.5.tar.gz",
"platform": null,
"description": "# FastStream Prometheus Collector\n\nFastStream Based Metrics Collection for Prometheus\n\n[![PyPI](https://img.shields.io/pypi/v/faststream-prometheus)](https://pypi.org/project/faststream-prometheus/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/faststream-prometheus)](https://pypi.org/project/faststream-prometheus/)\n[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/faststream-prometheus)](https://gitlab.com/rocshers/python/faststream-prometheus)\n[![Docs](https://img.shields.io/badge/docs-exist-blue)](https://projects.rocshers.com/open-source/faststream-prometheus/docs)\n\n[![Test coverage](https://codecov.io/gitlab/rocshers:python/faststream-prometheus/graph/badge.svg)](https://codecov.io/gitlab/rocshers:python/faststream-prometheus)\n[![Downloads](https://static.pepy.tech/badge/faststream-prometheus)](https://pepy.tech/project/faststream-prometheus)\n[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/faststream-prometheus)](https://gitlab.com/rocshers/python/faststream-prometheus)\n\n## Functionality\n\n- Collection metrics via `middleware`\n- Collecting general metrics\n- Collecting `details kafka` metrics\n\n## Installation\n\n`pip install faststream-prometheus`\n\n## Quick start\n\nSee [example](https://gitlab.com/rocshers/python/faststream-prometheus/-/blob/release/test_app.py) for details\n\n```python\nimport uvicorn\nfrom fastapi import FastAPI\nfrom faststream.kafka.fastapi import KafkaRouter\nfrom prometheus_fastapi_instrumentator import Instrumentator\n\n# Import Faststream Middleware for collect metrics \nfrom faststream_prometheus import FaststreamPrometheusMiddleware\n\n# Adding middleware \nfaststream_router = KafkaRouter(\n 'localhost:9092',\n middlewares=[FaststreamPrometheusMiddleware(prefix='test_faststream')],\n)\n\n# Setup export metrics via FastAPI -> HTTP GET /metrics\napp = FastAPI(lifespan=faststream_router.lifespan_context)\napp.include_router(faststream_router)\n\ninstrumentator = Instrumentator().instrument(app, metric_namespace='fastapi').expose(app)\n\n```\n\n```bash\n# see default metrics\ncurl localhost:8000/metrics\n```\n\n## Contribute\n\nIssue Tracker: <https://gitlab.com/rocshers/python/faststream-prometheus/-/issues> \nSource Code: <https://gitlab.com/rocshers/python/faststream-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": "FastStream Based Metrics Collection for Prometheus",
"version": "0.1.5",
"project_urls": {
"Documentation": "https://projects.rocshers.com/open-source/faststream-prometheus/docs",
"Homepage": "https://projects.rocshers.com/open-source/faststream-prometheus",
"Repository": "https://gitlab.com/rocshers/python/faststream-prometheus"
},
"split_keywords": [
"faststream",
" prometheus"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b2f48b43941c00d593119c21673620015a523f85274fe0a01f2106d793fec430",
"md5": "4b7e3e21411bb969b1e9ccd32fbc9b28",
"sha256": "fc00b21c9da56e5bda96074769e812ee5b7f1e27c2511a265130237ba3138b9f"
},
"downloads": -1,
"filename": "faststream_prometheus-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4b7e3e21411bb969b1e9ccd32fbc9b28",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 5531,
"upload_time": "2024-09-05T15:13:18",
"upload_time_iso_8601": "2024-09-05T15:13:18.005360Z",
"url": "https://files.pythonhosted.org/packages/b2/f4/8b43941c00d593119c21673620015a523f85274fe0a01f2106d793fec430/faststream_prometheus-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3bcecabbd854f6cedc55eb4866c3de2f5adf858c786cc7434cd6bb4927edc721",
"md5": "ed42e02d9caa53ee24ac4aea7f79e587",
"sha256": "69e200e535577b239215057485ace97d56d853c174e2ff1257de08d528e1277e"
},
"downloads": -1,
"filename": "faststream_prometheus-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "ed42e02d9caa53ee24ac4aea7f79e587",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 5179,
"upload_time": "2024-09-05T15:13:19",
"upload_time_iso_8601": "2024-09-05T15:13:19.164794Z",
"url": "https://files.pythonhosted.org/packages/3b/ce/cabbd854f6cedc55eb4866c3de2f5adf858c786cc7434cd6bb4927edc721/faststream_prometheus-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-05 15:13:19",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "rocshers",
"gitlab_project": "python",
"lcname": "faststream-prometheus"
}