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]

style(prometheus): sync prometheus.py formatting with origin/main

Ishaan Jaffer2395a2db4da5
diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.py
index d5fde2a4864..b3bf792e93b 100644
--- a/litellm/integrations/prometheus.py
+++ b/litellm/integrations/prometheus.py
@@ -88,9 +88,7 @@ class PrometheusLogger(CustomLogger):
_custom_buckets = litellm.prometheus_latency_buckets
self.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
@@ -1099,11 +1097,9 @@ 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 (
@@ -1771,11 +1767,9 @@ 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(
@@ -2099,9 +2093,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
@@ -2734,7 +2728,9 @@ 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],
]:
@@ -2925,11 +2921,9 @@ 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(
@@ -3411,10 +3405,10 @@ class PrometheusLogger(CustomLogger):
from litellm.constants import PROMETHEUS_BUDGET_METRICS_REFRESH_INTERVAL_MINUTES
from 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 them
verbose_logger.debug("found %s prometheus loggers", len(prometheus_loggers))