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-compiled cygrpc._ServicerContext doesn'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 details
Suggested Fix
Align the sync version with the async implementation:
- Store
handler_call_details in intercept_service
- Change
_find_name from @staticmethod to 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
Problem
The sync
ServerInterceptor._find_nameinsentry_sdk/integrations/grpc/server.pyis 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:
Impact
When
_find_namereturns an empty string, no Sentry transaction is created, meaning: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:Suggested Fix
Align the sync version with the async implementation:
handler_call_detailsinintercept_service_find_namefrom@staticmethodto instance methodself._handler_call_details.methodEnvironment
Related
ServerInterceptoralready works correctly