Open
Conversation
Add span streaming support to the MCP integration. When span streaming is enabled, start spans via sentry_sdk.traces.start_span and set data via set_attribute; otherwise fall back to the existing transaction-based flow and set_data. Introduce _set_span_data_attribute in sentry_sdk.ai.utils to branch on StreamedSpan vs Span so handlers can write attributes uniformly in both modes. Refs PY-2340 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Codecov Results 📊✅ 5 passed | Total: 5 | Pass Rate: 100% | Execution Time: 1.09s All tests are passing successfully. ❌ Patch coverage is 12.50%. Project has 17018 uncovered lines. Files with missing lines (1)
Generated by Codecov Action |
… of as seen when the file is viewed, but for some reason this is being flagged
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_stdio_transport_detection(sentry_init, capture_events, stdio): |
Contributor
There was a problem hiding this comment.
Parts of this diff look too red 😅
What happened to tests such as test_stdio_transport_detection()?
Member
Author
There was a problem hiding this comment.
This was folded into test_tool_handler_stdio. There were a few assertions that were unique to this test that now appear there (taken from the red below):
assert span["data"][SPANDATA.MCP_TRANSPORT] == "stdio"
assert span["data"][SPANDATA.NETWORK_TRANSPORT] == "pipe"
# No session ID for stdio transport
assert SPANDATA.MCP_SESSION_ID not in span["data"]
You can see them in the other test here
The non-streaming branches of test_prompt_handler_with_error and test_resource_handler_with_error only verified error-event fields, leaving span status and transaction shape unchecked. Mirror the streaming-branch assertions and the tool-handler test pattern so regressions in classic-mode error handling for prompts and resources are caught. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Add span streaming support to the MCP integration.
Refs PY-2340
Fixes #6038