Viewing File: /opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/__pycache__/ray.cpython-312.pyc

�

h0i����ddlZddlZddlZddlZddlmZmZddlmZm	Z	m
Z
ddlmZddl
mZmZmZmZmZ	ddlZddlmZerddlmZdd	lmZmZdd
l
mZd�Zd�Zd
�ZGd�de
�Zy#e$r	e	d��wxYw)�N)�OP�
SPANSTATUS)�_check_minimum_version�DidNotEnable�Integration)�TransactionSource)�event_from_exception�logger�package_version�qualname_from_function�reraisezRay not installed.)�
TYPE_CHECKING)�Callable)�Any�Optional)�ExcInfoc�t�tj�j�rytjd�y)Nz[[Tracing] Sentry not initialized in ray cluster worker, performance data will be discarded.)�
sentry_sdk�
get_client�	is_activer
�debug���J/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/ray.py�_check_sentry_initializedrs)������(�(�*��
�L�L�e�rc�x��tj�tj��d�fd�	�}|t_y)Nc�t�����tj��r��g���i���S����fd�}��|��S|S)Nc������tj��dd��fd�
�}tj|�}t	|j
j
��}|jtjdtjjd���|j|��|_�r	�
|�}n�
�i�	��|�}|j���fd�}||_|S)N)�_sentry_tracingc���t�tj|xsitjt��tjtj��}tj|�5}	�|i|��}|jtj�cddd�S#t$rI|jtj�t!j"�}t%|�t'|�Y�\wxYw#1swYyxYw)N)�op�name�origin�source)rr�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_func9s����*�+�(�7�7�#�)�r��(�(�/��7�)�0�0�,�1�1��� �1�1�+�>�+�+�!'��!<�8�!<��#�.�.�z�}�}�=�"�?�>��%�+�#�.�.�z�/H�/H�I�#&�<�<�>��*�8�4���*�	+��	?�>�s1�2C;�4'B&�C;�&AC8�5C;�7C8�8C;�;Dr)�kind�default)�
parametersc�&��tjtjt	�	�t
j��5}tj�j�D��cic]\}}||��
}}}	�|i|�d|i��}|jtj�cddd�Scc}}w#t$rI|jtj�tj�}t!|�t#|�Y�bwxYw#1swYyxYw)z,
                Ray Client
                )r!r"r#rN)r�
start_spanr�QUEUE_SUBMIT_RAYrr'r#�get_current_scope�iter_trace_propagation_headersr*rr+r,r-r.r/r0r
)
�args�kwargs�span�k�v�tracingr4r/�old_remote_methodr5s
        ��r�&_remote_method_with_header_propagationzf_patch_ray_remote.<locals>.new_remote.<locals>.wrapper.<locals>._remote_method_with_header_propagationes����
 �*�*��*�*�/��7�)�0�0���%/�$@�$@�$B�$a�$a�$c��$c�D�A�q��1��$c���	+�!2�!�"�%+�"�=D�"�����
�
�
�6�"�)���
��%�+����
�(A�(A�B�#&�<�<�>��*�8�4���*�	+����sB�&D�%
B,�2D�6+B2�!D�,D�2AD�D�D�D�D)
�	functools�wraps�inspect�	signature�listr9�values�append�	Parameter�KEYWORD_ONLY�replace�
__signature__�remote)r5r6rJ�params�rvrFrEr?�fr@�
old_remotes`     @����r�wrapperz6_patch_ray_remote.<locals>.new_remote.<locals>.wrapper7s����
�_�_�V�
$�26�
"�%�
"�4 �)�)�(�3�I��)�.�.�5�5�7�8�F��M�M��!�!�%� �*�*�7�7� ��
�&/�%6�%6�&�%6�%I�H�"����)��0�Z��0��0��:�� "�	�	��
"�6?�B�I��Ir)rI�isclass)rUr?r@rWrVs``` �r�
new_remotez%_patch_ray_remote.<locals>.new_remote,sE����?�?�1��
�a�1�$�1�&�1�1�K	�Z
�=��1�:���Nr)N)�rayrRrGrH)rYrVs @r�_patch_ray_remoter[(s3������J��_�_�Z� �Z�!�Z�x�C�Jrc��tj�}t||jdtj
d���\}}tj||��y)NF)�handled�type)�client_options�	mechanism)�hint)rrr	�optionsr'�
identifier�
capture_event)r/r@�client�eventras     rr0r0�sK��
�
"�
"�
$�F�&���~�~��"�-�-�
��K�E�4����U��.rc�*�eZdZdZde��Zed��Zy)r'rZzauto.queue.c�N�td�}tt|�t�y)NrZ)rrr'r[)�versions r�
setup_oncezRayIntegration.setup_once�s��"�%�(���~�w�7��rN)�__name__�
__module__�__qualname__rcr#�staticmethodrjrrrr'r'�s%���J��:�,�
'�F����rr') rIrGr.r�sentry_sdk.constsrr�sentry_sdk.integrationsrrr�sentry_sdk.tracingr�sentry_sdk.utilsr	r
rrr
rZ�ImportError�typingr�collections.abcrrrrrr[r0r'rrr�<module>rvs{����
��,�U�U�0���-��!��(�$�(��a�H/�
�[�
��Q�-�
�+�
,�,�-�s�A-�-A;
Back to Directory File Manager