
    gh                        S SK r S SKrS SKrS SKJrJr  S SKJrJrJ	r	  S SK
Jr  S SKJrJrJrJrJr   S SKrS SKrS SKJr  \(       a  S SKJr  S S	KJrJr  S S
KJr  S rS rS r " S S\	5      rg! \ a	    \" S5      ef = f)    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                      [         R                  " 5       R                  5       (       a  g [        R                  " S5        g )Nz[[Tracing] Sentry not initialized in ray cluster worker, performance data will be discarded.)
sentry_sdk
get_client	is_activer
   debug     ^/home/kali/devsecops-assessor/venv/lib/python3.13/site-packages/sentry_sdk/integrations/ray.py_check_sentry_initializedr      s,    ((**
LLer   c                  ~   ^ [         R                  m[        R                  " T5      SU4S jj5       n U [         l        g )Nc                    >^ ^^ [         R                  " T 5      (       a  T" T /TQ70 TD6$ UU UU4S jnT b  U" T 5      $ U$ )Nc                    >^ ^ S S.U 4S jjnT(       a	  T" U5      nOT" T0 TD6" U5      nUR                   mUU 4S jnX2l         U$ )N)_tracingc                 $  > [        5         [        R                  " U =(       d    0 [        R                  [        T5      [        R                  [        R                  S9n[        R                  " U5       n T" U0 UD6nUR                  [        R                  5        WsS S S 5        $ ! [         aJ    UR                  [        R                  5        [         R"                  " 5       n[%        U5        ['        U6    N^f = f! , (       d  f       g = f)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_funcH_patch_ray_remote.<locals>.new_remote.<locals>.wrapper.<locals>.new_func9   s    )+(77N((/7)00,11  11+>++!'!<8!<#..z}}= " ?> % +#..z/H/HI#&<<>*84*	+	 ?>s1   6D8'B*D*AC>;D=C>>D
Dc                  4  > [         R                  " [        R                  [	        T	5      [
        R                  S9 n[         R                  " 5       R                  5        VVs0 s H  u  p4X4_M	     nnn T" U 0 UDSU0D6nUR                  [        R                  5        WsSSS5        $ s  snnf ! [         aJ    UR                  [        R                  5        [        R                  " 5       n[!        U5        [#        U6    Ndf = f! , (       d  f       g= f)z
Ray Client
)r!   r"   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kvtracingr4   r/   old_remote_methodr5   s
           r   &_remote_method_with_header_propagationf_patch_ray_remote.<locals>.new_remote.<locals>.wrapper.<locals>._remote_method_with_header_propagationW   s    
  ****/7)00  %/$@$@$B$a$a$c$cDA $c  +!2D!UF!UW!U
6 "% 
 % +
(A(AB#&<<>*84*	+ sB   'D	$B,2D	6+B2!D	,D	2ADD	DD		
D)remote)	r5   r6   rvrD   rC   r=   fr>   
old_remotes	   `   @r   wrapper6_patch_ray_remote.<locals>.new_remote.<locals>.wrapper7   sN    +/ " "0 )00: "		"2 ?IIr   )inspectisclass)rH   r=   r>   rJ   rI   s   ``` r   
new_remote%_patch_ray_remote.<locals>.new_remote,   sL     ??1
 a1$1&11;	 ;	z =1:Nr   )N)rayrF   	functoolswraps)rN   rI   s    @r   _patch_ray_remoterS   (   s3    J__Z J !JX CJr   c                     [         R                  " 5       n[        U UR                  S[        R
                  S.S9u  p4[         R                  " X4S9  g )NF)handledtype)client_options	mechanism)hint)r   r   r	   optionsr'   
identifiercapture_event)r/   r>   clienteventrY   s        r   r0   r0   |   sG    ""$F&~~"--
KE U.r   c                   2    \ rS rSrSrS\ 3r\S 5       rSrg)r'      rP   zauto.queue.c                  N    [        S5      n [        [        U 5        [        5         g )NrP   )r   r   r'   rS   )versions    r   
setup_onceRayIntegration.setup_once   s     "%(~w7r   r   N)	__name__
__module____qualname____firstlineno__r[   r#   staticmethodrc   __static_attributes__r   r   r   r'   r'      s%    J:,'F r   r'   ) rL   r.   r   sentry_sdk.constsr   r   sentry_sdk.integrationsr   r   r   sentry_sdk.tracingr   sentry_sdk.utilsr	   r
   r   r   r   rP   ImportErrorrQ   typingr   collections.abcr   r   r   r   r   rS   r0   r'   r   r   r   <module>rr      s{     
  , U U 0 -   ($(Qh/
[ 
s  -
+
,,-s   A2 2B