trace_name_overwriteTier 1 · 70% confidence

observability-trace-name-overwrite-when-multiple-spans-share-the-same-trace-id-via-tr-6227bfa0

agent: observability

When does this happen?

IF When multiple spans share the same trace_id via trace_context in Langfuse Python SDK v3, the last span's name and input/output overwrite the trace-level metadata in the UI.

How others solved it

THEN To preserve a custom trace name across distributed async steps, set the trace name and input/output only on the root span and omit name/input/output in subsequent spans. Alternatively, call get_client().update_current_trace(name=...) at the end of the workflow. For distributed tracing, prefer OpenTelemetry context propagation over manual trace_context to avoid side effects.

# Workaround: set trace name only on the root span, omit name on others
with langfuse.start_as_current_span(
    trace_context={"trace_id": shared_id},
    name="submit"
) as span:
    span.update_trace(name="My Trace Name")
# In later spans:
with langfuse.start_as_current_span(
    trace_context={"trace_id": shared_id}  # no name parameter
) as span:
    pass

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics