litellm/tests/test_litellm/proxy/spend_tracking
Yassin Kortam 7209e139d6
fix(spend): fold logs-tab total into the page query to avoid a separate COUNT(*) (#31423)
The spend-logs UI list endpoint (/spend/logs/ui, /spend/logs/v2) ran a standalone
SELECT COUNT(*) before the page query to compute total_pages. On sharded engines
like YugabyteDB a COUNT(*) is a distributed RPC that contacts every tablet leader
and aggregates partial results regardless of row count, so it hits the distributed
RPC timeout and the logs tab 500s even on a one-minute window with a couple of rows.
The startTime range cannot prune tablets because rows hash to tablets on request_id,
not startTime.

Fold the count into the same scan as the page data with COUNT(*) OVER () and read
total off the returned rows, dropping the helper column before serialisation. One
distributed scan per page load instead of two; the response shape is unchanged. An
empty page carries no count row, in which case the total is zero.

Resolves LIT-4027
2026-06-26 13:01:05 -07:00
..
test_budget_reservation_redis_failure.py fix(register_model): preserve built-in cache pricing when registering custom overrides under unmapped keys (#30044) 2026-06-10 12:11:03 -07:00
test_cloudzero_endpoints.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_spend_log_error_logger.py feat(spend-logs): opt-in suppression of stack traces in spend-tracking error logs 2026-05-02 00:44:34 +00:00
test_spend_management_endpoints.py fix(spend): fold logs-tab total into the page query to avoid a separate COUNT(*) (#31423) 2026-06-26 13:01:05 -07:00
test_spend_query_optimization.py fix(spend): fold logs-tab total into the page query to avoid a separate COUNT(*) (#31423) 2026-06-26 13:01:05 -07:00
test_spend_tracking_utils.py feat(spend): store litellm_call_id on spend logs for DB-to-trace correlation (#31344) 2026-06-25 17:45:37 -07:00