Skip to content

fix(tracing): Skip child span creation in streaming path when no current span (AI/LLM)#6812

Closed
sentrivana wants to merge 1 commit into
masterfrom
ivana/streaming-child-spans-ai-llm
Closed

fix(tracing): Skip child span creation in streaming path when no current span (AI/LLM)#6812
sentrivana wants to merge 1 commit into
masterfrom
ivana/streaming-child-spans-ai-llm

Conversation

@sentrivana

Copy link
Copy Markdown
Contributor

Summary

  • When span streaming is enabled and there is no current span, AI/LLM integrations should not create new root segments for child-span operations
  • Adds a sentry_sdk.traces.get_current_span() is None guard before creating spans in the streaming path
  • Affected integrations: anthropic, cohere, openai, google_genai, huggingface_hub, langchain, langgraph, litellm

Test plan

  • Existing tests pass
  • Verify that in streaming mode, no orphan root segments are created for AI/LLM calls when there's no active span

🤖 Generated with Claude Code

…ent span (AI/LLM)

When span streaming is enabled and there is no current span,
AI/LLM integrations should not create new root segments for
child-span operations. This adds a guard check using
`sentry_sdk.traces.get_current_span()` before creating spans
in the streaming path.

Affected integrations: anthropic, cohere, openai, google_genai,
huggingface_hub, langchain, langgraph, litellm.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sentrivana sentrivana closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant