0iddlZddlZddlZddlZddlmZmZddlmZm Z m Z ddl m Z ddl mZmZmZmZmZ ddlZddlmZerddlmZdd lmZmZdd l mZd Zd Zd ZGdde Zy#e$r e dwxYw)N)OP SPANSTATUS)_check_minimum_version DidNotEnable Integration)TransactionSource)event_from_exceptionloggerpackage_versionqualname_from_functionreraisezRay not installed.) TYPE_CHECKING)Callable)AnyOptional)ExcInfocttjjrytjdy)Nz[[Tracing] Sentry not initialized in ray cluster worker, performance data will be discarded.) sentry_sdk get_client is_activer debugJ/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/ray.py_check_sentry_initializedrs)((* LLercxtjtjdfd }|t_y)Ncttjr giSfd}|S|S)Nctjddfd }tj|}t |j j }|jtjdtjjd|j||_ r  |}n i |}|jfd}||_ |S)N)_sentry_tracingcttj|xsitjt t jtj}tj|5} |i|}|jtjcdddS#t$rI|jtjt!j"}t%|t'|Y\wxYw#1swYyxYw)N)opnameoriginsource)rrcontinue_tracerQUEUE_TASK_RAYr RayIntegrationr#rTASKstart_transaction set_statusrOK ExceptionINTERNAL_ERRORsysexc_info_capture_exceptionr )rf_argsf_kwargs transactionresultr/user_fs rnew_funczH_patch_ray_remote..new_remote..wrapper..new_func9s*+(77#)r((/7)00,11   11+>++!'!<8!<#..z}}="?>%+#..z/H/HI#&<<>*84* + ?>s12C;4'B&C;&AC85C;7C88C;;Dr)kinddefault) parametersc&tjtjt t j 5}tjjDcic]\}}|| }}} |i|d|i}|jtjcdddScc}}w#t$rI|jtjtj}t!|t#|YbwxYw#1swYyxYw)z, Ray Client )r!r"r#rN)r start_spanrQUEUE_SUBMIT_RAYr r'r#get_current_scopeiter_trace_propagation_headersr*rr+r,r-r.r/r0r ) argskwargsspankvtracingr4r/old_remote_methodr5s r&_remote_method_with_header_propagationzf_patch_ray_remote..new_remote..wrapper.._remote_method_with_header_propagationes  ****/7)00%/$@$@$B$a$a$c$cDAq1$c +!2!"%+"=D" 6") %+ (A(AB#&<<>*84* +sB&D% B,2D6+B2!D,D2ADDDDD) functoolswrapsinspect signaturelistr9valuesappend Parameter KEYWORD_ONLYreplace __signature__remote) r5r6rJparamsrvrFrEr?fr@ old_remotes ` @rwrapperz6_patch_ray_remote..new_remote..wrapper7s __V $26 "% "4 ))(3I)..5578F MM!!% **77  &/%6%6&%6%IH ")0Z00: "  "6?BIIr)rIisclass)rUr?r@rWrVs``` r new_remotez%_patch_ray_remote..new_remote,sE ??1  a1$1&1 1K Z =1: Nr)N)rayrRrGrH)rYrVs @r_patch_ray_remoter[(s3J__Z Z!ZxCJrc tj}t||jdtj d\}}tj ||y)NF)handledtype)client_options mechanism)hint)rrr optionsr' identifier capture_event)r/r@clienteventras rr0r0sK  " " $F&~~"-- KE4U.rc*eZdZdZdeZedZy)r'rZz auto.queue.cNtd}tt|ty)NrZ)r rr'r[)versions r setup_oncezRayIntegration.setup_onces"%(~w7rN)__name__ __module__ __qualname__rcr# staticmethodrjrrrr'r's%J:, 'Frr') rIrGr.rsentry_sdk.constsrrsentry_sdk.integrationsrrrsentry_sdk.tracingrsentry_sdk.utilsr r r r r rZ ImportErrortypingrcollections.abcrrrrrr[r0r'rrrrvs{ ,UU0-!($(aH / [ Q- + ,,-s A--A;