Uh oh!
There was an error while loading. Please reload this page.
fix(otel): do not set AS_ROOT on child spans with parent_span_id - #1823
Open
misinierijon4-debug wants to merge 1 commit into
Open
Conversation
CLAassistant
commented
Aug 18, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When creating spans using
start_as_current_observation()orstart_observation()within an existing trace or with atrace_contextcontaining aparent_span_id, the client stampedLangfuseOtelSpanAttributes.AS_ROOT: Trueon the child span. This caused the Langfuse ingestion processor on the server to treat every child span as the root of the trace, overwriting the parent trace's name (and trace-level IO) with the child span's name during trace updates.Root cause
_create_span_with_parent_context,start_observation, andcreate_eventsetLangfuseOtelSpanAttributes.AS_ROOT = Truewheneverremote_parent_span is not None, without checking whetherparent_span_idwas provided or whether the span was a non-root child span in an existing trace.Solution
start_observation,create_event,start_as_current_observation, and_create_span_with_parent_contextto only setLangfuseOtelSpanAttributes.AS_ROOT = Truewhenparent_span_id is None(i.e. only on true trace root spans).tests/unit/test_otel.pyso child spans with customparent_span_idare not marked asAS_ROOT.Proof
Test Run
Reference
Fixeslangfuse/langfuse#16272
Greptile Summary
The PR corrects Langfuse root-span metadata so observations with an explicit parent span are not marked as trace roots.
AS_ROOTon the absence ofparent_span_idacross observation and event creation paths.Confidence Score: 4/5
The PR appears safe to merge after removing the non-blocking duplicate method definition.
The root-marker changes consistently distinguish explicitly parented observations, while the only accepted concern is an identical method definition that silently shadows its predecessor.
Files Needing Attention: langfuse/_client/client.py
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(otel): do not set AS_ROOT on child s..." | Re-trigger Greptile
Context used: