Skip to content

Isolate async gRPC server scope per request#5966

Closed
itsviseph wants to merge 1 commit intogetsentry:masterfrom
itsviseph:fix/grpc-aio-isolation-scope
Closed

Isolate async gRPC server scope per request#5966
itsviseph wants to merge 1 commit intogetsentry:masterfrom
itsviseph:fix/grpc-aio-isolation-scope

Conversation

@itsviseph
Copy link
Copy Markdown

Summary

Fixes #5894 by creating an isolation_scope() for each async gRPC unary-unary request, matching the sync interceptor and other request-oriented async integrations.

Without per-request isolation, scope state can leak between requests in the async gRPC server interceptor. That means request-local extras, tags, breadcrumbs, and similar scope data can bleed into later requests handled by the same process.

Changes

  • wrap the async unary-unary gRPC server handler in sentry_sdk.isolation_scope()
  • add a regression test that makes two back-to-back async gRPC requests and verifies request-specific scope extras do not leak across them

Verification

Ran:

  • python -m pytest tests/integrations/grpc/test_grpc_aio.py -q

This async gRPC test file passed locally.

@itsviseph itsviseph requested a review from a team as a code owner April 9, 2026 12:24
@sdk-maintainer-bot sdk-maintainer-bot bot added issue-already-assigned Used for automated community contribution checks. violating-contribution-guidelines Used for automated community contribution checks. labels Apr 9, 2026
@sdk-maintainer-bot
Copy link
Copy Markdown

This PR has been automatically closed. The referenced issue is already assigned to someone else.

If you believe this assignment is outdated, please comment on the issue to discuss before opening a new PR.

Please review our contributing guidelines for more details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Semver Impact of This PR

None (no version bump detected)

📋 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 ✨

  • (ai) Redact base64 data URLs in image_url content blocks by ericapisani in #5953
  • (integrations) Instrument pyreqwest tracing by servusdei2018 in #5682

Bug Fixes 🐛

Anthropic

  • Capture exceptions for stream() calls by alexander-alderman-webb in #5950
  • Stop setting transaction status when child span fails by alexander-alderman-webb in #5717
  • Only finish relevant spans in .create() patches by alexander-alderman-webb in #5716

Other

  • (wsgi) Respect HTTP_X_FORWARDED_PROTO in request.url construction by sl0thentr0py in #5963

Internal Changes 🔧

  • (anthropic) Separate sync and async .create() patches by alexander-alderman-webb in #5715
  • (openai) Split token counting by API for easier deprecation by ericapisani in #5930
  • (opentelemetry) Ignore mypy error by alexander-alderman-webb in #5927
  • Fix license metadata in setup.py by sl0thentr0py in #5934
  • Update validate-pr workflow by stephanie-anderson in #5931

Other

  • Isolate async gRPC server scope per request by itsviseph in #5966

🤖 This preview updates automatically when you update the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

issue-already-assigned Used for automated community contribution checks. violating-contribution-guidelines Used for automated community contribution checks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gRPC aio ServerInterceptor missing isolation_scope per request

1 participant