#31873 feat(logging): add opt-in session_id/trace_id correlation to JSON log records via contextvars
## Problem
LiteLLM's `JsonFormatter` in `_logging.py` emits structured JSON log records with no request-scoped identifiers. In production with concurrent async requests all writing to the same global logger singletons, log lines are interleaved with no way to group them per request. Operators cannot reconstruct a request's lifecycle from logs alone.
## Proposed fix
Introduce `session_id_var` and `trace_id_var` as `contextvars.ContextVar[str]` in `_logging.py`. Call `set_trace_id` and `set_session_id` in `Logging.__init__()` so the values are set once per request. `JsonFormatter.format()` reads both vars and injects them into the JSON record when non-empty — zero overhead on requests without a session ID, no changes to individual log call sites.
## Files
- `litellm/_logging.py` - `litellm/litellm_core_utils/litellm_logging.py`