From 13ffb9aed5c4bb2f5aa99f07a235aa07a344f0d4 Mon Sep 17 00:00:00 2001 From: harish-berri Date: Tue, 28 Apr 2026 21:27:55 +0000 Subject: [PATCH] update auth metric increment comment from greptile --- litellm/proxy/auth/auth_metrics.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/auth/auth_metrics.py b/litellm/proxy/auth/auth_metrics.py index 0b463cc920f..7284ba42736 100644 --- a/litellm/proxy/auth/auth_metrics.py +++ b/litellm/proxy/auth/auth_metrics.py @@ -13,6 +13,7 @@ Usage:: """ from litellm._logging import verbose_proxy_logger +from litellm.types.integrations.prometheus import UserAPIKeyLabelValues class AuthMetrics: @@ -42,9 +43,16 @@ class AuthMetrics: try: prom = AuthMetrics._get_prom() if prom is not None: - prom.litellm_auth_combined_view_queries_total.labels( - hashed_api_key=hashed_token - ).inc() + # Counter labelnames include ``hashed_api_key`` plus any + # ``custom_prometheus_metadata_labels`` / ``custom_prometheus_tags`` + # (see ``PrometheusMetricLabels.get_labels``). Use the same + # ``_inc_labeled_counter`` + ``prometheus_label_factory`` path as + # other metrics so label cardinality always matches registration. + prom._inc_labeled_counter( + prom.litellm_auth_combined_view_queries_total, + "litellm_auth_combined_view_queries_total", + UserAPIKeyLabelValues(hashed_api_key=hashed_token), + ) except Exception as e: verbose_proxy_logger.debug( "AuthMetrics.inc_combined_view_query: failed to increment counter: %s",