fix: propagate OTel context through fan-out branches and emit per-branch spans - #11
Merged
lostbean merged 1 commit intoJun 16, 2026
Conversation
…nch spans Three issues caused broken traces for workflows using MapNode/FanOutBranch: 1. Task.async_stream in execute_fan_out_branches (dsl.ex) and MapNode.run spawned child tasks without propagating the current OTel context. Child spans were disconnected from the parent trace. Fixed by capturing the context before spawning and re-attaching via OtelCtx.with_parent_context in each task — the same pattern already used by SpawnAgent. 2. execute_fan_out_branch ran the child node without creating a span, so individual branch executions were invisible to tracing. Now wraps each branch in a TOOL span with the child node name. 3. maybe_complete_fan_out in the workflow strategy transitioned to the next node without finishing the current node span. This left the fan-out node's span open, causing subsequent nodes to incorrectly nest under it instead of being siblings. Added finish_node_span before the transition. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks done
Owner
|
Thanks @Munksgaard! LGTM, merging it |
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 free
to 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.
Three issues caused broken traces for workflows using MapNode/FanOutBranch:
Task.async_stream in execute_fan_out_branches (dsl.ex) and MapNode.run spawned child tasks without propagating the current OTel context. Child spans were disconnected from the parent trace. Fixed by capturing the context before spawning and re-attaching via OtelCtx.with_parent_context in each task — the same pattern already used by SpawnAgent.
execute_fan_out_branch ran the child node without creating a span, so individual branch executions were invisible to tracing. Now wraps each branch in a TOOL span with the child node name.
maybe_complete_fan_out in the workflow strategy transitioned to the next node without finishing the current node span. This left the fan-out node's span open, causing subsequent nodes to incorrectly nest under it instead of being siblings. Added finish_node_span before the transition.