mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-28 00:00:38 +00:00
* fix(langfuse_otel): calls sharing a metadata trace_id share one Langfuse trace The trace id a caller names in metadata or litellm_metadata was only written as a span attribute, so every call still started its own OTel trace and Langfuse showed one trace per generation. A call with no traceparent, parent span or active span now starts under the trace the caller named Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * refactor(langfuse_otel): read the caller's trace id through langfuse_trace_id and type the span context override Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(langfuse_otel): resolve the caller's trace id without importing the Langfuse SDK Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(langfuse_otel): calls sharing a metadata trace_id share one trace with LITELLM_OTEL_V2 on The V2 server span starts from the request headers before any route reads the body, so a trace id the caller names in metadata or litellm_metadata never reached it. The outermost V2 middleware now reads that id from the JSON body (or a langfuse_trace_id header) and the tracer provider starts the request's server span in that trace. A traceparent header still wins Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(langfuse_otel): cap the V2 trace id lookahead and survive unparseable bodies The V2 middleware that reads a caller's trace id sits outside the request size limit, admission control and auth, so it now holds at most 16 MiB of a body and hands anything larger to the app unread, in a trace of its own. A body too deeply nested to parse no longer raises out of the middleware, a request naming no trace costs one substring scan, and the JSON content type is matched in any case Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(langfuse_otel): count V2 lookahead bytes once per message and read compressed bodies Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(langfuse_otel): bound the V2 compressed-body lookahead and read mislabelled plain bodies Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(langfuse_otel): hold the V2 lookahead body as one buffer, not a message per piece Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(langfuse_otel): bound the V2 trace lookahead with one per-worker budget Every lookahead on a worker now shares a 64 MiB budget for the bytes it holds before admission control, read bodies and decoded ones alike. A request that finds the budget spent is passed on unread and gets its own trace, and a compressed body whose decode does not fit names no trace instead of queueing behind another request's decode * fix(langfuse_otel): stop the V2 trace lookahead at the proxy's size limit and read trace ids like the langfuse callback The V2 lookahead now reads at most the proxy's max_request_size_mb (or the route's limit), so an unauthenticated upload over the limit is answered 413 instead of being held. It names the trace from the langfuse_trace_id header, then x-litellm-trace-id, then the body's trace_id, and no longer reads existing_trace_id, which asks to join a trace without becoming its root. * fix(langfuse_otel): keep request timing, spend session and roots intact for named traces V2 now names a trace from the langfuse_trace_id header or the request's own metadata trace_id, and no longer reads x-litellm-trace-id. The server span and litellm_received_at start when the request arrives, so reading the body for the trace id no longer hides upload time. The spend-log session skips the named id, existing_trace_id and skipped reads warn once, and only a valid traceparent wins. V1 exports named calls as trace roots, also when the otel callback runs beside langfuse_otel. SDK calls on V2 group by metadata trace_id, and named trace ids drop the W3C random flag. * fix(langfuse_otel): keep admission queue time out of latency and the caller's id as the spend session On V2 the received time is now stamped in auth less the time spent reading the body ahead, so the upload still counts and the admission queue wait does not. A named call's spend session is the trace id its caller sent, from the header or the body. Skip warnings use fixed reasons, so request headers no longer grow the warn-once cache * fix(otel): rename only Langfuse traces for a named V2 call, bound the body read in time, read forms * fix(otel): let unparseable forms reach their route, and keep named-trace attributes off other exporters A form body that spells trace_id but does not parse (a bad boundary, deep or oversized metadata) made the V2 body read raise, so the request got a plain 500 before auth. The read now skips naming for it and the route answers as on main. Exporters other than Langfuse no longer get litellm.otel.named_trace_id or litellm.otel.trace_id_skipped, so their spans stay as on main. Langfuse still gets the skip reason. * test(otel): time the body read on a fake clock, and check key-level exports by their requests The request timing test now moves a frozen clock instead of sleeping, so its durations are exact and the test no longer depends on how fast the machine runs. The key-level Langfuse exporter tests now export a span and check the request that reaches the key's host, instead of checking which span processor classes wrap the exporter. --------- Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_db_endpoint.py | ||
| test_langfuse_logger.py | ||
| test_otel_v2_baggage.py | ||
| test_otel_v2_components.py | ||
| test_otel_v2_config_baggage_parenting_guardrails.py | ||
| test_otel_v2_destinations.py | ||
| test_otel_v2_dynamic.py | ||
| test_otel_v2_emitter.py | ||
| test_otel_v2_logger.py | ||
| test_otel_v2_metrics.py | ||
| test_otel_v2_mount.py | ||
| test_otel_v2_multibackend.py | ||
| test_otel_v2_named_trace.py | ||
| test_otel_v2_presets.py | ||
| test_otel_v2_sources_of_truth.py | ||
| test_otel_v2_vendor_mappers.py | ||
| test_runtime.py | ||