Skip to content

fix: establish parent-child span hierarchy in mock runtimes#76

Merged
cristipufu merged 1 commit intomainfrom
fix/otel-span-hierarchy-in-mock-runtimes
Feb 18, 2026
Merged

fix: establish parent-child span hierarchy in mock runtimes#76
cristipufu merged 1 commit intomainfrom
fix/otel-span-hierarchy-in-mock-runtimes

Conversation

@cristipufu
Copy link
Member

Summary

  • Root spans created with start_span() (to avoid async generator context detach errors) were never set as the current context, causing all child spans to be emitted as flat root-level siblings instead of a proper hierarchy
  • Fix by calling trace.set_span_in_context() after creating root/subgraph spans and passing the explicit context parameter to all child span calls
  • Applied across all 5 mock runtimes: telemetry, invoice, pharma, support, movies

Test plan

  • Run the dev console with each mock runtime and verify spans in the telemetry panel show parent-child nesting
  • Verify the telemetry runtime shows 3-level hierarchy: root → researcher/coder → model/tools
  • Confirm no OpenTelemetry context detach errors in async generator flows

🤖 Generated with Claude Code

Root spans were created with `start_span()` (to avoid async generator
context detach errors) but never set as the current context, so all
child spans became root-level siblings. Fix by threading explicit
`context` parameter via `trace.set_span_in_context()` to all child
span calls across all five mock runtimes.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@cristipufu cristipufu merged commit 7bfd81b into main Feb 18, 2026
11 checks passed
@cristipufu cristipufu deleted the fix/otel-span-hierarchy-in-mock-runtimes branch February 18, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments