Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

docs(otel): tighten inject_trace_context docstring

yucheng8899583d06ea
diff --git a/litellm/integrations/otel/plumbing/context.py b/litellm/integrations/otel/plumbing/context.py
index 3dabd34c81c..57e220815b5 100644
--- a/litellm/integrations/otel/plumbing/context.py
+++ b/litellm/integrations/otel/plumbing/context.py
@@ -325,13 +325,11 @@ def _outgoing_trace_context(parent_span: object) -> Context | None:
def inject_trace_context(headers: Mapping[str, str], parent_span: object = None) -> dict[str, str]:
- """``headers`` plus W3C ``traceparent``/``tracestate`` for the current request's span.
+ """``headers`` plus W3C ``traceparent``/``tracestate`` for this request's span.
- Parent preference: the request span auth stashed on the key (the legacy
- ``litellm_request`` SERVER span, or the FastAPI server span under otel_v2), then
- the anchored request root span, then the ambient active span. Only trace context
- is injected, never Baggage, so per-request identity baggage cannot leak upstream.
- Unchanged when no valid span context exists anywhere.
+ Parent preference: ``parent_span`` (the request span auth stashed on the key), then
+ the anchored request root span, then the ambient active span. Only trace context is
+ injected, never Baggage. Unchanged when no valid span exists anywhere.
"""
context: Final = _outgoing_trace_context(parent_span)
if context is None: