13 lines
415 B
Python
13 lines
415 B
Python
|
|
from fastapi import APIRouter, Query
|
||
|
|
from fastapi.responses import PlainTextResponse
|
||
|
|
|
||
|
|
from app.metrics import metrics
|
||
|
|
|
||
|
|
router = APIRouter()
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/metrics")
|
||
|
|
async def get_metrics(format: str = Query(default="json", description="json | prometheus")):
|
||
|
|
if format == "prometheus":
|
||
|
|
return PlainTextResponse(metrics.prometheus(), media_type="text/plain; version=0.0.4")
|
||
|
|
return metrics.snapshot()
|