U \f@sddlZddlmZmZddlmZddlmZmZm Z m Z ddl m Z ddl mZddZd d ZGd d d e Zd dZddZdS)N)Hub_should_send_default_pii)reraise)AnnotatedValuecapture_internal_exceptionsevent_from_exceptionlogger) Integration)_filter_headerscsfdd}|S)Nc stj}|t}|dkr*||f||S|}t&||j|_| t ||W5QRXz ||f||WW5QRSt k rt }t||jjdddd\}}|j||dt|YnXW5QRXdS)N aws_lambdaF)typeZhandled)Zclient_optionsZ mechanism)hint)rcurrentget_integrationAwsLambdaIntegrationZ push_scoperZclear_breadcrumbs function_nameZ transactionZadd_event_processor_make_request_event_processor Exceptionsysexc_inforclientoptionsZ capture_eventr) eventcontextargskwargshub integrationZscoperr handlerS/opt/alt/python38/lib/python3.8/site-packages/sentry_sdk/integrations/aws_lambda.pysentry_handlers(    z%_wrap_handler..sentry_handlerr )rr"r rr! _wrap_handlers r#c Cs8t(tj}|t}|dk r*|jW5QRXdSN)rrrrrrflush)rrr r r! _drain_queue+s  r&c@seZdZdZeddZdS)rr csddl}d}t|ds.sentry_handle_event_requestcst|}|f||Sr$r)r*)old_handle_http_requestr r!sentry_handle_http_requestXszCAwsLambdaIntegration.setup_once..sentry_handle_http_requestcst||Sr$r&rr) old_to_jsonr r!sentry_to_jsoncsz7AwsLambdaIntegration.setup_once..sentry_to_jsoncst|}||f||Sr$r))Zlambda_runtime_clientr+rrr,r r!r.kscsfdd}|S)Ncst||Sr$r1r2fr r!inneryszKAwsLambdaIntegration.setup_once.._wrap_post_function..innerr )r6r7r r5r!_wrap_post_functionxs z._wrap_post_function) __main__hasattrZ bootstrap ImportErrorrZwarningr(r'Zto_jsonZLambdaRuntimeClientZpost_invocation_resultZpost_invocation_error)Zlambda_bootstrapZpre_37r.r0r4r8r )r-r/r3r! setup_once8sB      zAwsLambdaIntegration.setup_onceN)__name__ __module__ __qualname__ identifier staticmethodr<r r r r!r5srcsfdd}|S)Ncs |di}jjjjd|d<|di}dkrLd|d<t|d<dkrnd|d <d krtd |d <d drt d d ddddggi|d<t r|di}did}|dk r||d<did}|dk r||d<|S)Nextra)Zremaining_time_in_millisrfunction_versioninvoked_function_arnaws_request_idlambdarequestZ httpMethodmethodurlZqueryStringParametersZ query_stringheadersbodyremz!rawxrdatauserZidentityZuserArnidZsourceIpZ ip_address) setdefaultZget_remaining_time_in_millisrrCrDrE_get_urlr getrr)rr rBrGZ user_inforQZip aws_context aws_eventr r!event_processors4        z6_make_request_event_processor..event_processorr )rWrVrXr rUr!rs)rcCsV|dd}|di}|dd}|dd}|rJ|rJ|rJd|||Sd|jS)NpathrJZHostzX-Forwarded-Protoz {}://{}{}zawslambda:///{})rTformatr)rrrYrJhostprotor r r!rSs     rS)rZsentry_sdk.hubrrZsentry_sdk._compatrZsentry_sdk.utilsrrrrZsentry_sdk.integrationsr Z$sentry_sdk.integrations._wsgi_commonr r#r&rrrSr r r r!s    R-