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

�

h0i���>�ddlZddlZddlmZddlmZddlmZmZm	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZ	ddlmZdd	lmZdd
lmZddlmZddlmZddl m!Z!e!rddl m"Z"m#Z#ddl$m%Z%m&Z&ddlm'Z'ddlm(Z(Gd�de	�Z)d�Z*d�Z+y#e$r	ed
��wxYw)�N)�OP)�continue_trace)�_check_minimum_version�DidNotEnable�Integration)�
ignore_logger)�TransactionSource)�capture_internal_exceptions�ensure_integration_enabled�event_from_exception�format_timestamp�
parse_version)�Queue)�JobTimeoutException)�VERSION)�Worker)�	JobStatuszRQ not installed)�
TYPE_CHECKING)�Any�Callable)�Event�EventProcessor)�ExcInfo)�Jobc�*�eZdZdZde��Zed��Zy)�
RqIntegration�rqzauto.queue.c�j����tt�}tt|�tj
�t
t���fd��}|t_tj��fd�}|t_tj�t
t���fd��}|t_	td�y)Nc���tj�5}|j�|jt	tj|���t|jjd�xsitjdtjtj��}t!�5|j"|_ddd�tj&|d|i��5�||g|��i|��}ddd�ddd�|j(r"tj*�j-�S#1swY�pxYw#1swY�MxYw#1swY�QxYw)N�_sentry_trace_headerszunknown RQ task)�op�name�source�origin�rq_job)�custom_sampling_context)�
sentry_sdk�	new_scope�clear_breadcrumbs�add_event_processor�_make_event_processor�weakref�refr�meta�getr�
QUEUE_TASK_RQr	�TASKrr$r
�	func_namer"�start_transaction�is_horse�
get_client�flush)�self�job�args�kwargs�scope�transaction�rv�old_perform_jobs       ��I/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/rq.py�sentry_patched_perform_jobz<RqIntegration.setup_once.<locals>.sentry_patched_perform_job1s����%�%�'�5��'�'�)��)�)�*?����C�@P�*Q�R�,��H�H�L�L�!8�9�?�R��'�'�*�,�1�1�(�/�/���1�2�'*�}�}�K�$�3� �1�1��-5�s�O��)��s�D�T�D�V�D�B�	�(�*�}�}��%�%�'�-�-�/��I�3�2�����(�'�s<�BE�5D6�!E�(E�6E�6D?	�;E�E	�E�Ec����t|d�xr|jxr|jdkD}|jtjk(xs|j
}|r
|st
|��||g|��i|��S)N�retries_leftr)�hasattrrB�_statusr�FAILED�	is_failed�_capture_exception)r7r8�exc_infor:�retry�failed�old_handle_exceptions      �r?�sentry_patched_handle_exceptionzARqIntegration.setup_once.<locals>.sentry_patched_handle_exceptionUsx�����^�,�)��$�$�)��$�$�q�(�
�
�[�[�I�$4�$4�4�E��
�
�F��e�"�8�,�'��c�G�H�G��G�G�c���tj�}|j�&t|j	��|j
d<�||fi|��S)Nr )r'�get_current_scope�span�dict�iter_trace_propagation_headersr.)r7r8r:r;�old_enqueue_jobs    �r?�sentry_patched_enqueue_jobz<RqIntegration.setup_once.<locals>.sentry_patched_enqueue_jobfsQ����0�0�2�E��z�z�%�48��8�8�:�5����0�1�#�4��7��7�7rMz	rq.worker)r�
RQ_VERSIONrrr�perform_jobr�handle_exceptionr�enqueue_jobr)�versionr@rLrTrSrKr>s    @@@r?�
setup_oncezRqIntegration.setup_once)s���� �
�+���}�g�6� �,�,��	#�M�?�	C�	�
D�	�>8���%�6�6��	H�#B����+�+��	#�M�?�	C�	8�
D�	8�7����k�"rMN)�__name__�
__module__�__qualname__�
identifierr$�staticmethodrZ�rMr?rr%s'���J��:�,�
'�F��I#��I#rMrc����fd�}|S)Nc�&����}|��t�5|jdi�}|j|j|j|j
|jd�}|jrt|j�|d<|jrt|j�|d<||d<ddd�d|vr=t�5t|ddt�rdd	|jg|d
<ddd�|S|S#1swY�LxYw#1swY|SxYw)N�extra)�job_id�funcr9r:�description�enqueued_at�
started_atzrq-jobrHrrr�fingerprint)r
�
setdefault�idr2r9r:rfrgr
rh�
issubclassr)�event�hintr8rcr%�weak_jobs     �r?�event_processorz._make_event_processor.<locals>.event_processorxs�����j���?�,�.��(�(��"�5��!�f�f��M�M��H�H�!�j�j�#&�?�?����?�?�,<�S�_�_�,M�F�=�)��>�>�+;�C�N�N�+K�F�<�(�"(��h��/�"���,�.��d�:�.�q�1�3F�G�,0�2G����+W�E�-�(�/���u��-/�.��$/���s�BC:�)D�:D�Dr`)rorps` r?r+r+vs����8�rMc��tj�}t||jddd���\}}tj||��y)NrF)�type�handled)�client_options�	mechanism)rn)r'r5r�options�
capture_event)rHr:�clientrmrns     r?rGrG�sB��
�
"�
"�
$�F�&���~�~��E�2��K�E�4����U��.rM),r,r'�sentry_sdk.constsr�sentry_sdk.apir�sentry_sdk.integrationsrrr�sentry_sdk.integrations.loggingr�sentry_sdk.tracingr	�sentry_sdk.utilsr
rrr
r�rq.queuer�rq.timeoutsr�
rq.versionrrU�	rq.workerr�rq.jobr�ImportError�typingrrr�sentry_sdk._typesrrrrrr+rGr`rMr?�<module>r�s����� �)�U�U�9�0���+��/�0� � �!��$�7�(��N#�K�N#�b�B
/��A�+�
�)�
*�*�+�s�B�B
Back to Directory File Manager