freeleaps-authentication/webapi/providers/metrics.py

16 lines
548 B
Python
Raw Normal View History

2025-10-30 03:26:05 +00:00
import logging
from prometheus_fastapi_instrumentator import Instrumentator
from common.config.app_settings import app_settings
2025-10-30 03:26:05 +00:00
def register(app):
instrumentator = Instrumentator().instrument(
app,
metric_namespace="freeleaps_{}".format(app_settings.FREELEAPS_PRODUCT_ID),
metric_subsystem=app_settings.ENVIRONMENT)
2025-10-30 03:26:05 +00:00
@app.on_event("startup")
async def startup():
instrumentator.expose(app, endpoint="/api/_/metrics", should_gzip=True)
logging.info("Metrics endpoint exposed at /api/_/metrics")