mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-01 01:18:34 +00:00
* fix(logging): keep each proxy traceback in one JSON record and log token-count skips at debug With JSON logs on, exceptions raised in a thread or a destructor, and the aiohttp unclosed-session warning, printed as plain multi-line text, so a log collector split each traceback into one error entry per line. The thread and unraisable hooks now write one JSON record each, env-only JSON_LOGS sets up JSON logging the way the json_logs config key does, and the pre-call token count skip logs at DEBUG like the other skips in the same check. * fix(logging): leave operator root handlers alone when JSON logs come from the env Running the full JSON setup when proxy_server imports replaced the root handlers that an operator's --log_config or OpenTelemetry had installed. JSON mode now swaps Python's logging.lastResort for the JSON handler at WARNING instead. Python only uses it when no handler takes a record, so asyncio and aiohttp warnings still come out as one JSON record and configured handlers keep getting theirs * fix(logging): write JSON hook records to the current stderr The JSON handler behind the exception hooks and logging.lastResort kept the stderr that existed when JSON logs turned on, so a caller that redirected sys.stderr later lost thread tracebacks, destructor errors and unhandled library warnings. It now resolves stderr per record, like Python's defaults and litellm's own log handler * fix(logging): keep host hooks, exit-time destructor errors and whole hook tracebacks Install the JSON hooks only where Python's defaults are still in place, fall back to Python's own unraisable hook while the interpreter shuts down, keep hook tracebacks untruncated, drop the active request's trace id from destructor records, name the raising file and line in the logger field, and log the Responses MCP stream errors through the logger instead of traceback.print_exc() * fix(logging): keep JSON crash output under ddtrace-run, cap hook records and drop trace ids from GC records JSON logs take over sys.excepthook as before and still run a hook another tool set first, such as ddtrace-run's, with the plain traceback it hands to Python dropped. Hook records follow MAX_STRING_LENGTH_STDOUT_LOG again, and records no handler takes carry no trace id. The MCP stream test now fails the follow-up call against a closed local port instead of replacing aresponses. * fix(logging): replace sys.excepthook as before instead of muting stderr for the replaced hook Running the replaced hook with process-wide stderr redirected also dropped log lines other threads wrote meanwhile, so JSON logs go back to replacing sys.excepthook outright, as the merge base does. * test(mcp): check every MCP stream failure site logs one JSON record * test(mcp): stub the failing model call instead of opening a loopback socket --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| test_aresponses_api_with_mcp.py | ||
| test_chat_completions_handler.py | ||
| test_litellm_proxy_mcp_handler.py | ||
| test_mcp_streaming_iterator.py | ||
| test_parked_stream_dispatch.py | ||
| test_round_billing.py | ||
| test_tool_precheck.py | ||