Repository navigation
refactor(rust_bridge): give the logger module one role and split it by concern - #53690
Conversation
…y concern logger/mod.rs held the bridge from Rust tracing to Python logging together with two redaction classes that Python calls the other way, and its tests sat in a sibling tests.rs that the Rust workspace rules no longer allow. The module now only delivers Rust tracing events to Python logging. The redaction classes move to redaction.rs. Every call into litellm.rust_bridge.host.logger sits in logger/host.rs, one function per Python function. The sink and the per-call level cache each get a file with their tests inline, and each file says what it is for. No behavior changes.
PR overviewNo security issues were found in this pull request. Reviews
|
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@greptileai please review this PR. It is the bottom of a stack, so its diff against main is the whole change. |
[Low impact] The PR appears safe to merge, with no new actionable issues found.
|
|
@greptileai the doc comments stay, per litellm/rust/AGENTS.md, which asks for them in the Rust workspace. Please review again with that rule in mind. |
Handwritten 1-3 sentence description
[insert handwritten description here]
Details
TLDR
Problem this solves:
python-bridge/src/loggerdid not say what it is fortests.rs, which the Rust rules forbidHow it solves it:
loggeronly delivers Rusttracingevents to Pythonloggingpython-bridge/src/redaction.rslogger/host.rsholds every call intolitellm.rust_bridge.host.loggerRelevant issues
Base of the stack for #53539
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
E2E exception at 98e7efd.
Scope. The diff reorganizes
litellm/rust/crates/python-bridge/src/logger/and changes nothing a caller or an operator can observe. No test was added, removed or rewritten.Rationale. Almost all of the diff is code moving between files.
processing.rsbecomesredaction.rsunchanged, and its three importers (lib.rs,spend_log.rs,spend_log_rows.rs) switch to the new path. The Python classes keep their names, so nothing on the Python side changes.tests.rsis split betweensink.rsandlevels.rs, and the only edits inside it aresuper::paths and two strings in the delivery test that name the file and module the test itself lives in.One part is a small rewrite and not a move. The three calls into
litellm.rust_bridge.host.logger(context,enabled,emit) used to sit inside three unrelated functions and now are three functions inhost.rswith the same bodies. Reading the request correlation returns anOptionthere, and a call falls back to the default no-op logger when Python cannot provide one, exactly as before. The items the rest of the crate uses (capture,capture_call,LoggedMachine) keep their paths.Commands and results, from
litellm/rust.native_events_reach_python_with_levels_context_reentry_and_http_deduplicationprints SKIP and passes when the embedded interpreter cannot import the project's packages, so the run above puts them onPYTHONPATHand the test ran for real. It drives all three Python calls through a route machine, a sync call and an async call, and checks levels and request correlation on the Python side, so it covers the rewritten part.Type
🧹 Refactoring
Final Attestation