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

�

_�*j������UddlZddlZddlZddlZddlZddlZddlmZmZddl	m	Z	m
Z
ddlmZddl
mZmZmZmZmZddlmZddlmZddlmZdd	lmZmZmZmZmZmZm Z dd
l!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'ddl(m)Z)dd
l*m+Z+ddl,m-Z-ddl.m/Z/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9m:Z:ddl;m<Z<ddl=m>Z>ddl?m@Z@mAZAmBZBddlCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTerfddl
mUZUmVZVmWZWmXZXmYZYmZZZm[Z[ddl\m]Z]ddlmZddl^m_Z_m`Z`maZambZbmcZcmdZdmeZeddl%mfZfddlgmhZhddlimjZjddlkmlZlddl8m:Z:dd l?m#Z#mmZmdd!lCmnZneZd"ef�#�ZoeEd$�Zpd%ed&ed'�gd(�Zqd)erd*<				d<d+�Zs						d=d,�Zt				d>d-�Zud?d.�Zv	ewZxGd/�d0�Z{Gd1�d2e{�Z|Gd3�d4e{�Z}dd5l
mZerGd6�d7e ee~eUf�ZGd8�d9e e}�Z�yd:��Zd;��Z�y#ey$rezZxY�`wxYw)@�N)�Iterable�Mapping)�datetime�timezone)�
import_module)�
TYPE_CHECKING�Dict�List�cast�overload)�check_uwsgi_thread_support)�MetricsBatcher)�SpanBatcher)�DEFAULT_MAX_VALUE_LENGTH�DEFAULT_OPTIONS�INSTRUMENTER�SPANDATA�
SPANSTATUS�VERSION�ClientConstructor)�Envelope�Item�
PayloadRef)�_DEFAULT_INTEGRATIONS�setup_integrations)�DedupeIntegration)�Monitor)�setup_continuous_profiler)�Profile�has_profiling_enabled�setup_profiler)�
EventScrubber)�	serialize)�SessionFlusher)�
SpanStatus�StreamedSpan)�trace)�has_span_streaming_enabled)�AsyncHttpTransport�HttpTransportCore�make_transport)�AnnotatedValue�
ContextVar�capture_internal_exceptions�current_stacktrace�datetime_from_isoformat�env_to_bool�format_timestamp�get_before_send_log�get_before_send_metric�get_before_send_span�get_default_release�get_sdk_name�
get_type_name�
handle_in_app�has_logs_enabled�has_metrics_enabled�logger)�Any�Callable�Optional�Sequence�Type�TypeVar�Union��
LogBatcher)�Event�EventDataCategory�Hint�Log�Metric�SDKInfo�SerializedAttributeValue)�Integration)�Scope)�Session)�SpotlightClient)r&)r�	Transport)�Dsn�I)�bound�client_init_debugz
sentry.pythonzpypi:sentry-sdk)�name�version)rVrW�packagesrK�SDK_INFOc���t|t�r|dd�St|t�r|dd�St|t�r|dd�St|t�r|dd�St|t
�rF|sgdd�St
|d���ttttfvrt�fd�|D��r|dd�St|tt
f�rtj|�dd�Sy)	N�boolean)�value�type�integer�double�string�arrayrc3�8�K�|]}t|��u���y�w�N)r])�.0�v�tys  ��@/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/client.py�	<genexpr>zF_serialized_v1_attribute_to_serialized_v2_attribute.<locals>.<genexpr>�s�����1
�#2�a�D��G�r�M�?�s�)�
isinstance�bool�int�float�str�listr]�all�dict�json�dumps)�attribute_valuerfs @rg�3_serialized_v1_attribute_to_serialized_v2_attributertcs����/�4�(�$��
�	
�
�/�3�'�$��
�	
�
�/�5�)�$��
�	
�
�/�3�'�$��
�	
�
�/�4�(����1�1�
�/�!�$�
%��
�#�s�D�%�(�(�S�1
�#2�1
�.
�)���
��/�D�$�<�0��Z�Z��0��
�	
�
�c��tjjdd�}d|vr|d|d<d|vr|d|d<d|vr|d}|�	d|vr|d}||d<d|vr&d}	t|d�}|�|j�|d<d	|vr&d}	t|d	�}|�|j�|d
<d|vr|d|d<d|vr|dtjk7rd
|d<i}d|vr|d|d<d|vr|d|d<|jd�}t|t�r|j|�|jd�}t|t�r|j|�|jd�}	t|	t�r$d|	vr|	d|d<d|	vr|	d|d<d|	vr|	d|d<d|vr|d|d<d|vr|d|d<d|vr|d|d<d |vr|d |d!<|jd"i�jd#i�}
d|
vr|
d|d$<|jd%�}t|t�rd|vr|d|d&<d'|vr|d'|d(<|s|Si|d)<|j�D]\}}
t|
�}|��||d)|<�d|d)vr|d)d=|S#t$rY��wxYw#t$rY���wxYw)*NF)�status�
is_segment�trace_id�span_id�description�oprV�start_timestamp�	timestamp�
end_timestamp�parent_span_idrw�errorz	sentry.op�originz
sentry.origin�data�tags�user�idzuser.id�usernamez	user.name�emailz
user.email�releasezsentry.release�environmentzsentry.environment�server_namezserver.address�transactionzsentry.segment.name�contextsr'zsentry.segment.id�sdkzsentry.sdk.namerWzsentry.sdk.version�
attributes)
r%�OKr\r0�	Exceptionr~r�getrirp�update�itemsrt)�span�event�resr{r}rr��	span_data�	span_tagsr��
trace_context�sdk_info�keyr\�converted_values               rg�)_serialized_v1_span_to_serialized_v2_spanr��su��
�-�-�%�%���C�
�T���z�*��J���D���i���I������=�)����4�4�<��t�*�K�!��F���D� ���	�5�d�;L�6M�N�O��&�%4�%>�%>�%@�C�!�"��d���
�	�3�D��4E�F�M��$�#0�#:�#:�#<�C�� ��4�� $�%5� 6�����4��D��N�j�m�m�;���H�
�#%�J��t�|�"&�t�*�
�;���4��&*�8�n�
�?�#����� �I��)�T�"����)�$����� �I��)�T�"����)�$��9�9�V��D��$����4�<�$(��J�J�y�!����&*�:�&6�J�{�#��d�?�'+�G�}�J�|�$��E��',�Y�'7�
�#�$����+0��+?�
�'�(����',�]�';�
�#�$����,1�-�,@�
�(�)��I�I�j�"�-�1�1�'�2�>�M��M�!�*7�	�*B�
�&�'��y�y���H��(�D�!��X��,4�V�,<�J�(�)��� �/7�	�/B�J�+�,���
��C��� �&�&�(�
��U�M�e�T���"��!0��L��#��)��3�|�$�$����h�'��J��g�	��	���	��	�s$�I.�I>�.	I;�:I;�>	J�
Jc�|�d|vry|d}t|t�r|j}t|t�syg}g}|D]y}t|t�s|j|��%|j
d�}t|t�r#|jd�r|j|��i|j|��{||fS)N�spansr|zgen_ai.)	rir,r\rrp�appendr�rm�
startswith)�	event_optr��non_gen_ai_spans�gen_ai_spansr��span_ops      rg�_split_gen_ai_spansr�s����i����W�%�E��%��(������e�X�&�����L����$��%��#�#�D�)���(�(�4�.���g�s�#��(:�(:�9�(E�����%��#�#�D�)���\�)�)ruc�.�|r)t|dttf�s|d�|d}|dd}nd}t|�dkDrt	d��tt�}t|i|��}|�|jd��||d<|j�D]\}}||vrt	d|����|||<�|d�"tjjd�|d<|d�
t�|d<|d�&tjjd	�xsd
|d<|d�1ttjjd�d
��xsd|d<|d�'ttd�rtj�|d<|d�t j"|d<|d�	tj$�}||d<|dd
ur
|d�d|d<|d�t)|d�dn|d��|d<|dr-t|dt*�st-j.d�d|d<|d�1ttjjd�d
��xsd|d<|d�t1j2dt4d� �|d!r"t7|�rt1j2d"d� �|S#t&$rd}Y��wxYw)#Nr�z+Only single positional argument is expected�dsnzUnknown option �
SENTRY_DSNr�r��SENTRY_ENVIRONMENT�
production�debug�SENTRY_DEBUGT)�strictFr��gethostname�instrumenter�project_root�enable_tracing�traces_sample_rate��?�event_scrubber�send_default_pii)r��socket_optionszxIgnoring socket_options because of unexpected format. See urllib3.HTTPConnection.socket_options for the expected format.�
keep_alive�SENTRY_KEEP_ALIVEzVThe `enable_tracing` parameter is deprecated. Please use `traces_sample_rate` instead.���
stacklevel�trace_ignore_status_codeszLThe `trace_ignore_status_codes` parameter is ignored in span streaming mode.)ri�bytesrm�len�	TypeErrorrprr�r��os�environr6r1�hasattr�socketr�r�SENTRY�getcwdr�r"rnr<�warning�warnings�warn�DeprecationWarningr()�args�kwargsr��rv�optionsr�r\r�s        rg�_get_optionsr�#s�����D��G�e�S�\�2�d�1�g�o�#�A�w���A�B�x����
�4�y�1�}��E�F�F�	
�o�	�B��D�#�F�#�G�
��7�;�;�u�-�5������m�m�o�
��U��b�=��3�8�9�9���3��	&�
�%�y���J�J�N�N�<�0��5�	�	�)�}��+�-��9�
�	�-�� ��J�J�N�N�+?�@�P�L��=��	�'�{��!�"�*�*�.�.��"@��N�W�RW��7��	�-�� �W�V�]�%C�"�.�.�0��=��	�.��!�)�0�0��>��	�.��!�	 ��9�9�;�L�*��>��	�
��t�#��+?�(@�(H�#&��� �	�
��#�,��.�/�7��R�@R�=S� 
����
�
��J�r�2B�/C�T�$J����
G�	
� $����	�,�����
�
���':�;�D�I�R�U�	�<��
�
��'��
�
�d���	
�
�
%�&�+E�b�+I��
�
�Z��	
�
�I��O�	 ��L�	 �s�J�J�Jc��eZdZUdZdZded<ddd�Zdd�Zd d�Ze	d!d	��Z
e	d"d
��Zdefd�Z
defd�Zd#d
�Zd$d�Zd%d�Zd&d�Zd d�Zerededdfd��Zed'd��Z				d(d�Zd d�Zd d�Zd d�Zd d�Zd)d�Zd*d�Zy)+�
BaseClientzp
    .. versionadded:: 2.0.0

    The basic definition of a client that is used for sending data to Sentry.
    NzOptional[SpotlightClient]�	spotlight�returnc�v�|�|nt|_d|_d|_d|_d|_d|_i|_yrc)rr��	transport�monitor�log_batcher�metrics_batcher�span_batcher�integrations)�selfr�s  rg�__init__zBaseClient.__init__�sC���*�G��	
��15���,0���37���;?���59���68��ruc�
�diiS�Nr���r�r�r�s   rg�__getstate__zBaseClient.__getstate__�s���2��ruc��yrcr�r�s   rg�__setstate__zBaseClient.__setstate__����ruc��yrcr��r�s rgr�zBaseClient.dsn����ruc��yrcr�r�s rg�
parsed_dsnzBaseClient.parsed_dsn�r�ruc��y)NFr�r�s rg�should_send_default_piiz"BaseClient.should_send_default_pii�s��ruc��y)�u
        .. versionadded:: 2.0.0

        Returns whether the client is active (able to send data to Sentry)
        Fr�r�s rg�	is_activezBaseClient.is_active�s��ruc��yrcr�r�s   rg�
capture_eventzBaseClient.capture_event����ruc��yrcr��r��log�scopes   rg�_capture_logzBaseClient._capture_log�r�ruc��yrcr��r��metricr�s   rg�_capture_metriczBaseClient._capture_metric�r�ruc��yrcr��r�r�r�s   rg�
_capture_spanzBaseClient._capture_span�r�ruc��yrcr�r�s   rg�capture_sessionzBaseClient.capture_session�r�ru�
name_or_class�Optional[Integration]c��yrcr��r�rs  rg�get_integrationzBaseClient.get_integration����RUruc��yrcr�rs  rgrzBaseClient.get_integration����NQruc��yrcr�rs  rgrzBaseClient.get_integration�s��ruc��yrcr�r�s   rg�closezBaseClient.close�r�ruc��yrcr�r�s   rg�flushzBaseClient.flush�r�ruc��K�y�wrcr�r�s   rg�close_asynczBaseClient.close_async��	�������c��K�y�wrcr�r�s   rg�flush_asynczBaseClient.flush_async�rrc��|Srcr�r�s rg�	__enter__zBaseClient.__enter__�����ruc��yrcr��r��exc_type�	exc_value�tbs    rg�__exit__zBaseClient.__exit__�r�rurc)r�zOptional[Dict[str, Any]]r�N)r�r=r�r=r�r=�r�r=r�r=r�N�r��
Optional[str]�r�z
Optional[Dsn])r�r=r�r=r�r )r�rIr�rNr�N)r�rJr�rNr�N)r�r&r�rNr�N�rztype[I]r�zOptional[I])rzUnion[str, type[Integration]]r�r)r�r��rr=rr=rr=r�N)�__name__�
__module__�__qualname__�__doc__r��__annotations__r�r�r��propertyr�r�rjr�r�r�r�r�r�rrrrmrrrrrrrr�rurgr�r�s����.2�I�*�1�
9��
�������������4���
�
�
���	�U��U�9P�U�
�U�	�Q�
�Q��<��	 ��
�����rur�c��eZdZdZy)�NonRecordingClientz�
    .. versionadded:: 2.0.0

    A client that does not send any events to Sentry. This is used as a fallback when the Sentry SDK is not yet initialized.
    N)r$r%r&r'r�rurgr+r+�s���	rur+c	�B��eZdZdZd3�fd�Zd4d�Zd5d�Z				d6d�Zd7d�Zde	fd	�Z
de	fd
�Zed8d��Z
ed9d��Z								d:d�Zd
dddde	fd�Z	d;d
dddddde	fd�Zd
dddde	fd�Z						d<d�Z		d=							d>d�Zdddeddddfd�Zd?d�Zd@d�ZdAd �Z				dBd!�Zered"edd#fd$��ZedCd%��Z				dDd&�Zde	fd'�ZedEd(��Zd7d)�Z d7d*�Z!		d=					dFd+�Z"		d=					dFd,�Z#		d=					dFd-�Z$		d=					dFd.�Z%dGd/�Z&dHd0�Z'dGd1�Z(dHd2�Z)�xZ*S)I�_ClientaI
    The client is internally responsible for capturing the events and
    forwarding them to sentry through the configured transport.  It takes
    the client options as keyword arguments and optionally the DSN as first
    argument.

    Alias of :py:class:`sentry_sdk.Client`. (Was created for better intelisense support)
    r�Nc�`��tt|�t|i|����|j	�y)N�r�)�superr-r��get_options�
_init_impl)r�r�r��	__class__s   �rgr�z_Client.__init__�s)���
�g�t�%�k�4�.J�6�.J�%�K����ruc��d|jiSr�r/r�s rgr�z_Client.__getstate__�s���4�<�<�(�(ruc�8�|d|_|j�yr�)r�r2)r��states  rgr�z_Client.__setstate__�s���Y�'������ruc� �|D]}}d}|d}d|vrtjd|��%|jdd�\}}	t|�}t	||�}t||t
|��tjd|��y#t$r�	|jdd�\}}t|�}t	||�}	t	|	|�}t|	j|�}
t
|�}|
ttfvrt|�}t|	||�t|||	�tjd|�n-#t$r!}tjd||�Yd}~nd}~wwxYwY��`t$r"}tjd||�Yd}~���d}~wwxYw)z�
        Instruments the functions given in the list `functions_to_trace` with the `@sentry_sdk.tracing.trace` decorator.
        N�qualified_name�.z|Can not enable tracing for '%s'. Please provide the fully qualified name including the module (e.g. 'mymodule.my_function').r�zEnabled tracing for %szWCan not enable tracing for '%s'. (%s) Please check your `functions_to_trace` parameter.)r<r��rsplitr�getattr�setattrr'r��module_not_found_errorr]�__dict__�staticmethod�classmethodr�)
r��functions_to_trace�function�
class_name�function_qualname�module_name�
function_name�
module_obj�function_obj�	class_obj�
function_type�traced_function�es
             rg�_setup_instrumentationz_Client._setup_instrumentation�s���+�H��J� (�)9� :���+�+����S�%���):�)A�)A�#�q�)I�&�K��'
�+�;�7�
�&�z�=�A���
�M�5��3F�G����5�7H�I�)+��**�
��/:�.@�.@��a�.H�+�K��!.�{�!;�J� '�
�J� ?�I�#*�9�m�#D�L�$(��);�);�M�)J�$K�M�&+�L�&9�O�$��{�(C�C�*6��*G���I�}�o�F��J�
�I�>��L�L�!9�;L�M�� ���N�N�q�)��������
����m�%�����
�sI�AB�	F
�B$D3�2F
�3	E�<E�F
�E�F
�#F
�+F�F
c����tjd�}d,�fd�}		d-dtddddd	tddf
�fd
�
}	tj	�j
d�t
�j
��_d�_�jr)�j
drt�j��_d
dl
m}|�j
��_�j�N�j
ds?d�}d�j
d<|�j
d<|�j
d<|�j
d<t|���_d�_t!�j
�rd
dlm}|||���_d�_t)�j
�rt+||���_d�_t/�j
�rt1||���_d}�j
d|vrt3dj5|����j
djdd�rOt7j8d�t:j<�j
d<d t>vrt?j@d �tC�j
d!�j
d"�j
d#�j
d$�j
�%��_"tGtI�jDjK���}|tLd&<t7j8d'|�tO�j
�r	tQ�j
�n	tU�j
tL|�)�tj	|��jW�j
jd+g���jsS�jsG�j&s;�j,s/tO�j
�stY�jtZ�rt]�yy#tR$r }	t7j8d(|	�Yd}	~	��d}	~	wwxYw#tR$r }	t7j8d*|	�Yd}	~	��d}	~	wwxYw#tj	|�wxYw).NFr�c����j��jj|��j��jj|�yyrc)r��capture_enveloper�)�enveloper�s �rg�_capture_envelopez-_Client._init_impl.<locals>._capture_envelope:s@����~�~�)����/�/��9��~�~�)����/�/��9�*ru�reason�
data_categoryrG�itemzOptional[Item]�quantityc�^���j� �jj||||��yy)N)rSrTrUrV)r��record_lost_event)rSrTrUrVr�s    �rg�_record_lost_eventz._Client._init_impl.<locals>._record_lost_event@s7����~�~�)����0�0�!�"/��%�	1��*rur��enable_backpressure_handlingr)�setup_spotlightr�c��y)Nr�r�)�_args�_kwargss  rg�<lambda>z$_Client._init_impl.<locals>.<lambda>]s��sruTr��
error_sampler�traces_sampler�profiles_sampler)�capture_funcrD)rc�record_lost_func)�always�never�small�medium�max_request_body_sizez:Invalid value for max_request_body_size. Must be one of {}�_experiments�otel_powered_performancezA[OTel] Enabling experimental OTel-powered performance monitoring.r�zJsentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegrationr��default_integrations�auto_enabling_integrations�disabled_integrations)�
with_defaults�with_auto_enabling_integrationsrnr�rVzSetting SDK name to '%s'zCan not set up profiler. (%s))r�rcz(Can not set up continuous profiler. (%s)rA)rQrr�N)Nr�)/�_client_init_debugr�rmrk�setr�r+r�r�r�sentry_sdk.spotlightr[r�r$�session_flusherr�r:�sentry_sdk._log_batcherrEr�r;rr�r(r�
ValueError�formatr<r�r�OTELrr�rr�r7rn�keysrYr r!r�rrMrir*r
)
r��	old_debugrRrYr[�
sample_allrEri�sdk_namerLs
`         rgr2z_Client._init_impl7s����&�*�*�5�1�	�	:�&*��		��	�.�	�#�	��		�
�	�b	.��"�"�4�<�<��#8�9�+�D�L�L�9�D�N��D�L��~�~��<�<� >�?�#*�4�>�>�#:�D�L�
=�,�T�\�\�:�D�N��~�~�)�$�,�,�u�2E�:�
�37����/�0�0:����_�-�1;����-�.�3=����/�0�#1�?P�#Q�D� �#�D������-�>�#-�!2�%7�$�� �
$(�D� �"�4�<�<�0�'5�!2�%7�(��$�
!%�D��)�$�,�,�7�$/�!2�%7�%��!�
%K�!��|�|�3�4�<Q�Q� �P�W�W�-�����|�|�N�+�/�/�0J�E�R����W��0<�/@�/@����^�,�`�0�1�*�0�0�d��!3����^�,�"�l�l�+A�B�04���0�1�'+�l�l�3J�&K����!�D��$�D��):�):�)?�)?�)A�$B�C�H�'�H�V���L�L�3�X�>�$�T�\�\�2�E�"�4�<�<�0�P�-����!)�%6��
�"�"�9�-��#�#�D�L�L�$4�$4�5I�2�$N�O�
�L�L�����#�#�� � �$�T�\�\�2��$�.�.�*;�<�
'�(�	=��/!�E��L�L�!@�!�D�D��E��!�P��L�L�!K�Q�O�O��P��
�"�"�9�-�sZ�KQ�O3�*Q�,P�3	P�<P�Q�P�Q�	Q�(Q�>Q�Q�Q�Q"c��y)r�Tr�r�s rgr�z_Client.is_active�s��ruc�@�|jjd�xsdS)z�
        .. versionadded:: 2.0.0

        Returns whether the client should send default PII (Personally Identifiable Information) data to Sentry.
        r�F)r�r�r�s rgr�z_Client.should_send_default_pii�s���|�|��� 2�3�<�u�<ruc� �|jdS)z%Returns the configured DSN as string.r�r/r�s rgr�z_Client.dsn�s���|�|�E�"�"ruc�J�|jr|jjSdS)z)Returns the configured parsed DSN object.N)r�r�r�s rgr�z_Client.parsed_dsn�s��-1�N�N�t�~�~�(�(�D��Drur�rF�hintrHr��Optional[Scope]c�L�d}d}|jd��&tjtj�|d<|jd�dk(}|���tt
ttttf|jdg���}|j|||j�}|�Q|jrD|jjd|rdnd��|r!|jjdd|d	z�
�y|}|tt
ttttf|jdg���z
}	|jdd�}
|rR|j�F|	dkDr|jjdd|	�
�|
dkDr|jjd
d|
�
�|
|	z}|dkDr||z}|j dkDrN|jdi�}t#|t$�s|jdg�ng}
t|
�|j z}|s}|jdrnd|vrjd|vrfd|vrbt'�5dt)|jjdd�|jjdt*���ddd�gi|d<ddd�dD]M}|j|���|j|��%t|j|�j-�||<�O|jd��:t/t0�}t3|j4j7��|d<||d<|jd��d|d<t9||jd|jd |jd!�}|�"|jd"}|r|j;|�|��|j<r�|jdg�}t#|t>�r�|D]�}|jd#d�}|jd$i�}|s�*||j<vs�9t@jB|vs�Lt%|t@jBd%|j<|i�|t@jB<��|�!t%|jdg�d%|i�|d<|�#t%|jddgi�d%|i�|d<|�nt
d&tEt
d'|�|jjd(�|jjd�|jjd)��*��}|jd+}|��|��|jd�dk7r�d}t'�5|||xsi�}ddd�|�ctGjHd,�|jr|jjd+d��|jd�rtKjL�|}|jd-}|��(|��%|jd�dk(�rd}tt
ttttf|jdg���}t'�5|||xsi�}ddd�|�`tGjHd.�|jr�|jjd+d�/�|jjd+d|d	z�0�nM|t|jdg��z
}	|	dkDr*|j�|jjd+d|	�0�|}|S#1swY��wxYw#1swY���xYw#1swY��xYw)1Nr~r]r�r��event_processorr��rTr�r�)rTrV�_dropped_spansr�buffer_overflow�breadcrumbs�values�attach_stacktrace�	exception�
stacktrace�threads�include_local_variablesT�max_value_length)r�r�F)r��crashed�current)r�r�r��distr�r��platform�python�in_app_exclude�in_app_includer�r�rzr�r�rF�Dict[str, Any]ri�custom_repr)rir�r��before_sendzbefore send dropped event�before_send_transactionz%before send transaction dropped event)rSrT)rSrTrV)'r�r�nowr�utcr�rr
r	rm�object�apply_to_eventr�r�rX�pop�_n_breadcrumbs_truncatedrir,r.r/r�striprprY�sortedr�ryr9�scrub_event�_gen_ai_original_message_countrnr�GEN_AI_REQUEST_MESSAGESr#r<�infor�reset_last_seen)r�r�r�r��previous_total_spans�previous_total_breadcrumbs�is_transaction�spans_before�event_�spans_delta�span_recorder_dropped_spans�
dropped_spansr�r�r�r�r�r�r�rzr�r��	new_eventr�s                        rg�_prepare_eventz_Client._prepare_event�s���15��6:�"��9�9�[�!�)�!)���h�l�l�!;�E�+�����6�*�m�;�����t�D��c�6�k�):�$;�U�Y�Y�w�PR�=S�T�U�L��)�)�%��t�|�|�D�F��~��>�>��N�N�4�4�)�8F�}�G�5��&����8�8�-�*0�%1�A�%5�9��
��E�&���T�$�s�F�{�+�,�e�i�i���.D�E�*��K�05�y�y�9I�1�/M�'��$�.�.�"<���?��N�N�4�4�)��+�5��/��2��N�N�4�4�)�&,�!<�5��"=�{�!J�M��q� �'3�m�'C�$��-�-��1�#�i�i�
�r�:��&�k�>�B� �O�O�H�b�1�����K�%�"@�"@�@�+�
����0�1��5�(��E�)���&�,�.��*<�8<���8H�8H�$=�t�9"�26���1A�1A�$6�8P�2"�	+�(-�'+��
�$��i� �/�$C�C��y�y��~�%�$�,�,�s�*;�*G� ����c�!2�3�9�9�;��c�
�C��9�9�U��#��H�~�H�'-�d�.?�.?�.D�.D�.F�'G�H�^�$�#�E�%�L��9�9�Z� �(� (�E�*�����L�L�)�*��L�L�)�*��L�L��(�	
����!�\�\�*:�;�N���*�*�5�1����!E�!E�=B�Y�Y�w�PR�=S�E��%��&�!�D�"�h�h�y�$�7�G� $����� 4�I��#�u�'K�'K�K�$�<�<�	�I�FT�%�h�&F�&F�G�"�E�$H�$H��$Q�R�G�	�(�"B�"B�C�"� �+�+��	�	�'�2�&��0D�(E��E�'�N�&�1�#1��	�	�-�(�B��8��2�3�$�E�-� �������)�5�1�*.�,�,�*:�*:�;R�*S�%)�\�\�%5�%5�6H�%I� $��� 0� 0�� ?�	��E��l�l�=�1���#��!��	�	�&�!�]�2��I�,�.�'��t�z�r�:�	�/�� ����7�8��>�>��N�N�4�4�%�W�5���9�9�[�)�%�5�5�7��E�"&�,�,�/H�"I��#�/��!��	�	�&�!�]�2��I��t�D��c�6�k�):�$;�U�Y�Y�w�PR�=S�T�U�L�,�.�3�E�4�:�2�F�	�/�� ����C�D��>�>��N�N�4�4�,�M�5���N�N�4�4�,�&,�!-��!1�5��+�S����w��1K�-L�L����?�t�~�~�'A��N�N�4�4�,�F�[�5���E���M/�.��l/�.��4/�.�s%�;A\�\
�7\�\
�
\�\#c��|jd�}|�y|d}t|d�}|dj�d|��}|jdD]-}t	|t
�r
||k(s||k(s�yt
||�s�-yy)N�exc_infoFrr9�
ignore_errorsT)r�r8r%r�rirm�
issubclass)r�r�r�r�r��error_type_name�error_full_name�
ignored_errors        rg�_is_ignored_errorz_Client._is_ignored_error�s����8�8�J�'���������'����4��%-�a�[�%;�%;�_�M��!�\�\�/�:�M��-��-� �O�3�}��7W���e�]�3��;�ruc��|jd�dk(}|ry|duxr
|j}|ry|j||�}|ryy)Nr]r�TF)r��_should_capturer�)r�r�r�r�r��ignoring_prevents_recursion�ignored_by_config_options       rgr�z_Client._should_capture�sX�����6�*�m�;����&+�4�&7�&U��@U�@U�<U�#�&��#'�#9�#9�%��#F� �#��ruc�0�|jjdd�}t|�rt�5|||�}ddd�n|jd}	dkxrt	j�|k\}|r*|jr|jjdd�
�yy#1swY�UxYw#t
$rt
jd�d}Y�[t$r?t|�rdnd\}}t
jd|�d	|�d
t��d��d}Y��wxYw)Nr`�sample_rater�zMThe provided error_sampler raised an error. Defaulting to sampling the event.F)r`�returned)r��containsz
The provided � z an invalid value of zJ. The value should be a float or a bool. Defaulting to sampling the event.r�r�T)r�r��callabler.�random�	NameErrorr<r�r��reprr�rX)r�r�r�r`r��not_in_sample_rate�	parameter�verbs        rg�_should_sample_errorz_Client._should_sample_error�s��
���(�(��$�?�
��M�"�,�.�+�E�4�8��/�.��,�,�}�5�K�	'�!,�s�!2�!U�v�}�}��+�7U��0��~�~����0�0��g�0�V���K/�.���	'��N�N�_�
�"'���
	'��M�*�.�0�
�I�t�

�N�N��d�D��$5�7�
�"'��
	'�s$�
B �B,� B)�, D�AD�Dc�|�d}d}d}|jd�xsijd�}|rbd}|D][}t|t�r|jxsi}|jd�}t|t�s�E|jd�dus�Yd}n|jd�}	|j
�g|jd�xsijd	�}
t|
t�r|
ni}|j�D]\}}
|j�d
k(s�|
}n|j|rdnd|	||j|xs|z��y)
NFr�r�T�	mechanism�handledr��request�headersz
user-agentr�)rwr��
user_agent�errors)r�rir,r\rr�rpr��lowerr�r�)r��sessionr�r��erroredr��
exceptionsr�r�r�r��headers_dict�kres              rg�_update_session_from_eventz"_Client._update_session_from_events4��
�����
��i�i��,�2��7�7��A�
���G�#���e�^�4�!�K�K�-�2�E�!�I�I�k�2�	��i��1�i�m�m�I�6N�RW�6W�"�G��
$��y�y�� �����%��y�y��+�1�r�6�6�y�A�G�&0��$�&?�7�R�L�$�*�*�,���1��7�7�9��,�!"�J��-�
	��� '�9�T��!��>�>�W�%7��8�		�	
ruc�|�t|xsd�}|j|||�sy|jdd�}|jd�}|�#t	j
�jx|d<}|jdd�}|j|||�}|�y|r|jnd}|r|j||�|jd�dk(}	|jd�d	k(}
|	s|
s|j||�sy|jd
�}|jdi�jd�xsi}|jd
i�}
|dttjtj��d�}|
r|
|d<t!|��}|	r;t#|t$�r+|j'|j)||j*��|	r|s|j-|�n�|	r�t/|�}|�|ds|j-|�n�|\}}||d<|j-|�|D�cgc]}t#|t�rt1||��� }}|j3t5t6j8t6j:dt=|�it?d|d������n%|
r|jA|�n|jC|�|xsdD]!}|j3|jE���#d}|jFr|jFjI|�|}|jJ�|jJjI|�|}|Scc}w)aCaptures an event.

        :param event: A ready-made event that can be directly sent to Sentry.

        :param hint: Contains metadata about the event that can be read from `before_send`, such as the original exception object or a HTTP request object.

        :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events.

        :returns: An event ID. May be `None` if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting `debug=True` on `init()` may help.
        r�N�profile�event_id�_has_gen_ai_spanFr]r��check_in�attachmentsr�r'�dynamic_sampling_context)r��sent_at)r�r�r��
item_countr�)rWr�)rq)r]�content_typer��payload)&rpr�r�r��uuid�uuid4�hexr��_sessionr�r�r2rr�rr�rrir�add_profile�to_jsonr��add_transactionr�r��add_itemrr�TYPE�CONTENT_TYPEr�r�add_checkin�	add_event�to_envelope_itemr�rPr�)r�r�r�r�r�r��span_recorder_has_gen_ai_spanr�r�r��
is_checkinr�r�r�r�rQ�split_spansr�r�r��converted_gen_ai_spans�
attachment�return_values                       rgr�z_Client.capture_event(s�� �D�J�B����#�#�E�4��7���)�)�I�t�,���9�9�Z�(����+/�:�:�<�+;�+;�;�E�*���(-�	�	�2D�e�(L�%��'�'��t�U�;�	����%*�%�.�.�t����+�+�G�U�;�"���v�.�-�?���]�]�6�*�j�8�
����-�-�e�T�:���h�h�}�-��!�
�
�j�"�5�9�9�'�B�H�b�
�#0�#4�#4�5O�QS�#T� �"�*�-�'����X�\�\�(B�C�(
��
$�7�G�G���G�,���j��'�:�� � �����D�L�L�!I�J��"?��$�$�Y�/�
�-�i�8�K��"�+�a�.��(�(��3�1<�.� �,�%5�	�'�"��(�(��3�!-�*� ,��!�$��-�>�d�I�N� ,�'�*��!�!��(�-�-�%0�%=�%=�(�#�.D�*E�!�!+�+,�)?�"�!�
�� �� � ��+����y�)�%�+��+�J����j�9�9�;�<�,����>�>��N�N�+�+�H�5�#�L��>�>�%��N�N�+�+�H�5�#�L����O*s�#L9�	telemetryz*Optional[Union[Log, Metric, StreamedSpan]]rfrNc�
�|�y|j|�d}|dk(rt|j�}|}nG|dk(rt|j�}|}n*|dk(r%t	|j�}|j�}|��|i�}|dvr|��y|dk(r�t
|t�r�t
|t�rSd|vrO|d|_	i|_
|jd�xsij�D]\}}|j||��ntjd�|j�}d}|dk(r
|j }n2|dk(r
|j"}n |dk(r|j$d	<|j&}|�|j)�yy)
z�
        Capture attributes-based telemetry (logs, metrics, streamed spans).

        Apply any attributes set on the scope to it, and run the user's
        before_send_{telemetry} on it, if applicable.
        Nr�r�r�)r�r�rVr�zL[Tracing] Invalid return value from before_send_span. Keeping original span.�
_segment_span)�apply_to_telemetryr3r�r4r5�_to_jsonrir&rprV�_attributesr�r��
set_attributer<r�r�r��_segmentr��add)	r�r�rfr�r��
serializedr�re�batchers	         rg�_capture_telemetryz_Client._capture_telemetry�s������
� � ��+���
��;�-�d�l�l�;�K�"�J�
�8�^�0����>�K�"�J�
�6�\�.�t�|�|�<�K�"�+�+�-�J��"�$�Z��4�J��&�&��%���v��*�Y��"E��j�$�/�F�j�4H�%/��%7�I�N�,.�I�)�!+����!=�!C�� J� J� L���1�!�/�/��1�5�!M��L�L�f��'�/�/�1�
���
��;��&�&�G�
�8�^��*�*�G�
�6�\�+4�*<�*<�J��'��'�'�G����K�K�
�#�ruc�*�|j|d|�y)Nr��rr�s   rgr�z_Client._capture_log�s������U�E�2ruc�*�|j|d|�y)Nr�rr�s   rgr�z_Client._capture_metric�s�������%�8ruc�*�|j|d|�y)Nr�rr�s   rgr�z_Client._capture_span�s������f�e�4ruc�~�|jstjd�y|jj	|�y)Nz3Discarded session update because of missing release)r�r<r�rt�add_session)r�r�s  rgrz_Client.capture_session�s,������K�K�M�N�� � �,�,�W�5rurrc��yrcr�rs  rgrz_Client.get_integration�rruc��yrcr�rs  rgrz_Client.get_integration�r	ruc��t|t�r|}n$|j�
|j}ntd��|jj|�S)z�Returns the integration for this client by name or class.
        If the client does not have that integration then `None` is returned.
        zIntegration has no name)rirm�
identifierrvr�r�)r�r�integration_names   rgrz_Client.get_integrationsP���m�S�)�,��
�
%�
%�
1�,�7�7���6�7�7�� � �$�$�%5�6�6ruc�6�t|jt�S)z(Check if the current transport is async.)rir�r)r�s rg�_has_async_transportz_Client._has_async_transports���$�.�.�*<�=�=ruc�h�td�|j|j|jfD��S)Nc3�$K�|]}|�|���
y�wrcr�)rd�bs  rgrhz$_Client._batchers.<locals>.<genexpr>s����
�P���}�
�P�s�)�tupler�r�r�r�s rg�	_batchersz_Client._batcherss5���
��&�&��(<�(<�d�>O�>O�P�
�
�	
ruc���|jj�|jD]}|j��|jr|jj�yy)z0Kill all client components in the correct order.N)rt�killrr��r�rs  rg�_close_componentsz_Client._close_componentssG�����!�!�#����A�
�F�F�H� ��<�<��L�L����ruc�z�|jj�|jD]}|j��y)zFlush all client components.N)rtrrrs  rg�_flush_componentsz_Client._flush_components&s+�����"�"�$����A�
�G�G�I� ruc��|j�}|j�r(tjdd��|j	�n|j||��|j
�|jj�d|_yy)z�
        Close the client and shut down the transport. Arguments have the same
        semantics as :py:meth:`Client.flush`.
        Nz@close() used with AsyncHttpTransport. Use close_async() instead.r�r���timeout�callback)r�rr�r�rrrr�r�rrs   rgrz
_Client.close,sr���>�>�%��(�(�*��
�
�V� ���&�&�(��
�
�7�X�
�>��"�"�$��N�N���!�!�D�N�&ruc��*K�|j�|j�stjd�y|j	||���d{���|j�|jj
�}|�
|�d{���d|_yy7�C7��w)z�
        Asynchronously close the client and shut down the transport. Arguments have the same
        semantics as :py:meth:`Client.flush_async`.
        NzRclose_async() used with non-async transport, aborting. Please use close() instead.r)r�rr<r�rrr)r�rr�	kill_tasks    rgrz_Client.close_asyncBs������>�>�%��,�,�.����h����"�"�7�X�"�F�F�F��"�"�$����+�+�-�I��$����!�D�N�&�
G�� �s$�A	B�B�5B�B�B�Bc���|j�g|j�rtjdd��y|�|jd}|j�|jj
||��yy)a#
        Wait for the current events to be sent.

        :param timeout: Wait for at most `timeout` seconds. If no `timeout` is provided, the `shutdown_timeout` option value is used.

        :param callback: Is invoked with the number of pending events and the configured timeout.
        Nz@flush() used with AsyncHttpTransport. Use flush_async() instead.r�r��shutdown_timeoutr)r�rr�r�r�rrrs   rgrz
_Client.flushXsm���>�>�%��(�(�*��
�
�V� ������,�,�'9�:���"�"�$��N�N� � ��8� �D�&ruc��K�|j�r|j�stjd�y|�|jd}|j�|jj
||��}|�|�d{���yyy7��w)a2
        Asynchronously wait for the current events to be sent.

        :param timeout: Wait for at most `timeout` seconds. If no `timeout` is provided, the `shutdown_timeout` option value is used.

        :param callback: Is invoked with the number of pending events and the configured timeout.
        NzRflush_async() used with non-async transport, aborting. Please use flush() instead.r#r)r�rr<r�r�rr)r�rr�
flush_tasks    rgrz_Client.flush_asyncqs������>�>�%��,�,�.����h������,�,�'9�:���"�"�$����-�-�g��-�Q�J��%� � � �&�&�!�s�A8B�:B�;Bc��|Srcr�r�s rgrz_Client.__enter__�rruc�$�|j�yrc)rrs    rgrz_Client.__exit__�s���
�
�ruc��K�|S�wrcr�r�s rg�
__aenter__z_Client.__aenter__�s������s�c��@K�|j��d{���y7��wrc)rrs    rg�	__aexit__z_Client.__aexit__�s������� � � �s���r)r�r=)r6r=r�N)rAzSequence[Dict[str, str]]r�N)r�Nrr!)r�rFr�rHr�r�r�zOptional[Event]rc)r�rOr�rFr�N)NN)r�rFr�zOptional[Hint]r�r�r�r )r�z
Optional[Log]r�rNr�N)r�zOptional[Metric]r�rNr�N)r�zOptional[StreamedSpan]r�rNr�N)r�rOr�Nr")rzUnion[str, Type[Integration]]r�r)r�ztuple[Any, ...])rzOptional[float]rz&Optional[Callable[[int, float], None]]r�N)r�r-r#)+r$r%r&r'r�r�r�rMr2rjr�r�r)r�r�r�r�r�r�r�r�rmrr�r�r�rrrrrrrrrrrrrrr)r+�
__classcell__)r3s@rgr-r-�s������)��:�"<�:�	
�:�xG)�R�4��=��=��#��#��E��E�N��N��N�!�	N�

�N�`�w��f����2$(�	�����!�	�

��*-��-��-�
�	-�^#
��#
��#
�
�	#
�P"&�#'�	u��u��u�!�	u�

�u�nG$�?�G$�
�G$��	G$�

�G$�R3�9�5�6��6�
�6��	�U��U�9P�U�
�U�	�Q�
�Q�7�6�7�
!�7� >�d�>��
��
� ��&*�=A�"�"�"�;�"�
�	"�0&*�=A�"�"�"�;�"�
�	"�0&*�=A�E�"�E�;�E�
�	E�6&*�=A�!�"�!�;�!�
�	!�2���!rur-)rc��eZdZy)r1N�r$r%r&r�rurgr1r1����rur1c��eZdZy)�ClientNr.r�rurgr1r1�r/rur1c��tSrc)r�r�rurgr_r_�s��<ruc��tSrc)r-r�rurgr_r_�s��gru)rsr=r�z"Optional[SerializedAttributeValue])r��dict[str, Any]r�rFr�r4)r�rFr�zAOptional[tuple[List[Dict[str, object]], List[Dict[str, object]]]])r�r r�r=r�r�)�rqr�r�r�r�r��collections.abcrrrr�	importlibr�typingrr	r
rr�sentry_sdk._compatr
�sentry_sdk._metrics_batcherr�sentry_sdk._span_batcherr�sentry_sdk.constsrrrrrrr�sentry_sdk.enveloperrr�sentry_sdk.integrationsrr�sentry_sdk.integrations.deduper�sentry_sdk.monitorr�'sentry_sdk.profiler.continuous_profilerr�(sentry_sdk.profiler.transaction_profilerrr r!�sentry_sdk.scrubberr"�sentry_sdk.serializerr#�sentry_sdk.sessionsr$�sentry_sdk.tracesr%r&�sentry_sdk.tracingr'�sentry_sdk.tracing_utilsr(�sentry_sdk.transportr)r*r+�sentry_sdk.utilsr,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrurE�sentry_sdk._typesrFrGrHrIrJrKrLrM�sentry_sdk.scoperN�sentry_sdk.sessionrOrsrPrQrRrSrqrYr(rtr�r�r��ModuleNotFoundErrorr=r��ImportErrorr�r+r-rmr1r1r�rurg�<module>rOs����	�
�
���-�'�#�<�<�9�6�0����;�:�M�<�&�M���
.�+�.�6�$�?���
�����(�N�N�N�2�:����4�&�*�4�.�4�$���;�'�A�� 3�4��
��+��@�A���)��/��/�)�/�dn�
�n�#*�n��n�b*��*�H�*�:Q�h)�0��Z�Z�z	��	�n!�j�n!�b!��
�'��c�3�h��
�
�"�G�
�(�*�K��
 �F��g!�)�(��)�s�G�G'�&G'
Back to Directory File Manager