Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

_mount_metrics_endpoint

Ishaan Jafff16c53100226
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],