o
    0 i-                     @   s   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ er,d dlm	Z	m
Z
mZmZmZ z d dlZd dlmZmZ d dlmZ d d	lmZ d d
lmZ W n eyW   edw G dd dejejZdS )    N)OP)DidNotEnable)SPAN_ORIGIN)TYPE_CHECKING)AnyCallableIteratorIterableUnion)ClientCallDetailsCall)_UnaryOutcome)UnaryStreamCall)Messagezgrpcio is not installedc                   @   s,   e Zd ZdZdd Zdd Zedd ZdS )	ClientInterceptorFc                 C   s   |j }tjtjd| td)}|dd |d| | |}|||}|d| j	 |W  d    S 1 s:w   Y  d S )Nzunary unary call to %sopnameorigintypezunary unarymethodcode)
r   
sentry_sdk
start_spanr   GRPC_CLIENTr   set_data/_update_client_call_details_metadata_from_scoper   r   selfZcontinuationclient_call_detailsrequestr   spanresponse r#   o/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/sentry_sdk/integrations/grpc/client.pyintercept_unary_unary   s    
$z'ClientInterceptor.intercept_unary_unaryc                 C   sp   |j }tjtjd| td }|dd |d| | |}|||}|W  d    S 1 s1w   Y  d S )Nzunary stream call to %sr   r   zunary streamr   )r   r   r   r   r   r   r   r   r   r#   r#   r$   intercept_unary_stream0   s   
$z(ClientInterceptor.intercept_unary_streamc                 C   s^   | j rt| j ng }t  D ]\}}|||f qtjj| j	| j
|| j| j| jd} | S )N)r   timeoutmetadatacredentialswait_for_readycompression)r(   listr   Zget_current_scopeZiter_trace_propagation_headersappendgrpcZ_interceptorZ_ClientCallDetailsr   r'   r)   r*   r+   )r   r(   keyvaluer#   r#   r$   r   F   s    
	zAClientInterceptor._update_client_call_details_metadata_from_scopeN)__name__
__module____qualname__Z_is_interceptedr%   r&   staticmethodr   r#   r#   r#   r$   r      s    r   )r   Zsentry_sdk.constsr   Zsentry_sdk.integrationsr   Z#sentry_sdk.integrations.grpc.constsr   typingr   r   r   r   r	   r
   r.   r   r   Zgrpc._interceptorr   Zgrpc.aio._interceptorr   Zgoogle.protobuf.messager   ImportErrorZUnaryUnaryClientInterceptorZUnaryStreamClientInterceptorr   r#   r#   r#   r$   <module>   s(    
