Skip to content

feat: Support span first in Graphene#5708

Draft
sentrivana wants to merge 1 commit intomasterfrom
ivana/make-graphene-support-span-first
Draft

feat: Support span first in Graphene#5708
sentrivana wants to merge 1 commit intomasterfrom
ivana/make-graphene-support-span-first

Conversation

@sentrivana
Copy link
Contributor

Description

Issues

Reminders

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 8.15s

All tests are passing successfully.

❌ Patch coverage is 14.29%. Project has 14372 uncovered lines.

Files with missing lines (1)
File Patch % Lines
graphene.py 14.29% ⚠️ 72 Missing

Generated by Codecov Action

Comment on lines 168 to +174
try:
yield
finally:
_graphql_span.__exit__(None, None, None)
if isinstance(_graphql_span, StreamedSpan):
_graphql_span.end()
else:
_graphql_span.__exit__(None, None, None)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StreamedSpan exceptions not marked as errors due to bypassing exit

When has_span_streaming_enabled is True, the span is created but never entered as a context manager (no __enter__ call), and ended directly via .end() instead of __exit__. This skips the exception handling logic in StreamedSpan.__exit__ that sets status = SpanStatus.ERROR when an exception occurs. If a GraphQL operation throws an exception, the streaming span will be marked as 'ok' instead of 'error', losing important error information.

Verification

Read traces.py:310-323 confirming exit handles exception status via should_be_treated_as_error, while end() (lines 325-332) just calls _end() without exception handling. Read asgi.py:254,290 showing that ASGI uses streaming spans correctly via with span_ctx as span: context manager pattern.

Identified by Warden code-review · G3U-L27

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