faststreamprometheus 0.1.5
FastStream Prometheus Collector
FastStream Based Metrics Collection for Prometheus
Functionality
Collection metrics via middleware
Collecting general metrics
Collecting details kafka metrics
Installation
pip install faststream-prometheus
Quick start
See example for details
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)
# 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:
make install-dev
After changes:
make format test
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.