o
    h[                     @   s(  d dl Z d dlm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mZmZmZ zd dlZd dlmZ d dlmZmZ d d	lmZ W n eyS   ed
w d dlmZ er~d dlmZ d dlmZ d dlmZ d dlmZ ededef dZG dd deZdd Z G dd deZ!dS )    Nwraps)IntegrationDidNotEnable)_make_request_event_processor)TransactionSource)capture_internal_exceptionsevent_from_exceptionparse_versionreraise)__version__)ChaliceChaliceViewError)EventSourceHandlerzChalice is not installed)TYPE_CHECKING)Any)Dict)TypeVar)CallableF.)boundc                   @   s   e Zd Zdd ZdS )r   c              
   C   s   t  }t  b}t  | }|t||| W d    n1 s$w   Y  zt| ||W W  d    S  t	ya   t
 }t||jdddd\}}t j||d |  t|  Y nw W d    d S 1 smw   Y  d S )NchaliceFtypehandledclient_options	mechanismhint)
sentry_sdk
get_clientisolation_scoper   get_remaining_time_in_millisadd_event_processorr   ChaliceEventSourceHandler__call__	Exceptionsysexc_infor	   optionscapture_eventflushr   )selfeventcontextclientscopeconfigured_timer)   r    r3   a/var/www/html/pro-man-master/venv/lib/python3.10/site-packages/sentry_sdk/integrations/chalice.pyr&   #   s0   


	"zEventSourceHandler.__call__N)__name__
__module____qualname__r&   r3   r3   r3   r4   r   "   s    r   c                    s   t  fdd}|S )Nc                     s  t  }t  o}t $  j }|j jjtj	d |
t j  j| W d    n1 s3w   Y  zdi | W W  d    S  tyv } z#t|trU t }t||jdddd\}}t j||d |   d }~ww 1 szw   Y  d S )N)sourcer   Fr   r   r   r3   )r    r!   r"   r   lambda_contextr#   set_transaction_namefunction_namer   	COMPONENTr$   r   current_requestto_dictr'   
isinstancer   r(   r)   r	   r*   r+   r,   )function_argsr0   r1   r2   excr)   r.   r   appview_functionr3   r4   wrapped_view_function=   sD   



z:_get_view_function_response.<locals>.wrapped_view_functionr   rC   rD   r@   rE   r3   rB   r4   _get_view_function_response;   s   !rG   c                   @   s   e Zd ZdZedd ZdS )ChaliceIntegrationr   c                     sn   t t} | d u rtdt| dk rtj n	ddlm} |j  fdd}| dk r.|t_n||_tt	j
_d S )NzUnparsable Chalice version: {})      r   )RestAPIEventHandlerc                    s   t | ||} | ||S )N)rG   rF   old_get_view_function_responser3   r4   sentry_event_responsew   s   z<ChaliceIntegration.setup_once.<locals>.sentry_event_response)r
   CHALICE_VERSIONr   formatr   rG   chalice.apprK   r   r   rC   )versionrK   rN   r3   rL   r4   
setup_oncee   s   
zChaliceIntegration.setup_onceN)r5   r6   r7   
identifierstaticmethodrS   r3   r3   r3   r4   rH   b   s    rH   )"r(   	functoolsr   r    sentry_sdk.integrationsr   r   "sentry_sdk.integrations.aws_lambdar   sentry_sdk.tracingr   sentry_sdk.utilsr   r	   r
   r   r   r   rO   r   r   rQ   r   r%   ImportErrortypingr   r   r   r   r   r   rG   rH   r3   r3   r3   r4   <module>   s2    '