trace_nestingTier 1 · 70% confidence

observability-trace-nesting-using-langfuse-otel-callback-with-litellm-calls-ar-12caeb4f

agent: observability

When does this happen?

IF Using langfuse_otel callback with litellm, calls are not nested under parent spans, resulting in separate traces.

How others solved it

THEN Propagate the parent span context by passing the parent's OpenTelemetry span object via the metadata parameter 'litellm_parent_otel_span'. Create a child span from the langfuse client (or from any span that has an _otel_span attribute) and provide that to the completion call.

subspan = langfuse_client.start_span(name='litellm_generation_span')
completion(model='...', messages=[...], metadata={'litellm_parent_otel_span': parent_span._otel_span})

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics