o
    h                     @   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selfcontinuationclient_call_detailsrequesthubr   spanresponse r%   f/var/www/html/aiguide_backend/venv/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*   listiter_trace_propagation_headersappendgrpc_interceptor_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___is_interceptedr'   r(   staticmethodr   r%   r%   r%   r&   r      s    r   )
sentry_sdkr   sentry_sdk._typesr   sentry_sdk.constsr   sentry_sdk.integrationsr   typingr   r   r   r	   r
   r1   r   r   grpc._interceptorr   grpc.aio._interceptorr   google.protobuf.messager   ImportErrorUnaryUnaryClientInterceptorUnaryStreamClientInterceptorr   r%   r%   r%   r&   <module>   s$    
