
    lh                        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	 d dl
mZ d dlmZ erd dlmZmZ d d	lmZmZ 	 d dlZd d
lmZmZ d dlmZmZ  G d dej4                  j6                        Zy# e$ r	  ed      w xY w)    N)OP)DidNotEnable)SPAN_ORIGIN)TransactionTransactionSource)event_from_exception)TYPE_CHECKING)	AwaitableCallable)AnyOptional)HandlerCallDetailsRpcMethodHandler)
AbortErrorServicerContextzgrpcio is not installedc                   ,     e Zd Zd fd	Zd Zd Z xZS )ServerInterceptorc                 L    |xs | j                   | _        t        |           y N)
_find_name_find_method_namesuper__init__)self	find_name	__class__s     y/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/sentry_sdk/integrations/grpc/aio/server.pyr   zServerInterceptor.__init__   s    !*!=doo    c                    K   | _          ||       d {   y j                  s#j                  st        j                  } fd}nj                  s"j                  rt        j
                  }fd}n[j                  r"j                  st        j                  }fd}n-j                  r!j                  rt        j                  }fd} j                  j                        S 7 ޭw)Nc                   K   j                  |      }|s | |       d {   S t        j                  t        |j	                               t
        j                  |t        j                  t              }t        j                  |      5  	 j                  | |       d {   cd d d        S 7 7 # t        $ r  t        $ r0}t        |ddd      \  }}t        j                   ||        d }~ww xY w# 1 sw Y   y xY ww)N)opnamesourceorigin)transactiongrpcF)typehandled)	mechanism)hint)r   r   continue_from_headersdictinvocation_metadatar   GRPC_SERVERr   CUSTOMr   
sentry_sdkstart_transactionunary_unaryr   	Exceptionr   capture_event)	requestcontextr"   r%   exceventr*   handlerr   s	          r   wrappedz4ServerInterceptor.intercept_service.<locals>.wrapped(   s     --g6!('!::: *??4467~~,33&  11kJ 
%,%8%8'%JJ  ;  K% $ &:/5%&H't #00TB sX    D	B4A+D	C=B8&B6'B8*D	6B88C:
+C55C::C==DD	c                V   K   j                  | |      2 3 d {   }| 7 
6 y wr   )unary_streamr5   r6   rr9   s      r   r:   z4ServerInterceptor.intercept_service.<locals>.wrappedG   s1     &33GWE  !GE   )'%')')c                 H   K   j                  | |      }| d {   S 7 wr   )stream_unary)r5   r6   responser9   s      r   r:   z4ServerInterceptor.intercept_service.<locals>.wrappedO   s#     "//A%~%~s   " "c                V   K   j                  | |      2 3 d {   }| 7 
6 y wr   )stream_streamr=   s      r   r:   z4ServerInterceptor.intercept_service.<locals>.wrappedW   s1     &44WgF  !GFr?   )request_deserializerresponse_serializer)
_handler_call_detailsrequest_streamingresponse_streamingr&   unary_unary_rpc_method_handlerunary_stream_rpc_method_handlerstream_unary_rpc_method_handler stream_stream_rpc_method_handlerrE   rF   )r   continuationhandler_call_detailshandler_factoryr:   r9   s   `    @r   intercept_servicez#ServerInterceptor.intercept_service   s     %9"$%9::?((1K1K"AAO8 **w/I/I"BBO
 &&w/I/I"BBO&
 &&7+E+E"CCO
 !(!=!= ' ; ;
 	
w ;s   C8C6CC8c                 .    | j                   j                  S r   )rG   method)r   r6   s     r   r   zServerInterceptor._find_nameb   s    ))000r   r   )__name__
__module____qualname__r   rQ   r   __classcell__)r   s   @r   r   r      s    B
H1r   r   )r0   sentry_sdk.constsr   sentry_sdk.integrationsr   #sentry_sdk.integrations.grpc.constsr   sentry_sdk.tracingr   r   sentry_sdk.utilsr   typingr	   collections.abcr
   r   r   r   r&   r   r   grpc.aior   r   ImportErroraior    r   r   <module>rc      sf       0 ; = 1  3$294
M122 M1	  2
0
112s   A2 2B 