litellm/litellm/router_rust
yujonglee 46b5e0e4f2
refactor(rust): log from the core crates with tracing instead of host calls (#54788)
* refactor(rust): log from the core crates with tracing instead of host calls

router-core asked its host to write two model info log lines through an
awaited lookup, and the model capacity engine asked its host for every
warning and error line plus a fixed "unlicensed priority" line. A log line
is not something only the host can answer, so both crates now emit these
lines with tracing and the three host surfaces are gone from the traits,
from the native and Python hosts and from the Python answering code.

The Python proxy still gets the same lines at the same level on the same
logger. The bridge already delivers tracing events to Python logging, so
its target table now sends the capacity crate to "LiteLLM Proxy" and
router-core's model info module to "LiteLLM Router", and a model info
query runs under the calling request's logger so a level change is seen
at once.

A line logged on a runtime task is queued and handed to Python from the
blocking pool, so it can land after the call that logged it returns. The
bridge gains native_log_lines_delivered(), an awaitable that resolves once
the queued lines are delivered, and the capacity tests await it before
reading each step's lines.

* refactor(rust): name the log delivery wait rust_log_lines_delivered

The Rust workspace says "Rust", not "Native", for something written in Rust.

* fix(proxy): deliver queued Rust log lines before the proxy shuts down

A log line a Rust runtime task queued could be lost when the proxy stopped
before the queue was drained. Shutdown now waits for the queue, after the
steps that can still log.

The queue also reported its dropped-line count only when a later batch
arrived, so a drop during the last batch was never reported. It is now
reported once the queue is empty, and a delivery wait ends only after that
report.

* fix(proxy): bound the shutdown wait for queued Rust log lines

The wait had no timeout, so a log handler that stalled would hold worker
shutdown until an outside kill. It now gives up after five seconds or when
the graceful shutdown window runs out, whichever comes first. A timeout is
not logged, because a stalled handler holds its lock and the warning would
block on it too.
2026-11-27 14:53:04 +09:00
..
invoke fix(responses): bill a client-cancelled native Responses stream with the usage the provider reports (#54752) 2026-11-27 01:41:06 +00:00
steps fix(router): with pre-call checks on, retry a context window error on a group deployment serving another model (#54157) 2026-11-25 10:57:40 +00:00
surface refactor(rust): log from the core crates with tracing instead of host calls (#54788) 2026-11-27 14:53:04 +09:00
__init__.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
core.py fix(ocr): report an unreachable document URL as a 400, not a provider 500 (#54215) 2026-11-26 07:56:58 +00:00
routing_stores.py refactor(router): count the whole router_usage family on the native store (#50862) 2026-11-13 03:22:28 +00:00