U 췀g=@s8ddlZddlZddlmZddlmZddlmZmZddl m Z ddl m Z ddl mZmZmZmZmZz@ddlmZdd lmZdd lmZdd lmZdd lmZWnek red YnXddlm Z e rddlm!Z!m"Z"ddl#m$Z$m%Z%ddl m&Z&ddlm'Z'GdddeZ(ddZ)ddZ*dS)N)OP)continue_trace) DidNotEnable Integration) ignore_logger)TRANSACTION_SOURCE_TASK)capture_internal_exceptionsensure_integration_enabledevent_from_exceptionformat_timestamp parse_version)Queue)JobTimeoutException)VERSION)Worker) JobStatuszRQ not installed) TYPE_CHECKING)AnyCallable)EventEventProcessor)ExcInfo)Jobc@s&eZdZdZdeZeddZdS) RqIntegrationrqz auto.queue.cstt}|dkrtdt|dkr.tdtjttfdd}|t_tjfdd}|t_t j ttfdd }|t _ t d dS) NzUnparsable RQ version: {})rzRQ 0.6 or newer is required.c st}||tt|t|j dp6it j dt t jd}t|j|_W5QRXtj|d|id||f||}W5QRXW5QRX|jrt|S)N_sentry_trace_headerszunknown RQ task)opnamesourceoriginrq_job)Zcustom_sampling_context) sentry_sdkZ new_scopeZclear_breadcrumbsZadd_event_processor_make_event_processorweakrefrefrmetagetrZ QUEUE_TASK_RQrrr r func_namerZstart_transactionZis_horse get_clientflush)selfjobargskwargsscopeZ transactionrv)old_perform_jobH/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/rq.pysentry_patched_perform_job7s( & z.sentry_patched_perform_jobcsNt|do|jo|jdk}|jtjkp*|j}|r<|s.sentry_patched_handle_exceptioncs2t}|jdk r$t||jd<||f|S)Nr)r"Zget_current_scopespandictZiter_trace_propagation_headersr&)r+r,r.r/)old_enqueue_jobr2r3sentry_patched_enqueue_jobls   z.sentry_patched_enqueue_jobz rq.worker) r RQ_VERSIONrformatrZ perform_jobr rZhandle_exceptionr Z enqueue_jobr)versionr4r;r?r2)r>r:r1r3 setup_once)s"  zRqIntegration.setup_onceN)__name__ __module__ __qualname__ identifierr staticmethodrCr2r2r2r3r%s rcsfdd}|S)Nc s}|dk rvt\|di}|j|j|j|j|jd}|jrPt|j|d<|j rdt|j |d<||d<W5QRXd|krt(t |ddt rdd |jg|d <W5QRX|S) Nextra)Zjob_idfuncr-r. description enqueued_at started_atzrq-jobr8rrr fingerprint) r setdefaultidr(r-r.rKrLr rM issubclassr)eventhintr,rIr!weak_jobr2r3event_processor~s( z._make_event_processor..event_processorr2)rUrVr2rTr3r#|s r#cKs4t}t||jdddd\}}tj||ddS)NrF)typeZhandled)Zclient_optionsZ mechanism)rS)r"r)r optionsZ capture_event)r8r.clientrRrSr2r2r3r7s r7)+r$r"Zsentry_sdk.constsrZsentry_sdk.apirZsentry_sdk.integrationsrrZsentry_sdk.integrations.loggingrZsentry_sdk.tracingrZsentry_sdk.utilsrr r r r Zrq.queuer Z rq.timeoutsrZ rq.versionrr@Z rq.workerrZrq.jobr ImportErrortypingrrrZsentry_sdk._typesrrrrrr#r7r2r2r2r3s0           W!