fix(grpc): Read method from handler_call_details for grpcio >= 1.76 compat#5521
Merged
sentrivana merged 1 commit intogetsentry:masterfrom Feb 24, 2026
Merged
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛Openai
Other
Documentation 📚
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
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.
…ompat grpcio 1.76 introduced registered method handlers which resolve RPC methods at the C-core level. For these methods, `context._rpc_event.call_details.method` is empty, breaking tracing. This fix captures `handler_call_details.method` in the closure scope to avoid both the grpcio 1.76 issue and race conditions from shared instance state in the ThreadPoolExecutor. Fixes getsentry#5520
482ee29 to
8566650
Compare
sentrivana
approved these changes
Feb 24, 2026
Contributor
sentrivana
left a comment
There was a problem hiding this comment.
Thanks @yeung108, looks good to me.
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.
Summary
Fixes sync
ServerInterceptorto work with grpcio >= 1.76 by reading the method name fromhandler_call_details.methodinstead ofcontext._rpc_event.call_details.method.Problem
grpcio 1.76 introduced registered method handlers (
add_registered_method_handlers) which resolve RPC methods at the C-core level. For these registered methods,context._rpc_event.call_details.methodreturns an empty string, causing Sentry tracing to silently fail (no transactions, no spans, no trace IDs in logs).Solution
Capture
handler_call_details.methoddirectly in the closure scope before defining thebehaviorfunction. This approach:handler_call_details.methodis always populated by grpcio's_find_method_handlerfind_nameparameter still worksWhy Closure Capture Instead of Instance State?
The gRPC sync server uses a
ThreadPoolExecutorwhere multiple threads share the sameServerInterceptorinstance. Storing state asself._handler_call_detailswould create a race condition where one thread could overwrite the value before another thread'sbehaviorclosure reads it.Fixes #5520