U 췀gg@s0ddlZddlmZddlZddlmZmZddlmZddl m Z ddl m Z m Z mZmZz4ddlZddlmZddlmZmZdd lmZWnek red YnXdd lmZerdd lmZdd lmZddlmZddlmZededefdZGdddeZddZ GdddeZ!dS)Nwraps) Integration DidNotEnable)_make_request_event_processor)TRANSACTION_SOURCE_COMPONENT)capture_internal_exceptionsevent_from_exception parse_versionreraise) __version__)ChaliceChaliceViewError)EventSourceHandlerzChalice is not installed) TYPE_CHECKING)Any)Dict)TypeVar)CallableF.)boundc@seZdZddZdS)rc Cst}t}t |}|t|||W5QRXzt|||WW5QRSt k rt }t ||j dddd\}}tj||d|t|YnXW5QRXdS)NchaliceFtypeZhandledZclient_optionsZ mechanismhint) sentry_sdk get_clientisolation_scoperget_remaining_time_in_millisadd_event_processorrChaliceEventSourceHandler__call__ Exceptionsysexc_infor options capture_eventflushr )selfeventcontextclientscopeconfigured_timer&rr0M/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/chalice.pyr##s&   zEventSourceHandler.__call__N)__name__ __module__ __qualname__r#r0r0r0r1r"srcstfdd}|S)Nc st}t}t<j}|jjjtd| t j j|W5QRXzf|WW5QRSt k r}zJt|trt}t||jdddd\}}tj||d|W5d}~XYnXW5QRXdS)N)sourcerFrrr)rrrrZlambda_contextr Zset_transaction_nameZ function_namerr!rZcurrent_requestto_dictr$ isinstancerr%r&r r'r(r)) function_argsr-r.r/excr&r+rapp view_functionr0r1wrapped_view_function=s:    z:_get_view_function_response..wrapped_view_functionrr;r<r8r=r0r:r1_get_view_function_response;s!r?c@seZdZdZeddZdS)ChaliceIntegrationrcsntt}|dkrtdt|dkr.tjnddlm}|jfdd}|dkr\|t_n||_tt j _dS)NzUnparsable Chalice version: {})r)RestAPIEventHandlercst|||}|||S)N)r?r>Zold_get_view_function_responser0r1sentry_event_responsewsz.sentry_event_response) r CHALICE_VERSIONrformatr r? chalice.apprCrrr;)versionrCrEr0rDr1 setup_oncees  zChaliceIntegration.setup_onceN)r2r3r4 identifier staticmethodrJr0r0r0r1r@bsr@)"r% functoolsrrZsentry_sdk.integrationsrrZ"sentry_sdk.integrations.aws_lambdarZsentry_sdk.tracingrZsentry_sdk.utilsrr r r rr rFr rrHrr" ImportErrortypingrrrrrrr?r@r0r0r0r1s.         '