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]

feat(prometheus): add 7m and 10m latency histogram buckets (#25071)

Bohdan Kulinich23e702dae609
diff --git a/litellm/types/integrations/prometheus.py b/litellm/types/integrations/prometheus.py
index 0d1501664b9..35b695cd054 100644
--- a/litellm/types/integrations/prometheus.py
+++ b/litellm/types/integrations/prometheus.py
@@ -156,6 +156,8 @@ LATENCY_BUCKETS = (
180.0,
240.0,
300.0,
+ 420.0, # 7 minutes
+ 600.0, # 10 minutes (typical default LLM request timeout)
float("inf"),
)
diff --git a/tests/test_litellm/types/test_prometheus_latency_buckets.py b/tests/test_litellm/types/test_prometheus_latency_buckets.py
new file mode 100644
index 00000000000..85670bb0b74
--- /dev/null
+++ b/tests/test_litellm/types/test_prometheus_latency_buckets.py
@@ -0,0 +1,17 @@
+"""LATENCY_BUCKETS covers long-running LLM calls (histograms are in seconds)."""
+
+import math
+
+from litellm.types.integrations.prometheus import LATENCY_BUCKETS
+
+
+def test_latency_buckets_include_seven_and_ten_minutes():
+ """Buckets beyond 5 min so histograms resolve requests up to default LLM timeouts."""
+ assert 300.0 in LATENCY_BUCKETS
+ assert 420.0 in LATENCY_BUCKETS # 7 min
+ assert 600.0 in LATENCY_BUCKETS # 10 min
+ assert math.isinf(LATENCY_BUCKETS[-1])
+ idx_300 = LATENCY_BUCKETS.index(300.0)
+ idx_420 = LATENCY_BUCKETS.index(420.0)
+ idx_600 = LATENCY_BUCKETS.index(600.0)
+ assert idx_300 < idx_420 < idx_600