-
Notifications
You must be signed in to change notification settings - Fork 585
Closed
Description
Problem
The sync ServerInterceptor._find_name in sentry_sdk/integrations/grpc/server.py is broken with grpcio >= 1.76.
Root Cause
grpcio 1.76 introduced registered method handlers (add_registered_method_handlers) which resolve RPC methods at the C-core level by tag. For these registered methods:
context._rpc_event.call_details.method→ empty (the Cython-compiledcygrpc._ServicerContextdoesn't populate this field)handler_call_details.method→ always populated (set by grpcio's_find_method_handler)
The current sync implementation reads from the empty field:
@staticmethod
def _find_name(context: "ServicerContext") -> str:
return context._rpc_event.call_details.method.decode()Impact
When _find_name returns an empty string, no Sentry transaction is created, meaning:
- No traces
- No spans
- No trace ID in logs
The exception from accessing the empty method is caught by upstream interceptors, so requests still succeed — but tracing is silently broken.
The Fix Already Exists in Async Version
The async version (sentry_sdk/integrations/grpc/aio/server.py) already uses the correct approach:
async def intercept_service(self, continuation, handler_call_details):
self._handler_call_details = handler_call_details # Stores it
# ...
def _find_name(self, context: "ServicerContext") -> str:
return self._handler_call_details.method # Reads from stored detailsSuggested Fix
Align the sync version with the async implementation:
- Store
handler_call_detailsinintercept_service - Change
_find_namefrom@staticmethodto instance method - Read from
self._handler_call_details.method
Environment
- sentry-sdk version: 2.52.0 (and earlier)
- grpcio version: >= 1.76.0
- Python version: 3.12
Related
- The async
ServerInterceptoralready works correctly - This is not the same as issue gRPC (AIO) missing None check for when RPC method not implemented #3108 (which is about missing None checks for unimplemented methods)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Projects
Status
Waiting for: Product Owner