litellm/tests/test_litellm/proxy/spend_tracking
devin-ai-integration[bot] 3e23eae248
fix(proxy): keep call_type and request start time on failed-request spend logs (#40558)
* fix(proxy): keep call_type and request start time on failed-request spend logs

post_call_failure_hook pops litellm_logging_obj before the failure callbacks
run, so the spend row built from request_data had a blank call_type and used
datetime.now() as the start time. A guardrail-blocked MCP tool call therefore
showed up in the Logs page as an LLM row with no call type and a 0s duration.
Lift call_type and start_time off the logging object alongside the fields
already lifted, and have the DB failure hook prefer the lifted start time.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(proxy): inject the spend writer into _ProxyDBLogger instead of patching a module global

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yucheng <yucheng@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 12:22:18 -07:00
..
test_budget_reservation.py feat(rust_bridge): count budget-check input tokens in Rust on all LLM routes (#40381) 2026-09-10 13:56:30 -07:00
test_budget_reservation_redis_failure.py perf(proxy): pipeline spend counter increments into one Redis call per request (#40371) 2026-09-09 10:35:50 -07:00
test_cloudzero_endpoints.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_compression_savings.py feat(spend): track prompt compression saved tokens in daily spend aggregates (#33810) 2026-07-18 17:47:54 -07:00
test_key_metadata_recovery.py fix(spend-tracking): bound the spend-log scan with a statement timeout and name only unanimous alias, team, and owner 2026-09-08 17:24:22 -07:00
test_ptu_feature_flag.py feat(ptu): gate PTU flat-cost attribution behind an opt-in env var (#36138) 2026-08-10 12:23:20 -07:00
test_ptu_flat_cost_rollup.py test(ptu): drop the assertion on the flag removed upstream 2026-08-23 10:02:41 +00:00
test_savings.py fix(spend): compare auto-router targets by deployment identity (#40206) 2026-09-07 23:29:42 -07:00
test_spend_event.py feat(proxy): offload spend tracking to a pod-local collector sidecar (#40545) 2026-09-10 17:14:13 -07:00
test_spend_event_producer.py feat(proxy): offload spend tracking to a pod-local collector sidecar (#40545) 2026-09-10 17:14:13 -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 Merge pull request #40604 from BerriAI/litellm_lit7490_classifier_audit 2026-09-10 15:48:05 -07:00
test_spend_query_optimization.py test(proxy): pass search=None in direct ui_view_spend_logs calls 2026-09-03 16:04:41 -07:00
test_spend_tracking_utils.py fix(proxy): keep call_type and request start time on failed-request spend logs (#40558) 2026-09-11 12:22:18 -07:00