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

Extend LATENCY_BUCKETS beyond 5 minutes so request/LLM latency metrics
can distinguish long runs up to the typical default LLM request timeout.

Made-with: Cursor
This commit is contained in:
Bohdan Kulinich
2026-04-04 18:48:39 -07:00
committed by GitHub
parent fc75380b88
commit 23e702dae6
2 changed files with 19 additions and 0 deletions
+2
View File
@@ -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"),
)
@@ -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