File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
sentry_sdk/integrations/grpc Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 66from grpc .aio import Server as AsyncServer
77
88from sentry_sdk .integrations import Integration
9+ from sentry_sdk .utils import parse_version
910
1011from .client import ClientInterceptor
1112from .server import ServerInterceptor
@@ -128,6 +129,17 @@ def patched_aio_server( # type: ignore
128129 ) -> Server :
129130 server_interceptor = AsyncServerInterceptor ()
130131 interceptors = [server_interceptor , * (interceptors or [])]
132+
133+ try :
134+ # We prefer interceptors as a list because of compatibility with
135+ # opentelemetry https://github.com/getsentry/sentry-python/issues/4389
136+ # However, prior to grpc 1.42.0, only tuples were accepted, so we
137+ # have no choice there.
138+ if parse_version (grpc .__version__ ) < (1 , 42 , 0 ):
139+ interceptors = tuple (interceptors )
140+ except Exception :
141+ pass
142+
131143 return func (* args , interceptors = interceptors , ** kwargs ) # type: ignore
132144
133145 return patched_aio_server # type: ignore
You can’t perform that action at this time.
0 commit comments