Skip to content

ref(strawberry): Simplify span creation#5647

Merged
sentrivana merged 3 commits intomasterfrom
ivana/fixup-strawberry-integration
Mar 12, 2026
Merged

ref(strawberry): Simplify span creation#5647
sentrivana merged 3 commits intomasterfrom
ivana/fixup-strawberry-integration

Conversation

@sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Mar 12, 2026

The integration is doing manual scope management when it doesn't have to. Also, it's not setting the span on the scope.

(Another thing that popped out at me while looking at mypy issues in span first.)

@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

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


New Features ✨

Pydantic Ai

  • Support ImageUrl content type in span instrumentation by ericapisani in #5629
  • Add tool description to execute_tool spans by ericapisani in #5596

Other

  • (crons) Add owner field to MonitorConfig by julwhitney13 in #5610
  • (otlp) Add collector_url option to OTLPIntegration by sl0thentr0py in #5603

Bug Fixes 🐛

  • (celery) Propagate user-set headers by sentrivana in #5581
  • (utils) Avoid double serialization of strings in safe_serialize by ericapisani in #5587

Documentation 📚

  • (openai-agents) Remove inapplicable comment by alexander-alderman-webb in #5495
  • Add AGENTS.md by sentrivana in #5579
  • Add set_attribute example to changelog by sentrivana in #5578

Internal Changes 🔧

Openai Agents

  • Do not fail on new tool fields by alexander-alderman-webb in #5625
  • Stop expecting a specific function name by alexander-alderman-webb in #5623
  • Set streaming header when library uses with_streaming_response() by alexander-alderman-webb in #5583
  • Replace mocks with httpx for streamed responses by alexander-alderman-webb in #5580
  • Replace mocks with httpx in non-MCP tool tests by alexander-alderman-webb in #5602
  • Replace mocks with httpx in MCP tool tests by alexander-alderman-webb in #5605
  • Replace mocks with httpx in handoff tests by alexander-alderman-webb in #5604
  • Replace mocks with httpx in API error test by alexander-alderman-webb in #5601
  • Replace mocks with httpx in non-error single-response tests by alexander-alderman-webb in #5600
  • Remove test for unreachable state by alexander-alderman-webb in #5584
  • Expect namespace tool field for new openai versions by alexander-alderman-webb in #5599

Other

  • (httpx) Resolve type checking failures by alexander-alderman-webb in #5626
  • (pyramid) Support alpha suffixes in version parsing by alexander-alderman-webb in #5618
  • (rust) Don't implement separate scope management by sentrivana in #5639
  • (strawberry) Simplify span creation by sentrivana in #5647
  • Add httpx to linting requirements by alexander-alderman-webb in #5644
  • Remove CodeQL action by sentrivana in #5616
  • Normalize dots in package names in populate_tox.py by alexander-alderman-webb in #5574
  • Do not run actions on potel-base by sentrivana in #5614

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2026

Codecov Results 📊

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

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 14066 uncovered lines.

Files with missing lines (1)
File Patch % Lines
strawberry.py 8.63% ⚠️ 180 Missing

Generated by Codecov Action

@sentrivana sentrivana marked this pull request as ready for review March 12, 2026 12:06
@sentrivana sentrivana requested a review from a team as a code owner March 12, 2026 12:06
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

transaction.op = op

self.graphql_span.finish()
self.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.

Missing try/finally around yield leaks scope state

Medium Severity

__enter__() modifies scope.span and stores the old span in _context_manager_state, but the yield between __enter__() and __exit__() is not wrapped in a try/finally. If the Strawberry framework throws an exception into the generator or calls close() on it, the code after yield (including __exit__) is never reached. This leaves scope.span permanently pointing to the now-stale graphql_span, and the previous span is never restored. The old code using finish() didn't have this issue because it never called __enter__() and therefore never modified scope state.

Fix in Cursor Fix in Web

@sentrivana sentrivana merged commit 47238c8 into master Mar 12, 2026
166 checks passed
@sentrivana sentrivana deleted the ivana/fixup-strawberry-integration branch March 12, 2026 12:15
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.

2 participants