
    fi                        d dl Z d dlZ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mZmZmZmZ 	 d dlZn# e$ r  e	d          w xY wd dlmZ erd dlmZ d d	lmZmZ d d
lmZ d Zd Zd Z G d de
          ZdS )    N)OP
SPANSTATUS)_check_minimum_versionDidNotEnableIntegration)TransactionSource)event_from_exceptionloggerpackage_versionqualname_from_functionreraisezRay not installed.)TYPE_CHECKING)Callable)AnyOptional)ExcInfoc                  |    t          j                                                    rd S t          j        d           d S )Nz[[Tracing] Sentry not initialized in ray cluster worker, performance data will be discarded.)
sentry_sdk
get_client	is_activer
   debug     k/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/sentry_sdk/integrations/ray.py_check_sentry_initializedr      sE    ((** 
Le    r   c                  x    t           j        t          j                  dfd	            } | t           _        d S )Nc                 x     t          j                   r  gR i S  fd}  |           S |S )Nc                     t          j                   d d fd
            }t          j        |          }t	          |j                                                  }|                    t          j        dt          j        j	        d                      |
                    |          |_        r 
|          }n  
i 	|          }|j         fd}||_        |S )N)_sentry_tracingc                    t                       t          j        | pi t          j        t                    t          j        t          j	                  }t          j
        |          5 }	  |i |}|                    t          j                   nZ# t          $ rM |                    t          j                   t!          j                    }t%          |           t'          |  Y nw xY w|cd d d            S # 1 swxY w Y   d S )N)opnameoriginsource)r   r   continue_tracer   QUEUE_TASK_RAYr   RayIntegrationr#   r   TASKstart_transaction
set_statusr   OK	ExceptionINTERNAL_ERRORsysexc_info_capture_exceptionr   )r   f_argsf_kwargstransactionresultr/   user_fs         r   new_funczH_patch_ray_remote.<locals>.new_remote.<locals>.wrapper.<locals>.new_func9   sT    *+++(7#)r(/77)0,1    1+>> 
"++!'!<8!<!<#..z}====$ + + +#..z/HIII#&<>>*8444****	+ "
" 
" 
" 
" 
" 
" 
" 
" 
" 
" 
" 
" 
" 
" 
" 
" 
" 
"s7   *C<,'BC<AC+(C<*C++C<<D D r   )kinddefault)
parametersc                     t          j        t          j        t	                    t
          j                  5 }d t          j                                                    D             }	  | i |d|i}|	                    t          j                   nZ# t          $ rM |	                    t          j                   t          j                    }t!          |           t#          |  Y nw xY w|cddd           S # 1 swxY w Y   dS )z,
                Ray Client
                )r!   r"   r#   c                     i | ]\  }}||	S r   r   ).0kvs      r   
<dictcomp>zz_patch_ray_remote.<locals>.new_remote.<locals>.wrapper.<locals>._remote_method_with_header_propagation.<locals>.<dictcomp>o   s.        Aq 1  r   r   N)r   
start_spanr   QUEUE_SUBMIT_RAYr   r'   r#   get_current_scopeiter_trace_propagation_headersr*   r   r+   r,   r-   r.   r/   r0   r   )argskwargsspantracingr4   r/   old_remote_methodr5   s         r   &_remote_method_with_header_propagationzf_patch_ray_remote.<locals>.new_remote.<locals>.wrapper.<locals>._remote_method_with_header_propagatione   sw   
  **/77)0   "  $.$@$B$B$a$a$c$c  G	+!2!2!"%+" "=D" " " 
6666$ + + +
(ABBB#&<>>*8444****	+ ")" " " " " " " " " " " " " " " " " "s6   0C?++BC?AC.+C?-C..C??DD)	functoolswrapsinspect	signaturelistr9   valuesappend	ParameterKEYWORD_ONLYreplace__signature__remote)r5   r6   rM   paramsrvrI   rH   rD   frE   
old_remotes   `     @r   wrapperz6_patch_ray_remote.<locals>.new_remote.<locals>.wrapper7   s.   _V$$26 " " " " " " %$"4  )(33I).557788FMM!% *7      &/%6%6&%6%I%IH" ;Z))0ZZ000:: "	" " " " " "6 ?BIIr   )rL   isclass)rX   rD   rE   rZ   rY   s   ``` r   
new_remotez%_patch_ray_remote.<locals>.new_remote,   s     ?1 	2
 :a1$111&111K	 K	 K	 K	 K	 K	 K	 K	Z =71::Nr   )N)rayrU   rJ   rK   )r\   rY   s    @r   _patch_ray_remoter^   (   sQ    J_Z  Z Z Z Z Z ! Zx CJJJr   c                     t          j                    }t          | |j        dt          j        d          \  }}t          j        ||           d S )NF)handledtype)client_options	mechanism)hint)r   r   r	   optionsr'   
identifiercapture_event)r/   rE   clienteventrd   s        r   r0   r0      sa    "$$F&~"-
 
  KE4 U......r   c                   2    e Zd ZdZde Zed             ZdS )r'   r]   zauto.queue.c                  j    t          d          } t          t          |            t                       d S )Nr]   )r   r   r'   r^   )versions    r   
setup_oncezRayIntegration.setup_once   s3     "%((~w777r   N)__name__
__module____qualname__rf   r#   staticmethodrm   r   r   r   r'   r'      s?        J':''F  \  r   r'   ) rL   rJ   r.   r   sentry_sdk.constsr   r   sentry_sdk.integrationsr   r   r   sentry_sdk.tracingr   sentry_sdk.utilsr	   r
   r   r   r   r]   ImportErrortypingr   collections.abcr   r   r   r   r   r^   r0   r'   r   r   r   <module>ry      s        



     , , , , , , , , U U U U U U U U U U 0 0 0 0 0 0             -JJJJ - - -
,+
,
,,- !           )(((((($$$$$$$$((((((  a a aH/ / /
 
 
 
 
[ 
 
 
 
 
s	   = A