fix(prometheus): route litellm_callback_logging_failures_metric through get_labels_for_metric

The metric was registered with hardcoded labelnames=["callback_name"] instead of
going through get_labels_for_metric(), so prometheus_exclude_labels had no effect
on it. Route through get_labels_for_metric() and wrap the observation site with
_safe_labels() for consistency.
This commit is contained in:
Ishaan Jaffer 2026-03-23 18:53:03 -07:00
parent 56dec8d040
commit 5a2b2e4ee7

View file

@ -397,7 +397,9 @@ class PrometheusLogger(CustomLogger):
self.litellm_callback_logging_failures_metric = self._counter_factory(
name="litellm_callback_logging_failures_metric",
documentation="Total number of failures when emitting logs to callbacks (e.g. s3_v2, langfuse, etc)",
labelnames=["callback_name"],
labelnames=self.get_labels_for_metric(
"litellm_callback_logging_failures_metric"
),
)
self.litellm_llm_api_failed_requests_metric = self._counter_factory(
@ -2432,7 +2434,10 @@ class PrometheusLogger(CustomLogger):
Increment metric when logging to a callback fails (e.g., s3_v2, langfuse, etc.)
"""
self.litellm_callback_logging_failures_metric.labels(
callback_name=callback_name
**self._safe_labels(
self.litellm_callback_logging_failures_metric,
callback_name=callback_name,
)
).inc()
def track_provider_remaining_budget(