Repository navigation
feat(logger): dispatch Python logging through the Rust diagnostics processor - #42616
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
…absent Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ilter Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
…ey pattern The blanket REDACTED for a changed msg/color template discarded lines whose rendered form was already redacted by the same pipeline, e.g. 'password=%s' became 'REDACTED' instead of 'password=REDACTED'. Only fall back to REDACTED when the rendered form did not change either, which is where interpolation can mangle the key pattern the scrub would otherwise see. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
| if !importable { | ||
| eprintln!("SKIP: litellm package dependencies are not importable in this interpreter"); | ||
| return; |
There was a problem hiding this comment.
When dotenv is unavailable, this test returns successfully. The Rust CI job does not install the Python package dependencies, so its only end-to-end logger bridge test passes without checking event delivery, correlation, level mapping, or handler failures. Please install the dependencies for this test or make their absence fail visibly
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
The end-to-end bridge test skipped silently when litellm's Python deps were absent. uv sync --no-install-project installs them without a maturin build, and PYTHONPATH makes them visible to the embedded interpreter Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 89cc062. Configure here.
TLDR
Problem this solves:
How it solves it:
litellm-loggercrate owning credential redaction and diagnostic processingNativeDiagnosticProcessorthrough the pyo3 bridgelitellm/_logging.pydispatches through it underLITELLM_RUST, Python fallback otherwiseUser Flow
Before: an operator cannot route verbose log redaction through the native diagnostics processor
LITELLM_RUST=true, start the proxy, and emit a log line containing a credentialAfter: the same operator sees the record processed by the Rust diagnostics processor
LITELLM_RUST=true, start the proxy, and emit a log line containing a credentialREDACTEDfromNativeDiagnosticProcessor, falling back to Python on any failureRelevant issues
Affected release
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
cargo test -p litellm-loggerandpytest tests/test_litellm/rust_bridge/ tests/test_litellm/test_logging.py tests/test_litellm/test_secret_redaction.pyScreenshots / Proof of Fix
Before (dd32715)
uv run python -c "from litellm.rust_bridge.diagnostics import PROCESSOR"ModuleNotFoundError: No module named 'litellm.rust_bridge.diagnostics'After (319f686)
api_key=sk-live-abcdefghijklmnop12345LITELLM_RUSTthe catalog decidesDecision.PYTHON; withLITELLM_RUST=trueit decidesDecision.RUST_WITH_FALLBACKREDACTED, andnative.redact_text("key=sk-...")returnskey=REDACTEDType
New Feature
Caveats (if any)
Low
LITELLM_RUSTunset keepsDecision.PYTHONRUST_WITH_FALLBACK, so a bridge failure silently reverts to PythonValidation
cargo test -p litellm-loggerpassed, including parity cases generated against the Python redactor.pytest tests/test_litellm/rust_bridge/ tests/test_litellm/test_logging.py tests/test_litellm/test_secret_redaction.pypassed 1941 tests with one teardown error intest_level_routing_handler_falls_back_to_stderr_when_stdout_is_unusablethat reproduces identically on the merge base.cargo check -p litellm-loggeris clean.Cargo.lockwas regenerated after a rebase conflict againstlitellm-model-catalogFinal Attestation
Note
Medium Risk
Touches credential redaction and all main log filters; behavior is gated and falls back to Python, but parity bugs could leak secrets or change log shape (e.g. sets in extras sorted to lists).
Overview
Introduces a shared
litellm-tracingRust crate and wires it into Python so log redaction, truncation, and nativetracingevents can use one diagnostics pipeline whenLITELLM_RUSTis enabled (catalogLoggerContext, Python fallback on failure).Rust: Secret redaction moves out of
core-utilsintolitellm-tracing(SecretRedactor,Processorfor batch message/exception/stack/extra scrubbing, base64 collapse, access-arg scrubbing). ALogger+Sinklayer forwardslitellm_*events without a global subscriber. The python-bridge addsNativeDiagnosticProcessor, aPythonSinktolitellm.rust_bridge.logger, andlogger::run_*/LoggedMachineso cache, routes, HTTP warnings, and secrets crates emit through that sink instead of ad hoc Pythonwarncalls.Python:
DiagnosticProcessingFilterreplaces the old split between stdout truncation and inline secret scrubbing via_process_record, delegating to the native processor throughrust_bridge.diagnostics.run.secret_redactionand access-log filters use the same path.rust_bridge/logger.pyreceives native emits with correlation IDs and existing filters.CI: The Rust test job installs the repo Python env (
uv sync) so bridge logger integration tests can importlitellm.Reviewed by Cursor Bugbot for commit 89cc062. Bugbot is set up for automated code reviews on this repo. Configure here.