0i%"ddlZddlmZmZmZddlmZddlmZddl m Z ddl m Z m Z mZmZddlmZerddlmZdd lmZdd lmZdd lmZmZ ddlZdd lmZ ddlZej:Zej>Z dZ!dZ%e!re 5ddl&m'Z%dddGddeZ(GddZ)dZ*GddeZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2y#e$r ed wxYw#e$r!ddl"ZejFZejHZ dZ!YwxYw#1swY{xYw)N)_check_minimum_version Integration DidNotEnable)RequestExtractor)SentryWsgiMiddleware)SOURCE_FOR_STYLE)capture_internal_exceptionsensure_integration_enabledevent_from_exception parse_version) TYPE_CHECKING)Any)Dict)Optional)EventEventProcessor) __version__zFalcon not installedTF)_UNSETc0eZdZdZdZdZdZdZdZy)FalconRequestExtractorc.|jjSN)requestenvselfs M/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/falcon.pyrzFalconRequestExtractor.env5s||c.|jjSr)rcookiesrs rr zFalconRequestExtractor.cookies9s||###rcyrrs rformzFalconRequestExtractor.form=rcyrr"rs rfileszFalconRequestExtractor.filesAr$rc0|j}|dkDryy)Nrz[REQUEST_CONTAINING_RAW_DATA])content_length)rr(s rraw_datazFalconRequestExtractor.raw_dataEs ,,. A 2rcd}t5|jj}ddd|tur|Sy#1swYxYwr)r r_media _FALCON_UNSET)r cached_medias rjsonzFalconRequestExtractor.jsonRsA ( * <<..L+ } , + *s 7AN) __name__ __module__ __qualname__rr r#r&r)r.r"rrrr4s  $ rrceZdZdZdZy)SentryFalconMiddlewarez9Captures exceptions in Falcon requests and send to Sentryctjjt}|ytj}d|_|j t||y)Nfalcon) sentry_sdk get_clientget_integrationFalconIntegrationget_isolation_scope_nameadd_event_processor_make_request_event_processor)rreqrespargskwargs integrationscopes rprocess_requestz&SentryFalconMiddleware.process_requesthsP ++-==>OP   ..0  !!"?["QRrN)r/r0r1__doc__rDr"rrr3r3es CSrr3 uri_templatepathc6eZdZdZdeZdZddZedZy)r9r5z auto.http.cN|tvrtd|dtd||_y)Nz%Invalid value for transaction_style: z (must be in ))TRANSACTION_STYLE_VALUES ValueErrortransaction_style)rrOs r__init__zFalconIntegration.__init__|s. $< <$&>@ "3rc~tt}tt|t t t yr)r FALCON_VERSIONrr9_patch_wsgi_app_patch_handle_exception_patch_prepare_middleware)versions r setup_oncezFalconIntegration.setup_onces+ /0':!!#rN)rG) r/r0r1 identifieroriginrOrP staticmethodrWr"rrr9r9vs2J* &F3$$rr9cFtjfd}|t_y)Nctjjt}| ||St fdtj }|||S)Nc||Srr")envi start_resporiginal_wsgi_apprs rzB_patch_wsgi_app..sentry_patched_wsgi_app..s%6tT:%Nr) span_origin)r6r7r8r9rrY)rrstart_responserBsentry_wrappedr`s` rsentry_patched_wsgi_appz0_patch_wsgi_app..sentry_patched_wsgi_appsW ++-==>OP  $T3? ?- N)00  c>22r)falcon_app_class__call__)rer`s @rrSrSs(11 3!8rcltjttfd}|t_y)NcZdx}}t5td|D}td|D}ddd|g|}|||St||rGt|t j j ddd\}}t j|||S#1swYmxYw)Nc3BK|]}t|ts|ywr) isinstance Exception.0arguments r zS_patch_handle_exception..sentry_patched_handle_exception..sWt8z(I7Vhtsc3VK|]!}t|tjs|#ywr)rkr5Responserms rrpzS_patch_handle_exception..sentry_patched_handle_exception..s!)-XHfoo1Vs))r5F)typehandled)client_options mechanism)hint)r next_exception_leads_to_http_5xxr r6r7options capture_event)rr@exresponse was_handledeventrworiginal_handle_exceptions rsentry_patched_handle_exceptionz@_patch_handle_exception..sentry_patched_handle_exceptions X ( *WtWWB)-H+ 0>#+>KE4  $ $U 6-+ *s %B!!B*)rf_handle_exceptionr r9)rrs @rrTrTs7 0 B B 13LMN<*I&rcJtj dfd }|t_y)Nc|r |||Stjjt}|t g|xsgz}||Sr)r6r7r8r9r3) middlewareindependent_middlewareasgirBoriginal_prepare_middlewares r!sentry_patched_prepare_middlewarezD_patch_prepare_middleware..sentry_patched_prepare_middlewares^ .z;QSWX X ++-==>OP  "023z7GRHJ+:7MNNr)NFF)falcon_helpersprepare_middleware)rrs @rrUrUs&"0"C"C=BO )JN%rct|tjxr|jxsdj d}t|tjtj j f }|xs|xrt xs t|S)NrJ5) rkr5 HTTPErrorstatus startswith http_status HTTPStatusFALCON3_has_http_5xx_status)r|r}is_server_erroris_unhandled_errors rryrys V%5%56BIIO;W;W <O( V  v11<< =  11   5+H5rc8|jjdS)Nr)rr)r}s rrrs ?? % %c **rcb|j|jd}|||d<dt|i|d<y)NrF transactionsourcetransaction_info)rGrHr)rrOrname_for_styles r _set_transaction_name_and_sourcersD ,, N**;s revent_processorz6_make_request_event_processor..event_processorsG( 0M0MsS ( * "3 ' : :5 A+ + s AAr")r>rBrs`` rr=r=s r)3r6sentry_sdk.integrationsrrr$sentry_sdk.integrations._wsgi_commonrsentry_sdk.integrations.wsgirsentry_sdk.tracingrsentry_sdk.utilsr r r r typingr rrrsentry_sdk._typesrrr5rrR ImportErrorfalcon.app_helpers app_helpersrApprfrfalcon.api_helpers api_helpersAPIr,falcon.requestrrr3rMr9rSrTrUryrrr=r"rrrs#UUA=/!7 /4 ''NzzG  $ &: '.-.b S S4$ $68(#ILJ.&+ P O/ - ../''NzzG  ' &s* C CD C#DDD