Files
BanGUI/backend/app/routers/metrics.py
Lukas 7ec80fdeec refactor(logging): replace structlog with stdlib logging compat layer
- Remove structlog dependency from backend/pyproject.toml
- Add app.utils.logging_compat shim for keyword-arg logging API
- Add app.utils.json_formatter for JSON log output with extra fields
- Update all backend modules to use logging_compat.get_logger()
- Update docstrings in log_sanitizer.py and json_formatter.py
- Update test comment in test_async_utils.py
- Record 406 failing tests in Docs/Tasks.md for tracking
2026-05-10 13:37:54 +02:00

37 lines
918 B
Python

"""Prometheus metrics endpoint for BanGUI.
Exposes collected metrics in Prometheus text format at GET /metrics.
"""
from __future__ import annotations
from app.utils.logging_compat import get_logger
from fastapi import APIRouter
from starlette.responses import Response
from app.utils.metrics import get_metrics, get_metrics_content_type
log = get_logger(__name__)
router = APIRouter()
@router.get(
"/metrics",
tags=["observability"],
summary="Prometheus metrics endpoint",
description="Exposes application metrics in Prometheus text format (OpenMetrics)",
include_in_schema=False,
)
async def get_application_metrics() -> Response:
"""Get Prometheus metrics.
Returns:
Prometheus-formatted metrics as plain text.
"""
log.debug("metrics_endpoint_accessed")
return Response(
content=get_metrics(),
media_type=get_metrics_content_type(),
)