mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(prometheus): use return_exceptions=True for budget metric lookups
Make asyncio.gather resilient to partial failures. If key, team, or user lookup raises, log at debug level and allow the others to complete. Prevents one failing lookup from blocking the rest.
This commit is contained in:
parent
bbe5465bc3
commit
5735a2c2a2
1 changed files with 7 additions and 1 deletions
|
|
@ -1174,7 +1174,7 @@ class PrometheusLogger(CustomLogger):
|
|||
"user_api_key_user_max_budget", None
|
||||
)
|
||||
|
||||
await asyncio.gather(
|
||||
results = await asyncio.gather(
|
||||
self._set_api_key_budget_metrics_after_api_request(
|
||||
user_api_key=user_api_key,
|
||||
user_api_key_alias=user_api_key_alias,
|
||||
|
|
@ -1195,7 +1195,13 @@ class PrometheusLogger(CustomLogger):
|
|||
user_max_budget=_user_max_budget,
|
||||
response_cost=response_cost,
|
||||
),
|
||||
return_exceptions=True,
|
||||
)
|
||||
for i, r in enumerate(results):
|
||||
if isinstance(r, Exception):
|
||||
verbose_logger.debug(
|
||||
f"[Non-Blocking] Prometheus: Budget metric lookup {['key', 'team', 'user'][i]} failed: {r}"
|
||||
)
|
||||
|
||||
def _increment_top_level_request_and_spend_metrics(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue