a
    xd                     @   s   d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	 d dl
mZmZ d dlmZ erxd dlmZmZmZ d dl mZ zd d	lZW n ey   ed
Y n0 dZG dd deZdd Zdd Zd	S )    )MYPY)Hub_should_send_default_pii)DidNotEnable)StarletteIntegrationStarletteRequestExtractor)SOURCE_FOR_STYLETRANSACTION_SOURCE_ROUTE)transaction_from_function)AnyCallableDict)EventNzFastAPI is not installedzgeneric FastAPI requestc                   @   s   e Zd ZdZedd ZdS )FastApiIntegrationfastapic                   C   s
   t   d S )N)patch_get_request_handler r   r   W/var/www/html/Ranjet/env/lib/python3.9/site-packages/sentry_sdk/integrations/fastapi.py
setup_once   s    zFastApiIntegration.setup_onceN)__name__
__module____qualname__
identifierstaticmethodr   r   r   r   r   r      s   r   c                 C   s   d}|dkr*|j d}|rZt|p&d}n0|dkrZ|j d}|rZt|dd }|d urZ|}|svt| d< dti| d< d S || d< dt| i| d< d S )	N endpointurlroutepathZtransactionsourceZtransaction_info)Zscopegetr
   getattr_DEFAULT_TRANSACTION_NAMEr	   r   )eventtransaction_stylerequestnamer   r   r   r   r   r    _set_transaction_name_and_source"   s"    r'   c                     s    t jj  fdd} | t j_d S )Nc                     s   | i |  fdd}|S )Nc                     s   t j}|t}|d u r,| i |I d H S | R}| d }t|}| I d H   fdd}tj|_|	||| W d    n1 s0    Y  | i |I d H S )Nr   c                    s    fdd}|S )Nc                    sX   |  di } r>d v r*t r* d |d< d v r> d |d< || d< t| j | S )Nr%   cookiesdata)r    r   r'   r$   )r#   hintZrequest_info)infointegrationreqr   r   event_processorQ   s    zpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_app.<locals>._make_request_event_processor.<locals>.event_processorr   )r-   r,   r.   r+   )r,   r-   r   _make_request_event_processorO   s    zzpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_app.<locals>._make_request_event_processor)
r   currentZget_integrationr   Zconfigure_scoper   Zextract_request_infor   _nameZadd_event_processor)argskwargsZhubr,   Zsentry_scoper%   Z	extractorr0   Zold_appr/   r   _sentry_appC   s    

"zSpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_appr   )r3   r4   r6   Zold_get_request_handlerr5   r   _sentry_get_request_handler?   s    )z>patch_get_request_handler.<locals>._sentry_get_request_handler)r   ZroutingZget_request_handler)r8   r   r7   r   r   ;   s    /r   )Zsentry_sdk._typesr   Zsentry_sdk.hubr   r   Zsentry_sdk.integrationsr   Z!sentry_sdk.integrations.starletter   r   Zsentry_sdk.tracingr   r	   Zsentry_sdk.utilsr
   typingr   r   r   r   r   ImportErrorr"   r   r'   r   r   r   r   r   <module>   s    	