Skip to content

Commit 46071b9

Browse files
committed
fix(test): add _observe_once to exclude-labels test so assertion actually executes
1 parent 6cb570d commit 46071b9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_litellm/integrations/test_prometheus_latency_buckets.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,21 @@ def test_exclude_labels_strips_label_from_metrics():
218218

219219
logger = PrometheusLogger()
220220

221+
# Force at least one observation so the labeled histogram emits samples to
222+
# the registry; without this, family.samples is empty and the assertion
223+
# below never executes (trivially passing even if exclude_labels is broken).
224+
_observe_once(logger)
225+
221226
# Verify via the registry: no sample for litellm_request_total_latency_metric
222227
# should carry the end_user label key
228+
found_any_sample = False
223229
for family in REGISTRY.collect():
224230
if family.name == "litellm_request_total_latency_metric":
225231
for sample in family.samples:
232+
found_any_sample = True
226233
assert (
227234
"end_user" not in sample.labels
228235
), f"end_user label found in sample {sample}"
236+
assert (
237+
found_any_sample
238+
), "No samples found; _observe_once did not populate the registry"

0 commit comments

Comments
 (0)