Spaces:
Sleeping
Sleeping
feat: expose Prometheus scrape endpoint at /metrics/prometheus
Browse filesIn-memory MetricsCollector is preserved for agent-level stats.
prometheus-fastapi-instrumentator adds standard HTTP metrics
(request count, latency histograms) for Grafana/Alertmanager.
- app/api/main.py +2 -0
- requirements.txt +2 -1
app/api/main.py
CHANGED
|
@@ -5,12 +5,14 @@ from slowapi import _rate_limit_exceeded_handler
|
|
| 5 |
from slowapi.errors import RateLimitExceeded
|
| 6 |
from app.api.limiter import limiter
|
| 7 |
import os
|
|
|
|
| 8 |
|
| 9 |
app = FastAPI(
|
| 10 |
title="AI Code Review Agent",
|
| 11 |
description="Multi-agent AI platform that simulates a software engineering team",
|
| 12 |
version="0.1.0"
|
| 13 |
)
|
|
|
|
| 14 |
|
| 15 |
app.state.limiter = limiter
|
| 16 |
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
|
|
|
|
| 5 |
from slowapi.errors import RateLimitExceeded
|
| 6 |
from app.api.limiter import limiter
|
| 7 |
import os
|
| 8 |
+
from prometheus_fastapi_instrumentator import Instrumentator
|
| 9 |
|
| 10 |
app = FastAPI(
|
| 11 |
title="AI Code Review Agent",
|
| 12 |
description="Multi-agent AI platform that simulates a software engineering team",
|
| 13 |
version="0.1.0"
|
| 14 |
)
|
| 15 |
+
Instrumentator().instrument(app).expose(app, endpoint="/metrics/prometheus")
|
| 16 |
|
| 17 |
app.state.limiter = limiter
|
| 18 |
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
|
requirements.txt
CHANGED
|
@@ -25,4 +25,5 @@ slowapi
|
|
| 25 |
pytest-asyncio
|
| 26 |
fastapi==0.115.12
|
| 27 |
uvicorn==0.34.3
|
| 28 |
-
tenacity==8.3.0
|
|
|
|
|
|
| 25 |
pytest-asyncio
|
| 26 |
fastapi==0.115.12
|
| 27 |
uvicorn==0.34.3
|
| 28 |
+
tenacity==8.3.0
|
| 29 |
+
prometheus-fastapi-instrumentator
|