U \G@sddlmZddlZddlmZmZddlmZddlm Z m Z ddl m Z ddl mZddlmZGd d d eZd d Zd dZdddZddZddZdS))absolute_importN)SoftTimeLimitExceededRetry)Hub)capture_internal_exceptionsevent_from_exception)reraise) Integration) ignore_loggerc@seZdZdZeddZdS)CeleryIntegrationcelerycs<ddlmm}|jfdd}||_ttddS)Nrcs4t||j|_t||j|_t|||f||SN)_wrap_task_call__call__run _wrap_tracer)nametaskargskwargsZold_build_tracerO/opt/alt/python38/lib/python3.8/site-packages/sentry_sdk/integrations/celery.pysentry_build_tracersz9CeleryIntegration.setup_once..sentry_build_tracerzcelery.worker.job)Zcelery.app.traceZapptraceZ build_tracer_patch_worker_exitr )rrrrr setup_onces  zCeleryIntegration.setup_onceN)__name__ __module__ __qualname__ identifier staticmethodrrrrrr sr csfdd}|S)Nc sltj}|tdkr||S|<}d|_||tf||||W5QRSQRXdS)Nr ) rcurrentget_integrationr Z push_scope_nameZclear_breadcrumbsZadd_event_processor_make_event_processor)rrhubZscopefrrr_inner/s  z_wrap_tracer.._innerrrr(r)rr'rr(s rcsfdd}|S)Nc sRz ||WStk rLt}tt|W5QRXt|YnXdSr ) Exceptionsysexc_infor_capture_exceptionr)rrr-r'rrr)As z_wrap_task_call.._innerrr*rr'rr>s rcsfdd}|S)Nc stj|d<W5QRXt$|di}jd|d<W5QRXd|krt.t|ddtrddtd g|d <W5QRX|S) NZ transactionextra)Z task_namerrz celery-jobr-rr rrZ fingerprint)rr setdefault issubclassrgetattr)eventhintr/rrrrrevent_processorNs   z._make_event_processor..event_processorr)ruuidrrrequestr6rr5rr%Msr%cCsvtj}|tdkrdSt|dtr*dSt|drHt|d|jrHdSt||j j dddd\}}|j ||ddS)Nthrowsr F)typeZhandled)Zclient_optionsZ mechanism)r4) rr"r#r isinstancerhasattrr:rZclientoptionsZ capture_event)rr-r&r3r4rrrr.hs r.cs(ddlm}|jfdd}||_dS)Nr)WorkercsDz||WSt"tj}|tdk r4|W5QRXXdSr )rrr"r#r flush)rrr&Z old_worklooprrsentry_workloops z+_patch_worker_exit..sentry_workloop)Z billiard.poolr?Zworkloop)r?rBrrArr{s  r)N) __future__rr,Zcelery.exceptionsrrZsentry_sdk.hubrZsentry_sdk.utilsrrZsentry_sdk._compatrZsentry_sdk.integrationsr Zsentry_sdk.integrations.loggingr r rrr%r.rrrrrs