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

�

_�*j:���ddlZddlZddlZddlmZddlmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZmZddlmZddlmZdd	lmZdd
lmZmZmZmZmZ	ddlmZddlm Z dd
l!m"Z"ddl#m$Z%ddl&m'Z'	ddl&m)Z)e*e)d�sdZ)ddl+m,Z,e,rddl+m-Z-m.Z.ddlm/Z/ddl0m1Z1m2Z2ddlm3Z3Gd�de
�Z4dd�Z5dd�Z6y#e($r	e	d��wxYw#e($rdZ)Y�RwxYw)�N)�continue_trace)�OP�SPANDATA)�DidNotEnable�Integration�_check_minimum_version)�
ignore_logger)�Scope�should_send_default_pii)�
SegmentSource)�TransactionSource)�has_span_streaming_enabled)�SENSITIVE_DATA_SUBSTITUTE�capture_internal_exceptions�event_from_exception�format_timestamp�
parse_version)�	JobStatus)�Queue)�JobTimeoutException)�VERSION)�WorkerzRQ not installed)�
BaseWorker�perform_job)�
TYPE_CHECKING)�Any�Callable)�Job)�Event�EventProcessor)�ExcInfoc�,�eZdZdZde��Zedd��Zy)�
RqIntegration�rqzauto.queue.Nc������tt�}tt|�t�tnt
}|j�tj��dddddddddtf
�fd	��}||_|j�										d
�fd
�}||_
tj�tj��								d�fd��}|t_td�y)N�selfr�jobr�argsr�kwargs�returnc���tj�}|jt��
�
||g|��i|��Stj�5}|j�|j
ttj|���t|j��rtjj|jjd�xsi�t!j"d|i�d}t%�5|j&}ddd�tjj)|�dn|dt*j,dtj.dt0j2t4j6|j8id��5}|� |j;t4j<|��
||g|��i|��}ddd�n�t|jjd�xsit*j,dt>j2tj.��}	t%�5|j&|	_ ddd�tjB|	d|i�	�5�
||g|��i|��}ddd�ddd�|jDr"tj�jG�S#1swY���xYw#1swY�NxYw#1swY��xYw#1swY�fxYw#1swY�jxYw)
N�_sentry_trace_headers�rq_jobzunknown RQ taskz	sentry.opz
sentry.originzsentry.span.source)�name�
attributes�parent_span)�opr.�source�origin)�custom_sampling_context)$�
sentry_sdk�
get_client�get_integrationr#�	new_scope�clear_breadcrumbs�add_event_processor�_make_event_processor�weakref�refr�options�tracesr�meta�getr
�set_custom_sampling_contextr�	func_name�
start_spanr�
QUEUE_TASK_RQr3r�TASKr�MESSAGING_MESSAGE_ID�id�
set_attribute�CODE_FUNCTION_NAMEr
r.�start_transaction�is_horse�flush)r&r'r(r)�client�scoperC�span�rv�transaction�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_jobBse��� �*�*�,�F��%�%�m�4�<�&�t�S�B�4�B�6�B�B��%�%�'�5��'�'�)��)�)�*?����C�@P�*Q�R�-�f�n�n�=��%�%�4�4������%<�=�C����5�5�x��o�F� $�I�4�6�$'�M�M�	�7�$�*�*�5�5�2;�2C�.��'��)9�)9�+�]�-A�-A�0�-�2D�2D�$�9�9�3�6�6�	$�%)�6�	��$�0� �.�.�x�/J�/J�I�V�,�T�3�H��H��H��	�	�#1������%<�=�C���+�+�.�0�5�5�,�3�3�#�K�5�6�+.�=�=��(�7�$�5�5�#�19�3���-�T�3�H��H��H��	�S(�^�}�}��%�%�'�-�-�/��I�S7�6��	�	��.7�6�����S(�'�so�B3K�?
J�A8K�0J,�4A*K�J8�0!K�K�K�J)	�$K�,J5	�1K�8K	�=K�K
	�	K�Kc����t|d�xr|jxr|jdkD}|jtjk(xs|j
}|r
|st
|��||g|��i|��S)N�retries_leftr)�hasattrrW�_statusr�FAILED�	is_failed�_capture_exception)r&r'�exc_infor)�retry�failed�old_handle_exceptions      �rT�sentry_patched_handle_exceptionzARqIntegration.setup_once.<locals>.sentry_patched_handle_exception�sx�����^�,�)��$�$�)��$�$�q�(�
�
�[�[�I�$4�$4�4�E��
�
�F��e�"�8�,�'��c�G�H�G��G�G�c�P��tj�}|jt��
�||fi|��Stj�}t|j�r|jn|j}|�&t|j��|jd<�||fi|��S)Nr,)r5r6r7r#�get_current_scoperr>�
streamed_spanrP�dict�iter_trace_propagation_headersr@)r&r'r)rNrOrP�old_enqueue_jobs      �rT�sentry_patched_enqueue_jobz<RqIntegration.setup_once.<locals>.sentry_patched_enqueue_job�s���� �*�*�,�F��%�%�m�4�<�&�t�S�;�F�;�;��0�0�2�E�.�f�n�n�=��#�#��Z�Z�
�
��48��8�8�:�5����0�1�#�4��7��7�7rbz	rq.worker)
r&rr'rr]rr)rr*r)r&rr'rr)rr*r)r�
RQ_VERSIONrr#rrr�	functools�wraps�bool�handle_exceptionr�enqueue_jobr	)�version�
worker_clsrUrarirhr`rSs     @@@rT�
setup_oncezRqIntegration.setup_once5s ����
�+���}�g�6�$.�#9�Z�v�
�$�0�0��	����	)�<	��<	�#�<	�,3�<	�?D�<	�
�<	�
*�<	�|"<�
��)�:�:��	H��	H�!&�	H�38�	H�DI�	H�
�	H�'F�
�#��+�+��	����	)�	8��	8� %�	8�16�	8�
�	8�
*�	8�(7����k�"rb)r*N)�__name__�
__module__�__qualname__�
identifierr3�staticmethodrr�rbrTr#r#1s'���J��:�,�
'�F��x#��x#rbr#c���d�fd�}|S)Nc�f����}|��t�5|jdi�}|j|jt	�r|j
ntt	�r|jnt|jd�}|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�funcr(r)�description�enqueued_at�
started_atzrq-jobr]rr$r�fingerprint)r�
setdefaultrHrCrr(rr)r~rrr��
issubclassr)�event�hintr'r{r-�weak_jobs     �rT�event_processorz._make_event_processor.<locals>.event_processor�s����j���?�,�.��(�(��"�5��!�f�f��M�M�3�4����6�3�4��
�
�6�#&�?�?��� �?�?�,<�S�_�_�,M�F�=�)��>�>�+;�C�N�N�+K�F�<�(�"(��h��//�2���,�.��d�:�.�q�1�3F�G�,0�2G����+W�E�-�(�/���u��=/�.��4/���s�B:D�%)D&�D#�&D0)r�rr�zdict[str, Any]r*rrx)r�r�s` rTr;r;�s���!�F�rbc��tj�}t||jddd���\}}tj||��y)Nr$F)�type�handled)�client_options�	mechanism)r�)r5r6rr>�
capture_event)r]r)rNr�r�s     rTr\r\�sB��
�
"�
"�
$�F�&���~�~��E�2��K�E�4����U��.rb)r�zCallable[[], Job]r*r )r]r!r)rr*N)7rkr<r5�sentry_sdk.apir�sentry_sdk.constsrr�sentry_sdk.integrationsrrr�sentry_sdk.integrations.loggingr	�sentry_sdk.scoper
r�sentry_sdk.tracesr�sentry_sdk.tracingr
�sentry_sdk.tracing_utilsr�sentry_sdk.utilsrrrrr�rq.jobr�rq.queuer�rq.timeoutsr�
rq.versionrrj�	rq.workerr�ImportErrorrrX�typingrrrr�sentry_sdk._typesrr r!r#r;r\rxrbrT�<module>r�s������)�*�U�U�9�;�+�0�?���+� ��/�0� ��$��:�}�-��
�!��$��7�(�}#�K�}#�@$�N	/��{�+�
�)�
*�*�+�����J��s�B<�3C
�<C
�
C�C
Back to Directory File Manager