
    fi                        d dl Z d dlZd dlmZmZ d dlmZmZmZ d dl	m
Z
 d dlmZ d dlmZmZ d dlmZmZmZmZmZmZ 	 d dlZd dlmZ d d	lmZ d d
lmZmZm Z m!Z! n# e"$ r  ed          w xY wd dl#m$Z$ e$r0d dl#m%Z%m&Z&m'Z'm(Z( d dl)m*Z*m+Z+m,Z,m-Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3 d dlm4Z4 eee fZ5 G d de          Z6d Z7d Z8d Z9d Z:d Z;d Z<d Z=d Z>dS )    N)OP
SPANSTATUS)_check_minimum_versionDidNotEnableIntegration)ignore_logger)should_send_default_pii)TransactionTransactionSource)capture_internal_exceptionsensure_integration_enabledevent_from_exceptionSENSITIVE_DATA_SUBSTITUTEparse_versionreraise)VERSION)ArqRedis)JobExecutionFailedRetryRetryJobWorkerzArq is not installed)TYPE_CHECKING)AnyDictOptionalUnion)EventProcessorEventExcInfoHint)CronJob)Job)WorkerCoroutine)Functionc                   2    e Zd ZdZde Zed             ZdS )ArqIntegrationarqzauto.queue.c                  ^   	 t          t          t                    rt          t                    } nt          j        d d         } n# t
          t          f$ r d } Y nw xY wt          t          |            t                       t                       t                       t          d           d S )N   z
arq.worker)
isinstanceARQ_VERSIONstrr   version	TypeError
ValueErrorr   r&   patch_enqueue_jobpatch_run_jobpatch_create_workerr   )r-   s    k/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/sentry_sdk/integrations/arq.py
setup_oncezArqIntegration.setup_once-   s    	+s++ 2'44%-bqb1:& 	 	 	GGG	 	~w777l#####s   AA AAN)__name__
__module____qualname__
identifieroriginstaticmethodr4        r3   r&   r&   )   s?        J':''F$ $ \$ $ $r<   r&   c                  ^    t           j        j        } fd}| |_        |t           _        d S )Nc                 8  K   t          j                                        t                    }| | |g|R i | d {V S t          j        t
          j        |t          j                  5   | |g|R i | d {V cd d d            S # 1 swxY w Y   d S )N)opnamer9   )
sentry_sdk
get_clientget_integrationr&   
start_spanr   QUEUE_SUBMIT_ARQr9   )selffunctionargskwargsintegrationold_enqueue_jobs        r3   _sentry_enqueue_jobz.patch_enqueue_job.<locals>._sentry_enqueue_jobH   s-      +--==nMM(xI$III&IIIIIIIII"".:O
 
 
 	J 	J )xI$III&IIIIIIII	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	Js   /BBB)r   enqueue_job__kwdefaults__)original_kwdefaultsrL   rK   s     @r3   r0   r0   C   sK    *O)8	J 	J 	J 	J 	J *=&.Hr<   c                  B    t           j        fd} | t           _        d S )Nc                   K   t          j                                        t                    }| | ||           d {V S t          j                    5 }d|_        |                                 t          ddt          j	        t          j        t          j                  }t          j        |          5   | ||           d {V cd d d            cd d d            S # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )Nr'   zunknown arq taskok)r@   statusr?   sourcer9   )rA   rB   rC   r&   isolation_scope_nameclear_breadcrumbsr
   r   QUEUE_TASK_ARQr   TASKr9   start_transaction)rF   job_idscorerJ   scopetransactionold_run_jobs         r3   _sentry_run_jobz&patch_run_job.<locals>._sentry_run_job[   s      +--==nMM$T65999999999')) 	>UEK##%%%%'$(-%,  K -k:: > >([vu========> > > > > > >	> 	> 	> 	> 	> 	> 	> 	>> > > > > > > > >	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s7   A"C>9C%C>%C)	)C>,C)	-C>>DD)r   run_job)r`   r_   s    @r3   r1   r1   W   s0    .K> > > > >* %FNNNr<   c                    t          j                    }|j        Y| d         t          v r&|j                            t
          j                   d S |j                            t
          j                   t          | t          j	                    j
        t          j        dd          \  }}t          j        ||           d S )Nr   F)typehandled)client_options	mechanism)hint)rA   get_current_scoper^   ARQ_CONTROL_FLOW_EXCEPTIONS
set_statusr   ABORTEDINTERNAL_ERRORr   rB   optionsr&   r8   capture_event)exc_infor]   eventrg   s       r3   _capture_exceptionrq   s   s    (**E$A;555(();<<<F$$Z%>???&!,..6)4GG  KE4
 U......r<   c                       fd}|S )Nc                    t                      5  t          j                    }|j        d         |j        _        d         | d<   |                     di           }d         |d<   d         dk    |d<   |                     d	i           }d         t                      rnt          t                      rnt          d         d
|d<   d d d            n# 1 swxY w Y   | S )Njob_namer^   tagsr[   arq_task_idjob_try   arq_task_retryextra)taskrH   rI   retryzarq-job)r   rA   rh   r^   r@   
setdefaultr	   r   )rp   rg   r]   ru   rz   rH   ctxrI   s        r3   event_processorz._make_event_processor.<locals>.event_processor   s4    )** 	 	022E ,),Z!&'*:m$##FB//D"%h-D%(^a%7D!"$$Wb11EJ355TDD;T 677VFF=VY	  	 E)	 	 	 	 	 	 	 	 	 	 	 	 	 	 	* s   B>CC!Cr;   )r~   rH   rI   r   s   ``` r3   _make_event_processorr      s0          4 r<   c                       fd}|S )Nc                   K   t          j                                        t                    }| | g|R i | d {V S t          j                                        t          i | dig|R i |           	  | g|R i | d {V }n;# t          $ r. t          j	                    }t          |           t          |  Y nw xY w|S )Nrt   )rA   rB   rC   r&   get_isolation_scopeadd_event_processorr   	Exceptionsysro   rq   r   )r~   rH   rI   rJ   resultro   	coroutiner@   s         r3   _sentry_coroutinez*_wrap_coroutine.<locals>._sentry_coroutine   s+      +--==nMM"38888888888888&((<<!";S";*d";";MdMMMfMM	
 	
 	
	$9S:4:::6::::::::FF 	 	 	|~~Hx(((X	
 s   >B 5C	C	r;   )r@   r   r   s   `` r3   _wrap_coroutiner      s*         & r<   c                      t           j        j        t          t                    fd            } | t           j        _        d S )Nc                  "   | d         }t          |t                    rNd|v r#d |                    dg           D             |d<   d|v r#d |                    dg           D             |d<   t          |d          rd |j        D             |_        t          |d          rd |j        pg D             |_        d|v r#d |                    dg           D             |d<   d|v r#d	 |                    dg           D             |d<    | i |S )
Nr   	functionsc                 ,    g | ]}t          |          S r;   _get_arq_function.0funcs     r3   
<listcomp>zFpatch_create_worker.<locals>._sentry_create_worker.<locals>.<listcomp>   s0     - - - &d++- - -r<   	cron_jobsc                 ,    g | ]}t          |          S r;   _get_arq_cron_jobr   cron_jobs     r3   r   zFpatch_create_worker.<locals>._sentry_create_worker.<locals>.<listcomp>   s0     - - -  &h//- - -r<   c                 ,    g | ]}t          |          S r;   r   r   s     r3   r   zFpatch_create_worker.<locals>._sentry_create_worker.<locals>.<listcomp>   s.     & & &,0!$''& & &r<   c                 ,    g | ]}t          |          S r;   r   r   s     r3   r   zFpatch_create_worker.<locals>._sentry_create_worker.<locals>.<listcomp>   s0     & & & "(++& & &r<   c                 ,    g | ]}t          |          S r;   r   r   s     r3   r   zFpatch_create_worker.<locals>._sentry_create_worker.<locals>.<listcomp>   s.     # # #,0!$''# # #r<   c                 ,    g | ]}t          |          S r;   r   r   s     r3   r   zFpatch_create_worker.<locals>._sentry_create_worker.<locals>.<listcomp>   s.     # # #08!(++# # #r<   )r*   dictgethasattrr   r   )rH   rI   settings_clsold_create_workers      r3   _sentry_create_workerz2patch_create_worker.<locals>._sentry_create_worker   s    AwlD)) 
	l**- - , 0 0b A A- - -[) l**- -$0$4$4["$E$E- - -[)
 <-- 	& &4@4J& & &L" <-- 	& &!-!7!=2& & &L"
 &  # #4:JJ{B4O4O# # #F; &  # #<BJJ{TV<W<W# # #F; ! $1&111r<   )r'   workercreate_workerr   r&   )r   r   s    @r3   r2   r2      sQ    
00ABB#2 #2 #2 #2 CB#2J  5CJr<   c                     t           j                            |           }t          |j        |j                  |_        |S N)r'   r   r   r   r@   r   )r   arq_funcs     r3   r   r      s1    zt$$H(8JKKHOr<   c                 D    t          | j        | j                  | _        | S r   )r   r@   r   )r   s    r3   r   r      s    (8JKKHOr<   )?r   rA   sentry_sdk.constsr   r   sentry_sdk.integrationsr   r   r   sentry_sdk.integrations.loggingr   sentry_sdk.scoper	   sentry_sdk.tracingr
   r   sentry_sdk.utilsr   r   r   r   r   r   
arq.workerr'   arq.versionr   r+   arq.connectionsr   r   r   r   r   ImportErrortypingr   r   r   r   r   sentry_sdk._typesr   r   r   r    arq.cronr!   arq.jobsr"   
arq.typingr#   r$   ri   r&   r0   r1   rq   r   r   r2   r   r   r;   r<   r3   <module>r      s   



     , , , , , , , , U U U U U U U U U U 9 9 9 9 9 9 4 4 4 4 4 4 = = = = = = = =               /222222((((((FFFFFFFFFFFFF / / /
,-
.
../ !           $111111111111FFFFFFFFFFFF      ******######15(C $ $ $ $ $[ $ $ $4/ / /(% % %8/ / /&  >  2*5 *5 *5Z      s    A A.