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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
style: apply Black formatting to Prometheus integration modules
shivam49ddb0e5bad5
diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.pyindex b3bf792e93b..d5fde2a4864 100644--- a/litellm/integrations/prometheus.py+++ b/litellm/integrations/prometheus.py@@ -88,7 +88,9 @@ class PrometheusLogger(CustomLogger):_custom_buckets = litellm.prometheus_latency_bucketsself.latency_buckets = (- tuple(_custom_buckets) if _custom_buckets is not None else LATENCY_BUCKETS+ tuple(_custom_buckets)+ if _custom_buckets is not None+ else LATENCY_BUCKETS)# Create metric factory functions@@ -1097,9 +1099,11 @@ class PrometheusLogger(CustomLogger):),client_ip=standard_logging_payload["metadata"].get("requester_ip_address"),user_agent=standard_logging_payload["metadata"].get("user_agent"),- stream=str(standard_logging_payload.get("stream"))- if litellm.prometheus_emit_stream_label- else None,+ stream=(+ str(standard_logging_payload.get("stream"))+ if litellm.prometheus_emit_stream_label+ else None+ ),)if (@@ -1767,9 +1771,11 @@ class PrometheusLogger(CustomLogger):client_ip=_metadata.get("requester_ip_address"),user_agent=_metadata.get("user_agent"),model_id=model_id,- stream=str(request_data.get("stream"))- if litellm.prometheus_emit_stream_label- else None,+ stream=(+ str(request_data.get("stream"))+ if litellm.prometheus_emit_stream_label+ else None+ ),)_labels = prometheus_label_factory(supported_enum_labels=self.get_labels_for_metric(@@ -2093,9 +2099,9 @@ class PrometheusLogger(CustomLogger):):try:verbose_logger.debug("setting remaining tokens requests metric")- standard_logging_payload: Optional[- StandardLoggingPayload- ] = request_kwargs.get("standard_logging_object")+ standard_logging_payload: Optional[StandardLoggingPayload] = (+ request_kwargs.get("standard_logging_object")+ )if standard_logging_payload is None:return@@ -2728,9 +2734,7 @@ class PrometheusLogger(CustomLogger):)return- async def fetch_keys(- page_size: int, page: int- ) -> Tuple[+ async def fetch_keys(page_size: int, page: int) -> Tuple[List[Union[str, UserAPIKeyAuth, LiteLLM_DeletedVerificationToken]],Optional[int],]:@@ -2921,9 +2925,11 @@ class PrometheusLogger(CustomLogger):org_alias=org.organization_alias or "",spend=org.spend or 0.0,max_budget=budget_table.max_budget if budget_table else None,- budget_reset_at=getattr(budget_table, "budget_reset_at", None)- if budget_table- else None,+ budget_reset_at=(+ getattr(budget_table, "budget_reset_at", None)+ if budget_table+ else None+ ),)async def _set_team_budget_metrics_after_api_request(@@ -3405,10 +3411,10 @@ class PrometheusLogger(CustomLogger):from litellm.constants import PROMETHEUS_BUDGET_METRICS_REFRESH_INTERVAL_MINUTESfrom litellm.integrations.custom_logger import CustomLogger- prometheus_loggers: List[- CustomLogger- ] = litellm.logging_callback_manager.get_custom_loggers_for_type(- callback_type=PrometheusLogger+ prometheus_loggers: List[CustomLogger] = (+ litellm.logging_callback_manager.get_custom_loggers_for_type(+ callback_type=PrometheusLogger+ ))# we need to get the initialized prometheus logger instance(s) and call logger.initialize_remaining_budget_metrics() on themverbose_logger.debug("found %s prometheus loggers", len(prometheus_loggers))diff --git a/litellm/proxy/middleware/prometheus_auth_middleware.py b/litellm/proxy/middleware/prometheus_auth_middleware.pyindex d5dec6c4bda..3b30fd3d63c 100644--- a/litellm/proxy/middleware/prometheus_auth_middleware.py+++ b/litellm/proxy/middleware/prometheus_auth_middleware.py@@ -1,6 +1,7 @@"""Prometheus Auth Middleware - Pure ASGI implementation"""+import jsonfrom typing import Any, List, MutableMappingdiff --git a/litellm/types/integrations/prometheus.py b/litellm/types/integrations/prometheus.pyindex 51a41f97e03..1b36ad5daa6 100644--- a/litellm/types/integrations/prometheus.py+++ b/litellm/types/integrations/prometheus.py@@ -676,9 +676,9 @@ class PrometheusMetricLabels:litellm_managed_batch_created_total = _batch_user_labels- litellm_managed_file_size_bytes: List[- str- ] = [] # labels: purpose, file_type, model, api_provider, user (custom)+ litellm_managed_file_size_bytes: List[str] = (+ []+ ) # labels: purpose, file_type, model, api_provider, user (custom)litellm_managed_batch_duration_seconds = [UserAPIKeyLabelNames.v1_LITELLM_MODEL_NAME.value,@@ -687,9 +687,9 @@ class PrometheusMetricLabels:litellm_managed_file_created_total = _batch_user_labels- litellm_managed_file_deleted_total: List[- str- ] = [] # only "result" label, added at metric creation+ litellm_managed_file_deleted_total: List[str] = (+ []+ ) # only "result" label, added at metric creationlitellm_check_batch_cost_jobs_polled: List[str] = []