U 췀g@sddlZddlmZddlmZddlmZddlmZm Z ddl m Z ddl m Z e rxddlmZmZdd l mZmZz,ddlZdd lmZmZdd lmZmZWnek red YnXGd ddejjZdS)N)OP) DidNotEnable) SPAN_ORIGIN) TransactionTRANSACTION_SOURCE_CUSTOM)event_from_exception) TYPE_CHECKING) AwaitableCallable)AnyOptional)HandlerCallDetailsRpcMethodHandler) AbortErrorServicerContextzgrpcio is not installedcs.eZdZdfdd ZddZddZZS) ServerInterceptorNcs|p|j|_tdSN) _find_name_find_method_namesuper__init__)selfZ find_name __class__U/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/grpc/aio/server.pyrs zServerInterceptor.__init__cs|_||IdHdkr dSjsBjsBtj}fdd}n^jsbjrbtj}fdd}n>jrjstj}fdd}njrjrtj}fdd}||jj dS)Nc s|}|s||IdHStjt|tj|ttd}t j |dz ||IdHWW5QRSt k rYnHt k r}z*t|dddd\}}t j||dW5d}~XYnXW5QRXdS)N)opnamesourceorigin) transactiongrpcF)typeZhandled)Z mechanism)hint)rrZcontinue_from_headersdictZinvocation_metadatarZ GRPC_SERVERrr sentry_sdkZstart_transactionZ unary_unaryr ExceptionrZ capture_event)requestcontextrr exceventr#handlerrrrwrapped(s,    z4ServerInterceptor.intercept_service..wrappedcs&||2z3dHW}|Vq 6dSr)Z unary_streamr'r(rr,rrr-Gscs||}|IdHSr)Z stream_unary)r'r(responser0rrr-Os cs&||2z3dHW}|Vq 6dSr)Z stream_streamr.r0rrr-Ws)request_deserializerresponse_serializer) _handler_call_detailsZrequest_streamingZresponse_streamingr!Zunary_unary_rpc_method_handlerZunary_stream_rpc_method_handlerZstream_unary_rpc_method_handlerZ stream_stream_rpc_method_handlerr2r3)rZ continuationZhandler_call_detailsZhandler_factoryr-rr+rintercept_services*     z#ServerInterceptor.intercept_servicecCs|jjSr)r4method)rr(rrrrbszServerInterceptor._find_name)N)__name__ __module__ __qualname__rr5r __classcell__rrrrrsDr)r%Zsentry_sdk.constsrZsentry_sdk.integrationsrZ#sentry_sdk.integrations.grpc.constsrZsentry_sdk.tracingrrZsentry_sdk.utilsrtypingrcollections.abcr r r r r!r rZgrpc.aiorr ImportErrorZaiorrrrrs