o
    Zh                     @   s   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yS   edw G dd dejejZdS )    )Hub)MYPY)OP)DidNotEnable)AnyCallableIteratorIterableUnionN)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   t j}|j}|jtjd| d*}|dd |d| | ||}|||}|d| j	 |W  d    S 1 s=w   Y  d S )Nzunary unary call to %sopdescriptiontypezunary unarymethodcode)
r   currentr   
start_spanr   GRPC_CLIENTset_data-_update_client_call_details_metadata_from_hubr   nameselfZcontinuationclient_call_detailsrequesthubr   spanresponse r$   Z/var/www/html/lang_env/lib/python3.10/site-packages/sentry_sdk/integrations/grpc/client.pyintercept_unary_unary   s   

$z'ClientInterceptor.intercept_unary_unaryc                 C   sv   t j}|j}|jtjd| d!}|dd |d| | ||}|||}|W  d    S 1 s4w   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_stream,   s    
$z(ClientInterceptor.intercept_unary_streamc                 C   sZ   | j rt| j ng }| D ]\}}|||f qtjj| j| j|| j	| j
| jd} | S )N)r   timeoutmetadatacredentialswait_for_readycompression)r)   listZiter_trace_propagation_headersappendgrpcZ_interceptorZ_ClientCallDetailsr   r(   r*   r+   r,   )r   r!   r)   keyvaluer$   r$   r%   r   C   s   	z?ClientInterceptor._update_client_call_details_metadata_from_hubN)__name__
__module____qualname__Z_is_interceptedr&   r'   staticmethodr   r$   r$   r$   r%   r      s    r   )Z
sentry_sdkr   Zsentry_sdk._typesr   Zsentry_sdk.constsr   Zsentry_sdk.integrationsr   typingr   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$    
