freeleaps-service-hub/apps/authentication/webapi/providers/metrics.py
zhenyus 9754576d28 feat(probes): add metrics and probes APIs for application health checks
Signed-off-by: zhenyus <zhenyus@mathmast.com>
2025-03-12 15:59:06 +08:00

13 lines
555 B
Python

import logging
from prometheus_fastapi_instrumentator import Instrumentator
from common.config.app_settings import app_settings
def register(app):
instrumentator = Instrumentator().instrument(app,
metric_namespace="freeleaps",
metric_subsystem=app_settings.APP_NAME)
@app.on_event("startup")
async def startup():
instrumentator.expose(app, endpoint="/api/_/metrics", should_gzip=True)
logging.info("Metrics endpoint exposed at /api/_/metrics")