address greptile review feedback (greploop iteration 1)

- Add traceback to cache update warning logs (user, end_user, team, tag)
- Remove duplicate info log in non-redis commit path
This commit is contained in:
yuneng-jiang
2026-02-24 11:58:59 -08:00
parent c43a8dc842
commit 235d60eb88
2 changed files with 8 additions and 20 deletions
@@ -659,22 +659,6 @@ class DBSpendUpdateWriter:
db_spend_update_transactions = (
await self.spend_update_queue.flush_and_get_aggregated_db_spend_update_transactions()
)
if any(
len(v) > 0
for v in db_spend_update_transactions.values()
if isinstance(v, dict)
):
verbose_proxy_logger.info(
"Spend tracking - committing spend updates to DB (no Redis buffer): "
"keys=%d, users=%d, teams=%d, orgs=%d, end_users=%d, team_members=%d, tags=%d",
len(db_spend_update_transactions.get("key_list_transactions") or {}),
len(db_spend_update_transactions.get("user_list_transactions") or {}),
len(db_spend_update_transactions.get("team_list_transactions") or {}),
len(db_spend_update_transactions.get("org_list_transactions") or {}),
len(db_spend_update_transactions.get("end_user_list_transactions") or {}),
len(db_spend_update_transactions.get("team_member_list_transactions") or {}),
len(db_spend_update_transactions.get("tag_list_transactions") or {}),
)
await self._commit_spend_updates_to_db(
prisma_client=prisma_client,
n_retry_times=n_retry_times,
+8 -4
View File
@@ -1771,10 +1771,11 @@ async def update_cache( # noqa: PLR0915
verbose_proxy_logger.warning(
"Spend tracking - failed to update user spend in cache. "
"Budget enforcement may use stale spend values. "
"user_id=%s, response_cost=%s - %s",
"user_id=%s, response_cost=%s - %s\n%s",
user_id,
response_cost,
str(e),
traceback.format_exc(),
)
### UPDATE END-USER SPEND ###
@@ -1814,10 +1815,11 @@ async def update_cache( # noqa: PLR0915
verbose_proxy_logger.warning(
"Spend tracking - failed to update end user spend in cache. "
"Budget enforcement may use stale spend values. "
"end_user_id=%s, response_cost=%s - %s",
"end_user_id=%s, response_cost=%s - %s\n%s",
end_user_id,
response_cost,
str(e),
traceback.format_exc(),
)
### UPDATE TEAM SPEND ###
@@ -1861,10 +1863,11 @@ async def update_cache( # noqa: PLR0915
verbose_proxy_logger.warning(
"Spend tracking - failed to update team spend in cache. "
"Budget enforcement may use stale spend values. "
"team_id=%s, response_cost=%s - %s",
"team_id=%s, response_cost=%s - %s\n%s",
team_id,
response_cost,
str(e),
traceback.format_exc(),
)
### UPDATE TAG SPEND ###
@@ -1912,10 +1915,11 @@ async def update_cache( # noqa: PLR0915
verbose_proxy_logger.warning(
"Spend tracking - failed to update tag spend in cache. "
"Budget enforcement may use stale spend values. "
"tags=%s, response_cost=%s - %s",
"tags=%s, response_cost=%s - %s\n%s",
tags,
response_cost,
str(e),
traceback.format_exc(),
)
if token is not None and response_cost is not None: