From f16c531002268a97d608e814e018f26cc4f8ba87 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 4 Apr 2025 19:54:20 -0700 Subject: [PATCH] _mount_metrics_endpoint --- litellm/integrations/prometheus.py | 44 ------------------------------ 1 file changed, 44 deletions(-) diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.py index 6cd413857bf..7c23ef86f4e 100644 --- a/litellm/integrations/prometheus.py +++ b/litellm/integrations/prometheus.py @@ -1742,19 +1742,6 @@ class PrometheusLogger(CustomLogger): f"Prometheus metrics are only available for premium users. {CommonProxyErrors.not_premium_user.value}" ) - if PrometheusLogger._should_init_metrics_with_auth(): - PrometheusLogger._mount_metrics_endpoint_with_auth() - else: - # Mount metrics directly without authentication - PrometheusLogger._mount_metrics_endpoint_without_auth() - - @staticmethod - def _mount_metrics_endpoint_without_auth(): - from prometheus_client import make_asgi_app - - from litellm._logging import verbose_proxy_logger - from litellm.proxy.proxy_server import app - # Create metrics ASGI app metrics_app = make_asgi_app() @@ -1764,37 +1751,6 @@ class PrometheusLogger(CustomLogger): "Starting Prometheus Metrics on /metrics (no authentication)" ) - @staticmethod - def _mount_metrics_endpoint_with_auth(): - from fastapi import APIRouter, Depends - from prometheus_client import make_asgi_app - - from litellm._logging import verbose_proxy_logger - from litellm.proxy.auth.user_api_key_auth import user_api_key_auth - from litellm.proxy.proxy_server import app - - # Create metrics ASGI app - metrics_app = make_asgi_app() - - # Create a router for authenticated metrics - metrics_router = APIRouter() - - # Add metrics endpoint with authentication - @metrics_router.get("/metrics", dependencies=[Depends(user_api_key_auth)]) - async def authenticated_metrics(): - verbose_proxy_logger.debug("Serving authenticated metrics endpoint") - return metrics_app - - # Mount the router to the app - app.include_router(metrics_router) - verbose_proxy_logger.debug( - "Starting Prometheus Metrics on /metrics with authentication" - ) - - @staticmethod - def _should_init_metrics_with_auth(): - return litellm.require_auth_for_metrics_endpoint - def prometheus_label_factory( supported_enum_labels: List[str],