
    tni7                     x   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 	 d dlZd dlmZ d dlmZmZ d d	lmZ n# e$ r  ed
          w xY 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                   Z G d de          Z	 	 	 	 	 	 	 	 ddZ  G 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                       e Zd ZddZdS )r   eventr   contextreturnc           	      n   t          j                    }t          j                    5 }t                      5  |                                }|                    t          |||                     d d d            n# 1 swxY w Y   	 t          j        | ||          cd d d            S # t          $ rf t          j                    }t          ||j        ddd          \  }}t          j        ||           |                                 t!          |  Y nw xY w	 d d d            d S # 1 swxY w 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   )selfr   r   clientscopeconfigured_timer/   r%   s           \/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/sentry_sdk/integrations/chalice.pyr,   zEventSourceHandler.__call__#   s   &((')) 	#U,..  ")"F"F"H"H))1%/RR                
#09$wOO	# 	# 	# 	# 	# 	# 	# 	#  	# 	# 	#<>>2#)>'0UCC  t
 (T::::""""	# ##	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#sS   D*9A;/D*;A?	?D*A?	D*B))A-DD*DD**D.1D.N)r   r   r   r   r   r   )__name__
__module____qualname__r,        r7   r   r   "   s(        # # # # # #r<   r   appr   view_functionfunction_argsr   c                 B     t                    d fd            }|S )Nr?   r   r   c            	         t          j                    }t          j                    5 }t                      5  j                                        }|                    j        j        t          j	                   |
                    t          j                                        j        |                     d d d            n# 1 swxY w Y   	  	di | cd d d            S # t          $ rv}t          |t                     r t#          j                    }t'          ||j        ddd          \  }}t          j        ||           |                                  d }~ww xY w# 1 swxY w Y   d S )N)sourcer   Fr   r!   r$   r;   )r&   r'   r(   r	   lambda_contextr)   set_transaction_namefunction_namer   	COMPONENTr*   r   current_requestto_dictr-   
isinstancer   r.   r/   r
   r0   r1   r2   )
r?   r4   r5   r6   excr/   r   r%   r=   r>   s
           r7   wrapped_view_functionz:_get_view_function_response.<locals>.wrapped_view_function=   s   &((')) 	U,..  "%"4"Q"Q"S"S**&4,6 +   
 ))1+3355*'                 $}55}55!	 	 	 	 	 	 	 	"    c#344 <>>2#)>'0UCC  t
 (T::::#	 	 	 	 	 	 	 	 	 	sT   E+BC<E+C	E+C	E+C((
E(2A1E##E((E++E/2E/)r?   r   r   r   r   )r=   r>   r?   rK   s   ``  r7   _get_view_function_responserL   :   sE     =      @ ! r<   c                   *    e Zd ZdZedd            ZdS )ChaliceIntegrationr   r   Nc                  >   t          t                    } | 't          d                    t                              | dk     rt          j        nddlm} |j        	 	 	 	 	 	 	 	 dfd}| dk     r|t          _        n||_        t          t          j
        _        d S )NzUnparsable Chalice version: {})      r   )RestAPIEventHandlerr=   r   r>   r   r?   Dict[str, Any]r   c                 @    t          | ||          } | ||          S )N)rL   )r=   r>   r?   rK   old_get_view_function_responses       r7   sentry_event_responsez<ChaliceIntegration.setup_once.<locals>.sentry_event_responset   s<     %@]M% %! 21*M  r<   )r=   r   r>   r   r?   rS   r   r   )r   CHALICE_VERSIONr   formatr   rL   chalice.apprR   r   r   r=   )versionrR   rV   rU   s      @r7   
setup_oncezChaliceIntegration.setup_onced   s    00??FFWWXXXW-4-P**777777 $? +				'*		;K				 		 		 		 		 		 W2GG//>S;);&&&r<   )r   N)r8   r9   r:   
identifierstaticmethodr[   r;   r<   r7   rN   rN   a   s7        J< < < \< < <r<   rN   )r=   r   r>   r   r?   r   r   r   )"r.   	functoolsr   r&   sentry_sdk.integrationsr   r   "sentry_sdk.integrations.aws_lambdar   sentry_sdk.tracingr   sentry_sdk.utilsr	   r
   r   r   r   r   rW   r   r   rY   r   r+   ImportErrortypingr   r   r   r   r   r   rL   rN   r;   r<   r7   <module>re      s2   



           = = = = = = = = L L L L L L 0 0 0 0 0 0           3NNN66666611111111KKKKKKK 3 3 3
,1
2
223 !           /8CH-...A# # # # #2 # # #0$!	$!"$!38$!$! $! $! $!N#< #< #< #< #< #< #< #< #< #<s   A	 	A