U 췀g6 @sddlZddlmZddlmZddlmZddlmZerXddlm Z m Z m Z m Z m Z z@ddlZddlmZmZddlmZdd lmZdd lmZWnek red YnXGd d d ejejZdS)N)OP) DidNotEnable) SPAN_ORIGIN) TYPE_CHECKING)AnyCallableIteratorIterableUnion)ClientCallDetailsCall) _UnaryOutcome)UnaryStreamCall)Messagezgrpcio is not installedc@s,eZdZdZddZddZeddZdS) ClientInterceptorFc Csv|j}tjtjd|tdP}|dd|d|||}|||}|d|j |W5QRSQRXdS)Nzunary unary call to %sopnameorigintypez unary unarymethodcode) r sentry_sdk start_spanr GRPC_CLIENTrset_data/_update_client_call_details_metadata_from_scoperrselfZ continuationclient_call_detailsrequestrspanresponser#Q/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/grpc/client.pyintercept_unary_unarys   z'ClientInterceptor.intercept_unary_unaryc Csd|j}tjtjd|td>}|dd|d|||}|||}|W5QRSQRXdS)Nzunary stream call to %srrz unary streamr)rrrrrrrrrr#r#r$intercept_unary_stream/s"  z(ClientInterceptor.intercept_unary_streamcCs^|jrt|jng}tD]\}}|||fq tjj|j |j ||j |j |j d}|S)N)rtimeoutmetadata credentialswait_for_ready compression)r(listrZget_current_scopeZiter_trace_propagation_headersappendgrpcZ _interceptorZ_ClientCallDetailsrr'r)r*r+)rr(keyvaluer#r#r$rGs   zAClientInterceptor._update_client_call_details_metadata_from_scopeN)__name__ __module__ __qualname__Z_is_interceptedr%r& staticmethodrr#r#r#r$rs r)rZsentry_sdk.constsrZsentry_sdk.integrationsrZ#sentry_sdk.integrations.grpc.constsrtypingrrrrr r r.r r Zgrpc._interceptorr Zgrpc.aio._interceptorrZgoogle.protobuf.messager ImportErrorZUnaryUnaryClientInterceptorZUnaryStreamClientInterceptorrr#r#r#r$s$