U \ @sxddlmZddlZddlmZddlmZddlmZm Z ddl m Z ddl m Z Gdd d eZd d Zd d ZdS))absolute_importN)Hub) Integration)capture_internal_exceptionsevent_from_exception)JobTimeoutException)Workerc@seZdZdZeddZdS) RqIntegrationrqcs4tjfdd}|t_tjfdd}|t_dS)Nc stj}|t}|dkr*||f||S|4}||tt |||f||}W5QRX|j r||j |SN) rcurrentget_integrationr Z push_scopeZclear_breadcrumbsZadd_event_processor_make_event_processorweakrefrefZis_horseclientflush)selfjobargskwargshubZ integrationZscoperv)old_perform_job/rq.pysentry_patched_perform_job s   z.sentry_patched_perform_jobcst|||f||Sr )_capture_exception)rrexc_infor)old_handle_exceptionrrsentry_patched_handle_exception9szARqIntegration.setup_once..sentry_patched_handle_exception)rZ perform_jobZhandle_exception)rr r)rrr setup_onces   zRqIntegration.setup_onceN)__name__ __module__ __qualname__Z identifier staticmethodr!rrrrr sr csfdd}|S)Nc s}|dk rft|j|d<W5QRXt0|di}|j|j|j|j|jd|d<W5QRXd|krt(t|ddtrdd|jg|d <W5QRX|S) NZ transactionextra)Zjob_idfuncrr descriptionzrq-jobrrr rZ fingerprint) rZ func_name setdefaultidrrr( issubclassr)eventhintrr&weak_jobrrevent_processorBs" z._make_event_processor..event_processorr)r/r0rr.rr@s rcKsFtj}|tdkrdSt||jjdddd\}}|j||ddS)Nr F)typeZhandled)Zclient_optionsZ mechanism)r-)rr r r rrZoptionsZ capture_event)rrrr,r-rrrr]s r)Z __future__rrZsentry_sdk.hubrZsentry_sdk.integrationsrZsentry_sdk.utilsrrZ rq.timeoutsrZ rq.workerrZAnyZDictCallableZJobZQueueZExcInfor rrrrrrs     )