U \1@sddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z mZmZddlZddlmZmZGd d d eZd d Zd dZdS)N)reraise)Hub) Integration) ignore_logger)_filter_headers)capture_internal_exceptionsevent_from_exceptionHAS_REAL_CONTEXTVARS) Application HTTPExceptionc@seZdZdZeddZdS)AioHttpIntegrationaiohttpcs0ts tdtdtjfdd}|t_dS)NzRThe aiohttp integration for Sentry requires Python 3.7+ or aiocontextvars packagezaiohttp.servercs*fdd}t|IdHS)Nc stj}|tdkr,fIdHSt}ttj}|}||t |W5QRXzIdH}Wn4t k rYn t k rt t |YnX|W5QRSQRXdS)N)rcurrentZget_integrationr weakrefrefZconfigure_scopeZclear_breadcrumbsZadd_event_processor_make_request_processorr Exceptionr_capture_exception)hub weak_requestZscoperesponse)argskwargs old_handlerequestselfP/opt/alt/python38/lib/python3.8/site-packages/sentry_sdk/integrations/aiohttp.pyinner0s   zGAioHttpIntegration.setup_once..sentry_app_handle..inner)asyncioZget_event_loopZ create_task)rrrrrr)rrrrrsentry_app_handle.sz8AioHttpIntegration.setup_once..sentry_app_handle)r RuntimeErrorrr _handle)r!rr r setup_onces zAioHttpIntegration.setup_onceN)__name__ __module__ __qualname__ identifier staticmethodr$rrrrr sr csfdd}|S)Nc s}|dkr|St^|di}d|j|j|jf|d<|j|d<|j|d<d|ji|d<tt |j |d<W5QRX|S) Nrz %s://%s%surl query_stringmethodZ REMOTE_ADDRenvheaders) r setdefaultschemehostpathr+r,Zremoterdictr.)eventhintrZ request_inforrraiohttp_processorPs    z2_make_request_processor..aiohttp_processorr)rr7rr6rrNs rcCs6t}t||jjdddd\}}|j||d|S)Nr F)typeZhandled)Zclient_optionsZ mechanism)r5)sysexc_inforZclientoptionsZ capture_event)rr:r4r5rrrros r)r9rZsentry_sdk._compatrZsentry_sdk.hubrZsentry_sdk.integrationsrZsentry_sdk.integrations.loggingrZ$sentry_sdk.integrations._wsgi_commonrZsentry_sdk.utilsrrr rZ aiohttp.webr r RequestZAnyDictZTupleCallableZExcInfor rrrrrrs      2!