
    \j                         d dl mZmZmZmZ d dlZd dlmZ d dlm	Z	 d dl
mZ 	 d dlmZmZmZmZmZmZ d dlmZ  G d	 d
      Z G d dee      Z G d dee      Zy# e$ r	  e	d      w xY w)    )CallableUnionAsyncIterableAnyN)OP)DidNotEnable)SPAN_ORIGIN)UnaryUnaryClientInterceptorUnaryStreamClientInterceptorClientCallDetailsUnaryUnaryCallUnaryStreamCallMetadata)Messagezgrpcio is not installedc                   &    e Zd Ze	 	 	 	 dd       Zy)ClientInterceptorc                 r   | j                   | j                  t                     } nIt        | j                   t              s/| j                  t        j                  | j                               } t        j                         j                         D ]!  \  }}| j                   j                  ||       # | S )N)metadata)	r   _replacer   
isinstance
from_tuple
sentry_sdkget_current_scopeiter_trace_propagation_headersadd)client_call_detailskeyvalues      Q/root/env/lib/python3.12/site-packages/sentry_sdk/integrations/grpc/aio/client.py/_update_client_call_details_metadata_from_scopezAClientInterceptor._update_client_call_details_metadata_from_scope   s     ''/"5">">
">"S/88(C #6">">!,,-@-I-IJ #? # ))+JJL	9 
((,,S%8		9
 #"    N)r   r   returnr   )__name__
__module____qualname__staticmethodr     r!   r   r   r      s$    #0#	# #r!   r   c                   $    e Zd Z	 	 	 	 	 	 	 	 ddZy)!SentryUnaryUnaryClientInterceptorc                   K   |j                   }t        j                  t        j                  d|j                         z  t              5 }|j                  dd       |j                  d|       | j                  |      } |||       d {   }|j                          d {   }|j                  d|j                         |cd d d        S 7 C7 -# 1 sw Y   y xY ww)Nzunary unary call to %sopnameorigintypezunary unarymethodcode)r0   r   
start_spanr   GRPC_CLIENTdecoder	   set_datar    r1   r-   )selfcontinuationr   requestr0   spanresponsestatus_codes           r   intercept_unary_unaryz7SentryUnaryUnaryClientInterceptor.intercept_unary_unary,   s      %++""~~)FMMO;
 	 MM&-0MM(F+"&"V"V## **=wGGH (/KMM&+"2"23!	 	 H/	 	sC   AC 
ACCC$C%!C
C CCCC N)r7   z6Callable[[ClientCallDetails, Message], UnaryUnaryCall]r   r   r8   r   r"   zUnion[UnaryUnaryCall, Message])r#   r$   r%   r<   r'   r!   r   r)   r)   +   s-    N 1 	
 
*r!   r)   c                   $    e Zd Z	 	 	 	 	 	 	 	 ddZy)"SentryUnaryStreamClientInterceptorc                 X  K   |j                   }t        j                  t        j                  d|j                         z  t              5 }|j                  dd       |j                  d|       | j                  |      } |||       d {   }|cd d d        S 7 # 1 sw Y   y xY ww)Nzunary stream call to %sr+   r/   zunary streamr0   )	r0   r   r2   r   r3   r4   r	   r5   r    )r6   r7   r   r8   r0   r9   r:   s          r   intercept_unary_streamz9SentryUnaryStreamClientInterceptor.intercept_unary_streamK   s      %++""~~*V]]_<
 	 MM&.1MM(F+"&"V"V## **=wGGH !	 	 H	 	s1   AB*
ABBB
B*BB'#B*N)r7   z7Callable[[ClientCallDetails, Message], UnaryStreamCall]r   r   r8   r   r"   z*Union[AsyncIterable[Any], UnaryStreamCall])r#   r$   r%   r@   r'   r!   r   r>   r>   G   s-    O 1 	
 
6r!   r>   )typingr   r   r   r   r   sentry_sdk.constsr   sentry_sdk.integrationsr   #sentry_sdk.integrations.grpc.constsr	   grpc.aior
   r   r   r   r   r   google.protobuf.messager   ImportErrorr   r)   r>   r'   r!   r   <module>rH      ss    6 6    0 ;2  0
# #*(9;V 8 k  2
0
112s   A A+