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

�

_�*j[(���UddlZddlZddlZddlmZddlmZddlmZmZddl	m	Z	m
Z
ddlmZddl
mZddlmZdd	lmZmZddlZdd
lmZddlmZddlmZmZmZmZdd
lmZm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m,Z,ddl-m.Z.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEeryddlFmGZGddlmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSddlTmUZUddlZddlmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcddl-mdZdePd�ZeeRd�ZfeRdeIdeHf��ZgeRd�Zhdaid ejd!<e;d"d�#�Zke;d$d�#�ZlgZmd%ejd&<dand'ejd(<Gd)�d*e�ZoGd+�d,�Zpd=d.�Zq				d>d/�Zrd?d0�Zsd@d1�Ztd-eufd2�ZvdAd3�ZwdBd4�ZxGd5�d6�ZyedCd7��ZzedDd8��Z{edCd9��Z|edEd:��Z}d-eufd;�Z~dd<lm�Z�erddlZyy)F�N)�deque)�contextmanager)�copy�deepcopy)�datetime�timezone)�Enum��wraps)�chain)�
TYPE_CHECKING�cast)�AnnotatedValue)�
Attachment)�DEFAULT_MAX_BREADCRUMBS�FALSE_VALUES�INSTRUMENTER�SPANDATA)�DEFAULT_FLAG_CAPACITY�
FlagBuffer)�get_profiler_id�!try_autostart_continuous_profiler�!try_profile_lifecycle_trace_start)�Profile)�Session)�_DEFAULT_PARENT_SPAN�NoOpStreamedSpan�StreamedSpan)�BAGGAGE_HEADER_NAME�SENTRY_TRACE_HEADER_NAME�NoOpSpan�Span�Transaction)�Baggage�PropagationContext�_make_sampling_decision�has_span_streaming_enabled�has_tracing_enabled�is_ignored_span)�
ContextVar�capture_internal_exception�capture_internal_exceptions�datetime_from_isoformat�disable_capture_event�event_from_exception�exc_info_from_error�format_attribute�has_logs_enabled�has_metrics_enabled�logger)�Mapping)�Any�Callable�Deque�Dict�	Generator�Iterator�List�Optional�	ParamSpec�Tuple�TypeVar�Union)�Unpack)�
Attributes�AttributeValue�
Breadcrumb�BreadcrumbHint�ErrorProcessor�Event�EventProcessor�ExcInfo�Hint�Log�LogLevelStr�Metric�SamplingContext�Type)�TransactionKwargs�P�R�F.)�bound�T�Optional[Scope]�
_global_scope�isolation_scope)�default�
current_scopezList[EventProcessor]�global_event_processorsz1Optional[Callable[[], Optional[Tuple[str, str]]]]� _external_propagation_context_fnc��eZdZdZdZdZdZy)�	ScopeType�current�	isolation�global�mergedN)�__name__�
__module__�__qualname__�CURRENT�	ISOLATION�GLOBAL�MERGED���?/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/scope.pyr_r_�s���G��I�
�F�
�Frlr_c�&�eZdZddd�Zdd�Zdd�Zy)	�
_ScopeManagerNc��g|_y�N)�_old_scopes)�self�hubs  rm�__init__z_ScopeManager.__init__�s
��*,��rlc��tj�}|jj|�|j	�}t
j
|�|Srq)�Scope�get_isolation_scoperr�append�fork�_isolation_scope�set)rsrY�forked_scopes   rm�	__enter__z_ScopeManager.__enter__�sF���3�3�5��������0�&�+�+�-�����\�*��rlc�b�|jj�}tj|�yrq)rr�popr{r|)rs�exc_type�	exc_value�tb�	old_scopes     rm�__exit__z_ScopeManager.__exit__�s$���$�$�(�(�*�	����Y�'rlrq)rt�
Optional[Any]�returnN�r�rw)r�r6r�r6r�r6r�N)rdrerfrur~r�rkrlrmroro�s��-��(rlror�c�.�tj|�yrq)r\ry)�	processors rm�add_global_event_processorr��s���"�"�9�-rlc��|ayrq�r]��fns rm�%register_external_propagation_contextr��s
��(*�$rlc��dayrqr�rkrlrm�#remove_external_propagation_contextr��s��'+�$rlc�&�tr
t�SdSrqr�rkrlrm� get_external_propagation_contextr��s��.N�(�*��TX�rlc��tduSrqr�rkrlrm� has_external_propagation_contextr��s
��+�4�7�7rlc�0�t||j��S)N)�fset�doc)�property�__doc__r�s rm�_attr_setterr��s�������,�,rlc�0��t��d�fd��}|S)Nc�l��|jsy	d|_�|g|��i|��d|_S#d|_wxYw)NFT)�_should_capture)rs�args�kwargsr�s   �rm�wrapperz!_disable_capture.<locals>.wrapper�s?����#�#��	(�#(�D� ��d�,�T�,�V�,�#'�D� ��4�D� �s�*�	3)rsr6r��Dict[str, Any]r�r6r�r6r
)r�r�s` rm�_disable_capturer��s ���
�2�Y�(��(��Nrlc
��eZdZdZdZ		d�					d�d�Zd�d�Zed�d��Zed�d	��Z	ed�d
��Z
ed�d��Zed�d��Zd�d
�Z
ed�d��Z		d�					d�d�Zed�d��Z	d�			d�d�Zd�d�Zd�d�Zd�d�Z	d�			d�d�Zd�d�Zd�d�Zd�d�Zd�d�Zdddddefd �Zd�d!�Z						d�d"�Zd�d#�Ze				d�d%��Zd�d&�Z e!d�d(��Z"d�d)�Z#e!d�d*��Z$e%d�d+��Z&e&jNd�d,��Z&d�d-ed.dddfd/�Z(e!d�d0��Z)d�d1�Z*e%d�d2��Z+e+jNd�d3��Z+e%d�d5��Z,e,jNd�d6��Z,e%d�d7��Z-e-jNd�d8��Z-d9ed'dddfd:�Z.d�d;�Z/d9eddfd<�Z0d9ed'dddfd=�Z1d9eddfd>�Z2d9ed'dddfd?�Z3d9eddfd@�Z4dAeddfdB�Z5d�dC�Z6d�dD�Z7d�dE�Z8					d�dFdGdHddIddJddKe9ddfdL�Z:		d�							d�dM�Z;de<jzdfdNdOdPed$dQddRddSf
dT�Z>e<jzfdPeddddUfdV�Z?d-edWdXdYd4dZe9dd[f
d\�Z@d]eAddfd^�ZB				d�d_dd`dd-dd.ddaeddbfdc�ZC		d�									d�df�ZDd�dg�ZEd�dh�ZFd�di�ZG		d�djedkdlddddedddf
dm�ZH		d�							d�dn�ZId�do�ZJd�dp�ZKd�dq�ZLd�dr�ZM				d�ds�ZN	d�					d�dt�ZO								d�du�ZP								d�dv�ZQ								d�dw�ZR								d�dx�ZS								d�dy�ZT								d�dz�ZU								d�d{�ZV								d�d|�ZW								d�d}�ZX								d�d~�ZY				d�d�ZZ				d�d��Z[d�ddedd�fd��Z\d�d��Z]d�d��Z^e_	d�							d�d���Z`e_d�d���Zad�d��Zb							d�															d�d��Zcdefd��Zde%d�d���Zed�ed'd�ddfd��Zfd�eddfd��Zgy)�rwzaThe scope holds extra information that should be sent with all
    events that belong to it.
    )�_level�_name�_fingerprint�_transaction�_transaction_info�_user�_tags�	_contexts�_extras�_breadcrumbs�_n_breadcrumbs_truncated�_gen_ai_original_message_count�_gen_ai_conversation_id�_event_processors�_error_processorsr��_span�_session�_attachments�_force_auto_session_tracking�_profile�_propagation_context�client�_type�_last_event_id�_flags�_attributesN�tyr�c��||_g|_g|_d|_d|_d|_i|_t�|_|�|j|�|j�|j�}|j|��y)Nr)�
incoming_data)
r�r�r�r�r�r�r��NonRecordingClientr��
set_client�clear�_load_trace_data_from_env�generate_propagation_context)rsr�r��incoming_trace_informations    rmruzScope.__init__�s���
��
�9;���9;���&*��
�DH��!�-.��%�@B��+�6H�6J������O�O�F�#��
�
��%)�%C�%C�%E�"��)�)�8R�)�Srlc��tj|j�}|j|_|j|_|j
|_|j|_|j|_|j|_|jj�|_	|j|_|jj�|_|jj�|_
|jj�|_t|j�|_|j |_|j"j�|_|j$j�|_|j&j�|_|j(|_|j*|_|j,|_|j.|_|j0|_|j2j�|_|j4|_|j6|_t9|j:�|_|j<j�|_|j>|_|S)zs
        Returns a copy of this scope.
        This also creates a copy of all referenced data structures.
        ) �object�__new__�	__class__r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�)rs�rvs  rm�__copy__zScope.__copy__s���
�n�n�T�^�^�4���:�:����K�K��	��K�K��	��:�:����+�+����+�+���#�5�5�:�:�<����:�:����:�:�?�?�$����~�~�*�*�,����\�\�&�&�(��
��t�0�0�1���&*�&C�&C��#�,0�,O�,O�,T�,T�,V��)�#�5�5�:�:�<���#�5�5�:�:�<���"&�";�";���!�1�1����:�:����m�m���*.�*K�*K��'��+�+�0�0�2����m�m��� �/�/����T�[�[�)��	��)�)�.�.�0���%)�%A�%A��"��	rlc��tj�}|�/ttj��}tj|�|S)zM
        .. versionadded:: 2.0.0

        Returns the current scope.
        �r�)�_current_scope�getrwr_rgr|)�clsr[s  rm�get_current_scopezScope.get_current_scope;s<��'�*�*�,�
�� �!�Y�%6�%6�7�M����}�-��rlc�.�tj|�y)z�
        .. versionadded:: 2.0.0

        Sets the given scope as the new current scope overwriting the existing current scope.
        :param new_current_scope: The scope to set as the new current scope.
        N)r�r|)r��new_current_scopes  rm�set_current_scopezScope.set_current_scopeIs��	���,�-rlc��tj�}|�/ttj��}tj|�|S)zO
        .. versionadded:: 2.0.0

        Returns the isolation scope.
        r�)r{r�rwr_rhr|)r�rYs  rmrxzScope.get_isolation_scopeSs<��+�.�.�0���"�#�y�':�':�;�O�� � ��1��rlc�.�tj|�y)z�
        .. versionadded:: 2.0.0

        Sets the given scope as the new isolation scope overwriting the existing isolation scope.
        :param new_isolation_scope: The scope to set as the new isolation scope.
        N)r{r|)r��new_isolation_scopes  rm�set_isolation_scopezScope.set_isolation_scopeas��	���0�1rlc�N�t�ttj��atS)zL
        .. versionadded:: 2.0.0

        Returns the global scope.
        r�)rXrwr_ri�r�s rm�get_global_scopezScope.get_global_scopeks ��� �!�Y�%5�%5�6�M��rlc��ddlm}|jtj|d�|jtj
|d�t
j�j}|jd�}|r |jtj|�|jd�}|r |jtj|�|jd�}|r!|jtj|�yy)Nr)�SDK_INFO�name�version�server_name�environment�release)
�sentry_sdk.clientr��
set_attributer�SENTRY_SDK_NAME�SENTRY_SDK_VERSION�
sentry_sdk�
get_client�optionsr��SERVER_ADDRESS�SENTRY_ENVIRONMENT�SENTRY_RELEASE)rsr�r�r�r�r�s      rm�set_global_attributeszScope.set_global_attributesxs���.����8�3�3�X�f�5E�F����8�6�6���8K�L��'�'�)�1�1���k�k�-�0������x�6�6��D��k�k�-�0������x�:�:�K�H��+�+�i�(������x�6�6��@�rl�
Optional[str]c�6�|j�jS)a�
        .. versionadded:: 2.2.0

        Returns event ID of the event most recently captured by the isolation scope, or None if no event
        has been captured. We do not consider events that are dropped, e.g. by a before_send hook.
        Transactions also are not considered events in this context.

        The event corresponding to the returned event ID is NOT guaranteed to actually be sent to Sentry;
        whether the event is sent depends on the transport. The event could be sent later or not at all.
        Even a sent event could fail to arrive in Sentry due to network issues, exhausted quotas, or
        various other reasons.
        )rxr�r�s rm�
last_event_idzScope.last_event_id�s���&�&�(�7�7�7rlrWc���|r
|rtd��t�tt�n	t�}tj
|_tj�}|�|j|�tj�}|�|j|�||k7r||k7r|j|�|�(t|�r
||�|S|j|�|S|r|jdi|��|S)z�
        Merges global, isolation and current scope into a new scope and
        adds the given additional scope or additional scope kwargs to it.
        zcannot provide scope and kwargsrk)
�	TypeErrorrXrrwr_rjr�r{r��update_from_scoper��callable�update_from_kwargs)rs�additional_scope�additional_scope_kwargs�final_scoperYr[s      rm�
_merge_scopeszScope._merge_scopes�s���� 7��=�>�>�-:�-F�d�=�)�E�G��%�,�,���*�.�.�0���&��)�)�/�:�&�*�*�,�
��$��)�)�-�8��=� �T�_�%<��)�)�$�/��'��(�)� ��-����-�-�.>�?�
��%�*�K�*�*�E�-D�E��rlc��tj�}	|j}|�|j	�r|St
j�}	|j}|�|j	�r|S	tj}|�|j	�r|St�S#t$rd}Y��wxYw#t$rd}Y�awxYw#t$rd}Y�MwxYw)a,
        .. versionadded:: 2.0.0

        Returns the currently used :py:class:`sentry_sdk.Client`.
        This checks the current scope, the isolation scope and the global scope for a client.
        If no client is available a :py:class:`sentry_sdk.client.NonRecordingClient` is returned.
        N)r�r�r��AttributeError�	is_activer{rXr�)r�r[r�rYs    rmr�zScope.get_client�s���'�*�*�,�
�	�"�)�)�F���&�"2�"2�"4��M�*�.�.�0��	�$�+�+�F���&�"2�"2�"4��M�	�"�)�)�F���&�"2�"2�"4��M�!�#�#��/�	��F�	���	��F�	���	��F�	�s5�B�B+�,B<�B(�'B(�+B9�8B9�<C
�	C
c�z�|�*||_tj�j�yt	�|_y)z�
        .. versionadded:: 2.0.0

        Sets the client for this scope.

        :param client: The client to use in this scope.
            If `None` the client of the scope will be replaced by a :py:class:`sentry_sdk.NonRecordingClient`.

        N)r�r�r�r�r�)rsr�s  rmr�zScope.set_client�s2���� �D�K�
�'�'�)�?�?�A�,�.�D�Krlc��t|�}|S)zP
        .. versionadded:: 2.0.0

        Returns a fork of this scope.
        )r)rsr}s  rmrzz
Scope.fork�s���D�z���rlc��d}tjjd�xsdj�}|tv}|r�i}tjjd�r*tjjd�xsd|t
<tjjd�r*tjjd�xsd|t<|xsdS)z�
        Load Sentry trace id and baggage from environment variables.
        Can be disabled by setting SENTRY_USE_ENVIRONMENT to "false".
        N�SENTRY_USE_ENVIRONMENT��SENTRY_TRACE�SENTRY_BAGGAGE)�os�environr��lowerrr r)rsr��sentry_use_environment�use_environments    rmr�zScope._load_trace_data_from_envs���
BF�"�
�J�J�N�N�3�4�:��
�%�'�	�1��D���)+�&��z�z�~�~�n�-��J�J�N�N�>�2�8�b�+�+C�D��z�z�~�~�.�/��J�J�N�N�#3�4�:��+�+>�?�*�1�T�1rlc�"�t�|_y)zt
        Creates a new propagation context and sets it as `_propagation_context`. Overwriting existing one.
        N)r%r��rss rm�set_new_propagation_contextz!Scope.set_new_propagation_contexts��%7�$8��!rlc��|�tj|�|_|jtj
k7r|j�|j
�yyy)a
        Makes sure the propagation context is set on the scope.
        If there is `incoming_data` overwrite existing propagation context.
        If there is no `incoming_data` create new propagation context, but do NOT overwrite if already existing.
        N)r%�from_incoming_datar�r�r_rgr)rsr�s  rmr�z"Scope.generate_propagation_context$sV���$�(:�(M�(M��)�D�%�
�:�:��*�*�*��(�(�0��0�0�2�1�+rlc�H�|j�y|jjS)z�
        Returns the Dynamic Sampling Context from the Propagation Context.
        If not existing, creates a new one.

        Deprecated: Logic moved to PropagationContext, don't use directly.
        N)r��dynamic_sampling_contextr
s rm�get_dynamic_sampling_contextz"Scope.get_dynamic_sampling_context6s%���$�$�,���(�(�A�A�Arlr�r6r�c��|j�}t|j�s|j�j	�St|j�}|r5t
|j�tur|jj�S|s&|j�|jj�S|j�j	�S)z�
        Returns the Sentry "sentry-trace" header (aka the traceparent) from the
        currently active span or the scopes Propagation Context.
        )r�r(r��get_active_propagation_context�to_traceparentr'�type�
streamed_spanr�_to_traceparent�span�rsr�r�r��span_streamings     rm�get_traceparentzScope.get_traceparentBs���
���"��"�6�>�>�2��6�6�8�G�G�I�I�3�F�N�N�C���d�4�#5�#5�6�,�F��%�%�5�5�7�7��D�I�I�$9��9�9�,�,�.�.��2�2�4�C�C�E�Erlc��|j�}t|j�s|j�j	�St|j�}|r5t
|j�tur|jj�S|s&|j�|jj�S|j�j	�S)z�
        Returns the Sentry "baggage" header containing trace information from the
        currently active span or the scopes Propagation Context.
        )r�r(r�r�get_baggager'rrr�_to_baggagerrs     rmrzScope.get_baggageVs���
���"��"�6�>�>�2��6�6�8�D�D�F�F�3�F�N�N�C���d�4�#5�#5�6�,�F��%�%�1�1�3�3��D�I�I�$9��9�9�(�(�*�*��2�2�4�@�@�B�Brlr�c�r�t|j�j�r@|j�4t	|jt
�s|jj
�St�}|r
|\}}||d�S|j�}|j|j|j|jd�S)zR
        Returns the Sentry "trace" context from the Propagation Context.
        )�trace_id�span_id)r"r#�parent_span_idr)
r(r�r�r��
isinstancer�_get_trace_contextr�rr"r#r$r)rs�external_propagation_contextr"r#�propagation_contexts     rm�get_trace_contextzScope.get_trace_contextjs���

 ���� 1� 9� 9�:��
�
�&��t�z�z�+;�<��:�:�0�0�2�2�(H�'I�$�'� <��H�g� (�W�=�=�"�A�A�C��,�4�4�*�2�2�1�@�@�(;�(T�(T�	
�	
rlc��|jdd�}|�tjd�d}|j�D]\}}|d|�d|�d�z
}�|S)z�
        Return meta tags which should be injected into HTML templates
        to allow propagation of trace information.
        rNzaThe parameter `span` in trace_propagation_meta() is deprecated and will be removed in the future.rz<meta name="z" content="z">)r�r4�warning�iter_trace_propagation_headers)rsr�r�r�metar��contents       rm�trace_propagation_metazScope.trace_propagation_meta�sh��
�z�z�&�$�'�����N�N�s�
���!�@�@�B�M�D�'��l�4�&��G�9�B�?�?�D�C��rlc#�nK�|j�#|jj�Ed{���yy7��w)z�
        Creates a generator which returns the `sentry-trace` and `baggage` headers from the Propagation Context.
        Deprecated: use PropagationContext.iter_headers instead.
        N)r��iter_headersr
s rmr1zScope.iter_headers�s4����
�$�$�0��0�0�=�=�?�?�?�1�?�s�*5�3�5c/�K�|j�}|jjd�stjdt
d��y|j
dd�}|s/t|j�}|r|jn|j}t|j�r,|�*t|t�s|j�D]}|���yt�ry|j�j!�D]}|���y�w)z�
        Return HTTP headers which allow propagation of trace data.

        If a span is given, the trace data will taken from the span.
        If no span is given, the trace data is taken from the scope.
        �propagate_tracesz_The `propagate_traces` parameter is deprecated. Please use `trace_propagation_targets` instead.���
stacklevelNr)r�r�r��warnings�warn�DeprecationWarningr�r'rrr(r%r�
_iter_headersr�rr1)rsr�r�r�rr�headers       rmr,z$Scope.iter_trace_propagation_headers�s��������"���~�~�!�!�"4�5��M�M�q�"��
�

��z�z�&�$�'���7����G�N�)7�4�%�%�T�Y�Y�D�
 ����/�� ��t�%5�6��,�,�.����/�
-�
/�
��=�=�?�L�L�N����O�s�DDc���|j�|jS|j�}|j�|jS|j�}|j�t�|_|jSrq)r�r�rxr%)rsr[rYs   rmrz$Scope.get_active_propagation_context�sq���$�$�0��,�,�,��.�.�0�
��-�-�9� �5�5�5��2�2�4���/�/�7�3E�3G�O�0��3�3�3rl�custom_sampling_contextc�^�|j�j�j|�yrq)r�r�_set_custom_sampling_context)r�r=s  rm�set_custom_sampling_contextz!Scope.set_custom_sampling_context�s'��	����>�>�@�]�]�#�	
rlc�.�d|_d|_d|_i|_d|_i|_i|_i|_g|_|j�d|_
d|_d|_d|_
d|_d|_d|_d|_i|_d|_y)zClears the entire scope.NT)r�r�r�r�r�r�r�r�r��clear_breadcrumbsr�r�r�r�r�r�r�r�r�r�r
s rmr�zScope.clear�s���/3���37���-1���35���15��
�')��
�68���)+���02������ �%)���<@��
�-1��
�>B��)�-1��
�$(��!�04���.2���)+���8<��$rl�valuec�<�tjd�||_y)z�
        When set this overrides the level.

        .. deprecated:: 1.0.0
            Use :func:`set_level` instead.

        :param value: The level to set.
        zIDeprecated: use .set_level() instead. This will be removed in the future.N)r4r+r��rsrCs  rm�levelzScope.level�s��	���W�	
���rlc��||_y)zX
        Sets the level for the scope.

        :param value: The level to set.
        N�r�rEs  rm�	set_levelzScope.set_level
s����rlc��||_y)z0When set this overrides the default fingerprint.N)r�rEs  rm�fingerprintzScope.fingerprints��"��rlc���|j�yt|jt�rtjdt
d��y|jj�y|jjS)z8Return the transaction (root span) in the scope, if any.N�5Scope.transaction is not available in streaming mode.r4r5)r�r%rr7r8r9�containing_transactionr
s rm�transactionzScope.transactions`���:�:����d�j�j�,�/��M�M�G�"��
�
��:�:�,�,�4���z�z�0�0�0rlc�(�tjd�||_|jrjt	|jt
�rt
jdtd��y|jjr||jj_
yyy)zrWhen set this forces a specific transaction name to be set.

        Deprecated: use set_transaction_name instead.z`Assigning to scope.transaction directly is deprecated: use scope.set_transaction_name() instead.rMr4r5N)r4r+r�r�r%rr7r8r9rNr�rEs  rmrOzScope.transaction0su��"	���n�	
�"����:�:��$�*�*�l�3��
�
�K�&� ��
��z�z�0�0�9>��
�
�1�1�6�1�rlr��sourcec���||_|jr�t|jt�ryt|jt�rO||jj
_|r�|jj
jdt|d|��nN|jjr8||jj_|r||jj_
|r||jd<yy)z?Set the transaction name and optionally the transaction source.N�sentry.span.sourcerCrQ)r�r�r%rr�_segmentr�r��getattrrNrQr�)rsr�rQs   rm�set_transaction_namezScope.set_transaction_nameQs��� ����:�:��$�*�*�&6�7���D�J�J��5�+/��
�
�#�#�(���J�J�'�'�5�5�,�g�f�g�v�.N�����2�2�9=��
�
�1�1�6��?E�D�J�J�5�5�<��/5�D�"�"�8�,�rlc�^�tjdtd��|j|�y)zPWhen set a specific user is bound to the scope. Deprecated in favor of set_user.zEThe `Scope.user` setter is deprecated in favor of `Scope.set_user()`.r4r5N)r7r8r9�set_userrEs  rm�userz
Scope.usergs'��	�
�
�S���	
�
	
�
�
�e�rlc�p�||_|j�j}|�|j|��yy)zSets a user for the scope.N)rY)r�rxr��update)rsrC�sessions   rmrXzScope.set_userqs6����
��*�*�,�5�5�����N�N��N�&�rlc�R�t|jt�r|jSdS)z,Get/set current tracing span or transaction.N)r%r�r"r
s rmrz
Scope.spanxs ��(��
�
�D�9�t�z�z�C�t�Crlc��||_t|t�rG|}|jr8|j|_|j
r|j
|jd<yyyy)NrQ)r�r%r#r�r�rQr�)rsrrOs   rmrz
Scope.span}s_����
��d�K�(��K����$/�$4�$4��!��%�%�7B�7I�7I�D�*�*�8�4�&� �)rl�Optional[StreamedSpan]c�R�t|jt�r|jSdS)zGet/set current tracing span.N)r%r�rr
s rmrzScope.streamed_span�s ��(��
�
�L�A�t�z�z�K�t�Krlc��||_t|�turd|j�rS|j|_|jjd�r&t|jd�|jd<yyyy)NrSrQ)
r�rr�_is_segmentr�r�r�r��strr�)rsrs  rmrzScope.streamed_span�st����
���:��%�$�*:�*:�*<� $�	�	�D�����#�#�$8�9�36��$�$�%9�:�4��&�&�x�0�:�+=�%rlc��|jSrq�r�r
s rm�profilez
Scope.profile�s���}�}�rlc��||_yrqre)rsrfs  rmrfz
Scope.profile�s	����
rl�keyc�"�||j|<y)z�
        Sets a tag for a key to a specific value.

        :param key: Key of the tag to set.

        :param value: Value of the tag to set.
        N)r��rsrhrCs   rm�set_tagz
Scope.set_tag�s�� ��
�
�3�rlc�:�|jj|�y)a�Sets multiple tags at once.

        This method updates multiple tags at once. The tags are passed as a dictionary
        or other mapping type.

        Calling this method is equivalent to calling `set_tag` on each key-value pair
        in the mapping. If a tag key already exists in the scope, its value will be
        updated. If the tag key does not exist in the scope, the key-value pair will
        be added to the scope.

        This method only modifies tag keys in the `tags` mapping passed to the method.
        `scope.set_tags({})` is, therefore, a no-op.

        :param tags: A mapping of tag keys to tag values to set.
        N)r�r[)rs�tagss  rm�set_tagszScope.set_tags�s�� 	
�
�
���$�rlc�<�|jj|d�y)zX
        Removes a specific tag.

        :param key: Key of the tag to remove.
        N)r�r��rsrhs  rm�
remove_tagzScope.remove_tag�s��	
�
�
���s�D�!rlc�"�||j|<y)zG
        Binds a context at a certain key to a specific value.
        N)r�rjs   rm�set_contextzScope.set_context�s��$����s�rlc�<�|jj|d�y)zRemoves a context.N)r�r�rps  rm�remove_contextzScope.remove_context�s��
	
�����3��%rlc�"�||j|<y)z&Sets an extra key to a specific value.N)r�rjs   rm�	set_extrazScope.set_extra�s��"����S�rlc�<�|jj|d�y)zRemoves a specific extra key.N)r�r�rps  rm�remove_extrazScope.remove_extra�s��
	
������d�#rl�conversation_idc��||_y)zy
        Sets the conversation ID for gen_ai spans.

        :param conversation_id: The conversation ID to set.
        N�r�)rsrzs  rm�set_conversation_idzScope.set_conversation_id�s��(7��$rlc��|jS)zx
        Gets the conversation ID for gen_ai spans.

        :returns: The conversation ID, or None if not set.
        r|r
s rm�get_conversation_idzScope.get_conversation_id�s���+�+�+rlc��d|_y)zRemoves the conversation ID.Nr|r
s rm�remove_conversation_idzScope.remove_conversation_id�s
��'+��$rlc�0�t�|_d|_y)zClears breadcrumb buffer.rN)rr�r�r
s rmrBzScope.clear_breadcrumbs�s��16����()��%rl�bytesz'Union[None, bytes, Callable[[], bytes]]�filename�path�content_type�add_to_transactionsc	�V�|jjt|||||���y)z�Adds an attachment to future events sent from this scope.

        The parameters are the same as for the :py:class:`sentry_sdk.attachments.Attachment` constructor.
        )r�r�r�r�r�N)r�ryr)rsr�r�r�r�r�s      rm�add_attachmentzScope.add_attachments/��	
��� � ����!�)�$7�
�	
rlc�*�|j�}|j�stjd�y|jjd�}|jjdt�}t|xsd�}|j|�|syt|xsd�}|jd��&tjtj�|d<|jd��d|d<|�
|||�}n|}|�|jj|�ntjd	|�t|j�|kDrI|jj!�|xj"d
z
c_t|j�|kDr�Hyy)a
        Adds a breadcrumb.

        :param crumb: Dictionary with the data as the sentry v7/v8 protocol expects.

        :param hint: An optional value that can be used by `before_breadcrumb`
            to customize the breadcrumbs that are emitted.
        z*Dropped breadcrumb because no client boundN�before_breadcrumb�max_breadcrumbsrk�	timestamprrZz)before breadcrumb dropped breadcrumb (%s)�)r�r�r4�infor�r�r�dictr[r�nowr�utcr�ry�len�popleftr�)rs�crumb�hintr�r�r�r��	new_crumbs        rm�add_breadcrumbzScope.add_breadcrumbsQ�����"�����!��K�K�D�E��"�N�N�.�.�/B�C�� �.�.�,�,�->�@W�X���U�[�b�!��
���V�����D�J�B����9�9�[�!�)�!)���h�l�l�!;�E�+���9�9�V��$�%�E�&�M��(�)�%��6�I��I�� ����$�$�Y�/��K�K�C�U�K��$�#�#�$��6����%�%�'��)�)�Q�.�)��$�#�#�$��6rlrOzOptional[Transaction]�instrumenterzOptional[SamplingContext]zUnpack[TransactionKwargs]zUnion[Transaction, NoOpSpan]c��|jd|�|j�}|jd}||k7r
t�St	�|xsi}|}|�td
i|��}|j
�|jd�}|j|�|j|��|j�x|j�}	|	j}
|
�"t|j�|
jd<|jr,t|j�|jjd<|j r�t#|j |j$�}|j|��||_t)�|_|j*�|j-t/��|jdj1d�xsd}|j3|�	�|S)a�
        Start and return a transaction.

        Start an existing transaction if given, otherwise create and start a new
        transaction with kwargs.

        This is the entry point to manual tracing instrumentation.

        A tree structure can be built by adding child spans to the transaction,
        and child spans to other spans. To start a new child span within the
        transaction or any span, call the respective `.start_child()` method.

        Every child span must be finished before the transaction is finished,
        otherwise the unfinished spans are discarded.

        When used as context managers, spans and transactions are automatically
        finished at the end of the `with` block. If not using context managers,
        call the `.finish()` method.

        When the transaction is finished, it will be sent to Sentry with all its
        finished child spans.

        :param transaction: The transaction to start. If omitted, we create and
            start a new transaction.
        :param instrumenter: This parameter is meant for internal use only. It
            will be removed in the next major version.
        :param custom_sampling_context: The transaction's custom sampling context.
        :param kwargs: Optional keyword arguments to be passed to the Transaction
            constructor. See :py:class:`sentry_sdk.tracing.Transaction` for
            available arguments.
        �scoper�)�transaction_context�parent_sampled)�sampling_context�sample_rate�_experiments�	max_spansi�)�maxlenrk)�
setdefaultr�r�r!rr#�to_jsonr�r[�_set_initial_sampling_decisionr�r�baggagerc�sentry_items�_baggage�sampledr�_start_timestamp_monotonic_nsr�r�_continuous_profile�set_profiler_idrr��init_span_recorder)
rsrOr�r=r�r��configuration_instrumenter�transaction_kwargsr�r(r�rfr�s
             rm�start_transactionzScope.start_transactionGs���L	���'�4�(����"��%+�^�^�N�%C�"��5�5��:��)�+�"9�"?�R��39����%�;�(:�;�K�
$/�#6�#6�#8�)�8�8�
��	��� 7�8��2�2�DT�2�U��"�"�.�"&�"E�"E�"G��)�1�1�G��"�69�+�:Q�:Q�6R��$�$�]�3��#�#�CF��+�+�D��$�$�1�1�-�@������#�#�[�%N�%N��G�
�2�2�DT�2�U�#*�K� �.O�.Q�K�+�
�.�.�:��+�+�O�,=�>� ����7�;�;�K�H�Q�T�I��*�*�)�*�<��rlr"c���tj�}t|j�r&t	j
dtd��t�S|jd��t	j
dtd��t�5|jd|�|j�}|jd}||k7rt�cddd�S|jxs|j�j}t|t�rt�cddd�S|�/d	|vr|j�}|j |d	<t#d
i|��}n|j$d
i|��}|cddd�S#1swYyxYw)aO
        Start a span whose parent is the currently active span or transaction, if any.

        The return value is a :py:class:`sentry_sdk.tracing.Span` instance,
        typically used as a context manager to start and stop timing in a `with`
        block.

        Only spans contained in a transaction are sent to Sentry. Most
        integrations start a transaction at the appropriate time, for example
        for every incoming HTTP request. Use
        :py:meth:`sentry_sdk.start_transaction` to start a new transaction when
        one is not already in progress.

        For supported `**kwargs` see :py:class:`sentry_sdk.tracing.Span`.

        The instrumenter parameter is deprecated for user code, and it will
        be removed in the next major version. Going forward, it should only
        be used by the SDK itself.
        z4Scope.start_span is not available in streaming mode.r4r5�descriptionNzEThe `description` parameter is deprecated. Please use `name` instead.r�r�r"rk)r�r�r'r�r7r8r9r!r��	new_scoper�rrxr%rrr"r"�start_child)rsr�r�r�r�rr(s       rm�
start_spanzScope.start_span�s:��,�&�&�(��%�f�n�n�5��M�M�F�"��
�
�:���:�:�m�$�0��M�M�W�"��
��[����g�t�,��_�_�&�F�)/����)G�&��9�9��z��[��9�9�?�� 8� 8� :� ?� ?�D��$��-��z��[� �|��V�+�*.�*M�*M�*O�'�)<�)E�)E�F�:�&��~�f�~��(�t�'�'�1�&�1���7�[�[�s�AE*�AE*�AE*�*E3�
attributes�Optional[Attributes]�parent_span�activerc
�(�t|t�rtjd�|tust|t�r|j
}|��|j
�}t||�r
t|d��St|||�\}}}}	|�|j|�|dur
t||	��St||||d|j|j|j|j||��St�5t||�rtd��cddd�St|t�rt|j ��cddd�St|||||j"|j|j$|j&��cddd�S#1swYyxYw)NzYIgnored parent span provided. Span will be parented to the currently active span instead.�ignored)r��unsampled_reasonF)r�r�r�r��segmentr"r$r�r��sample_randr�)r�)r�r�r�r�r�r"r$r�)r%rr4�debugrrrr)r&�_update_sample_raterr"r$r�r�r��_unsampled_reasonrTr#r�)
rsr�r�r�r�r(r�r�r��outcomes
          rm�start_streamed_spanzScope.start_streamed_span�s����k�#3�4��L�L�1�
�
�.�.�*��)�3
��,�,�K���"&�"E�"E�"G���t�Z�0�'��%.���
:Q����:�6�G�[�+�w��&��(�(��5��%��'��%,���
 ��%����,�5�5�2�A�A�2�A�A�+�3�3�'�'��
��[��t�Z�0�'�%.���[��+�'7�8�'��9V�9V�W��[� ��%���#�,�,�$�-�-�*�2�2�*�2�2�	��[�[�s�3F�%F�:F�Fr�c�r�|j�}|j}|�t|�|jd<yy)Nr�)rr�rcr�)rsr�r(r�s    rmr�zScope._update_sample_rateCs>��#�A�A�C��%�-�-����25�k�2B�G� � ��/�rl�environ_or_headers�op�originr#c���|j|�tt|j�}i}|r||d<|r||d<t	d|||j
|j|j|jdd�|��S)ze
        Sets the propagation context from environment or headers and returns a transaction.
        r�rQF)r�r�r�r�r"r$�same_process_as_parentrk)	r�rr%r�r#r�r�r"r$)rsr�r�r�rQr�r(�optional_kwargss        rm�continue_tracezScope.continue_traceLs���	
�)�)�*<�=�#�#5�t�7P�7P�Q�����&*�O�F�#��(.�O�H�%��	
���'�/�/�.�=�=�(�1�1�.�=�=�#(�	
��	
�		
rlr��scope_kwargsc���tjd�ry|j||�}|j�j	|||��}|�)|jd�dk7r||j�_|S)a}
        Captures an event.

        Merges given scope data and calls :py:meth:`sentry_sdk.client._Client.capture_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.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :param scope_kwargs: Optional data to apply to event.
            For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`).
        FN)�eventr�r�rrO)r.r�r�r��
capture_eventrxr�)rsr�r�r�r��event_ids      rmr�zScope.capture_eventmsr��2!�$�$�U�+���"�"�5�,�7���?�?�$�2�2��T�QV�2�W����E�I�I�f�$5��$F�8@�D�$�$�&�5��rlc�J�|�y|j�}t|j�sy|j�}|jj	dd�}|r9tjd|j	d��d|j	d����|j||��y)Nr�Fz[Sentry Logs] [�
severity_text�] �body�r�)r�r2r�r�r�r4r��_capture_log)rs�logr��merged_scoper�s     rmr�zScope._capture_log�s����;�����"������/���)�)�+�����"�"�7�E�2����L�L�!�#�'�'�/�":�!;�2�c�g�g�f�o�=N�O�
�	���C�|��4rlc
�n�|�y|j�}t|j�sy|j�}|jj	dd�}|rKtjd|j	d��d|j	d��d|j	d����|j||�	�y)
Nr�Fz[Sentry Metrics] [rr�r�z: rCr�)r�r3r�r�r�r4r��_capture_metric)rs�metricr�r�r�s     rmr�zScope._capture_metric�s����>�����"��"�6�>�>�2���)�)�+�����"�"�7�E�2����L�L�$�V�Z�Z��%7�$8��6�:�:�f�;M�:N�b�QW�Q[�Q[�\c�Qd�Pe�f�
�	���v�\��:rlc��|�y|j�}t|j�sy|j�}|j	||��y)Nr�)r�r'r�r��
_capture_span)rsrr�r�s    rmr�zScope._capture_span�sF���<�����"��)�&�.�.�9���)�)�+�����T���6rl�messagerF�Optional[LogLevelStr]c�j�tjd�ry|�d}||d�}|j|fd|i|��S)a�
        Captures a message.

        :param message: The string to send as the message.

        :param level: If no level is provided, the default level is `info`.

        :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :param scope_kwargs: Optional data to apply to event.
            For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`).
        FNr�)r�rFr�)r.r�r�)rsr�rFr�r�r�s      rm�capture_messagezScope.capture_message�sM��.!�$�$�U�+���=��E���
��
"�t�!�!�%�E�u�E��E�Erlc�H�tjd�ry|�t|�}ntj�}t||j
�j��\}}	|j|f||d�|��S#t$r ttj��YywxYw)a�Captures an exception.

        :param error: An exception to capture. If `None`, `sys.exc_info()` will be used.

        :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :param scope_kwargs: Optional data to apply to event.
            For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.

        :returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`).
        FN)�client_options)r�r�)r.r�r0�sys�exc_infor/r�r�r��	Exceptionr+)rs�errorr�r�r�r�r�s       rm�capture_exceptionzScope.capture_exception�s���&!�$�$�U�+����*�5�1�H��|�|�~�H�*��T�_�_�%6�%>�%>�
���t�	7�%�4�%�%�e�T�$�e�T�|�T�T���	7�&�s�|�|�~�6��	7�s�"A8�8&B!� B!c��|jdd�}|j�|j�}t|jjd�|jjd�|j|��|_y)zStarts a new session.�session_mode�applicationr�r�)r�r�rYr�N)r��end_sessionr�rr�r�r�r�)rsr�r�r�r�s     rm�
start_sessionzScope.start_sessionsd���z�z�.�-�@���������"����N�N�&�&�y�1����*�*�=�9����%�	
��
rlc��|j}d|_|�0|j�|j�j|�yy)z)Ends the current session if there is one.N)r��closer��capture_session)rsr�r�r\s    rmr�zScope.end_sessions;���-�-����
����M�M�O��O�O��-�-�g�6�rlc�2�|j�d|_y)z�Stops automatic session tracking.

        This temporarily session tracking for the current scope when called.
        To resume session tracking call `resume_auto_session_tracking`.
        FN)r�r�)rsr�r�s   rm�stop_auto_session_trackingz Scope.stop_auto_session_tracking"s��	
����,1��)rlc��d|_y)z�Resumes automatic session tracking for the current scope if
        disabled earlier.  This requires that generally automatic session
        tracking is enabled.
        N)r�r
s rm�resume_auto_session_trackingz"Scope.resume_auto_session_tracking+s��
-1��)rlc���t|j�dkDr/tjd|j�|jdd�=|jj	|�y)z}Register a scope local event processor on the scope.

        :param func: This function behaves like `before_send.`
        �zLToo many event processors on scope! Clearing list to free up some memory: %rN)r�r�r4r+ry)rs�funcs  rm�add_event_processorzScope.add_event_processor2sS���t�%�%�&��+��N�N�^��&�&�
��&�&�q�)����%�%�d�+rlc�X���|�|�|�d��fd�}|jj|�y)aRegister a scope local error processor on the scope.

        :param func: A callback that works similar to an event processor but is invoked with the original exception info triple as second argument.

        :param cls: Optionally, only process exceptions of this type.
        Nc�`��	t|d��}|r	�||�S|S#t$rd}Y�wxYw)Nr�F)r%r�)r�r��is_inst�cls_�	real_funcs   ��rmr�z'Scope.add_error_processor.<locals>.funcRsE���$�(��!��d�;�G��$�U�H�5�5����	!�$�#�G�$�s��-�-)r�rHr�rJr��Optional[Event])r�ry)rsr�r�r�r�s   @@rm�add_error_processorzScope.add_error_processorCs/����?��D��I�
�	
���%�%�d�+rlc�<�|j�|j|d<yy)NrFrH�rsr�r�r�s    rm�_apply_level_to_eventzScope._apply_level_to_event]s ���;�;�"�!�[�[�E�'�N�#rlc���|jdi�t|dt�s6|djdg�|ddj|j�	t|dt�sL|ddD]'}t|dt
�s�t
|d�|d<�)|ddjd���yy#t$r!}tjd|��Yd}~yd}~wwxYw)N�breadcrumbs�valuesr�c��|dS)Nr�rk)r�s rm�<lambda>z3Scope._apply_breadcrumbs_to_event.<locals>.<lambda>us	��e�K�&8rl)rhzError when sorting breadcrumbs)r�)r�r%r�extendr�rcr-�sortr�r4r�)rsr�r�r�r��errs      rm�_apply_breadcrumbs_to_eventz!Scope._apply_breadcrumbs_to_eventcs���	�����+��%�
�.��?��-� �+�+�H�b�9��-� ��*�1�1�$�2C�2C�D�	��e�M�2�N�C�"�=�1�(�;�E�!�%��"4�c�:�-D�U�;�EW�-X��k�*�<��m�$�X�.�3�3�8�4��D���	��L�L�9�C�H���	�s�1B=�,B=�=	C'�C"�"C'c�`�|jd��|j�|j|d<yyy)NrY)r�r�rs    rm�_apply_user_to_eventzScope._apply_user_to_event{s2���9�9�V��$����)?� �J�J�E�&�M�*@�$rlc�`�|jd��|j�|j|d<yyy)NrO)r�r�rs    rm� _apply_transaction_name_to_eventz&Scope._apply_transaction_name_to_event��7���9�9�]�#�+��0A�0A�0M�#'�#4�#4�E�-� �1N�+rlc�`�|jd��|j�|j|d<yyy)N�transaction_info)r�r�rs    rm� _apply_transaction_info_to_eventz&Scope._apply_transaction_info_to_event�s9���9�9�'�(�0�T�5K�5K�5W�(,�(>�(>�E�$�%�6X�0rlc�`�|jd��|j�|j|d<yyy)NrK)r�r�rs    rm�_apply_fingerprint_to_eventz!Scope._apply_fingerprint_to_event�rrlc�t�|jr,|jdi�j|j�yy)N�extra)r�r�r[rs    rm�_apply_extra_to_eventzScope._apply_extra_to_event�s/���<�<����W�b�)�0�0����>�rlc�t�|jr,|jdi�j|j�yy)Nrm)r�r�r[rs    rm�_apply_tags_to_eventzScope._apply_tags_to_event�s/���:�:����V�R�(�/�/��
�
�;�rlc���|jr+|jdi�j|j�|jdi�}|jd��|j	�|d<yy)N�contexts�trace)r�r�r[r�r))rsr�r�r�rs     rm�_apply_contexts_to_eventzScope._apply_contexts_to_event�se���>�>����Z��,�3�3�D�N�N�C��#�#�J��3���<�<�� �(� $� 6� 6� 8�H�W��)rlc��|jj�}t|�dkDr4|jdi�jdi�j	d|i�yy)Nrr�flagsr)r r�r�r�r[)rsr�r�r�r s     rm�_apply_flags_to_eventzScope._apply_flags_to_event�sT���
�
��� ���u�:��>����Z��,�7�7���D�K�K��5�!�
�rlc��t|t�r|d}n|j}|jj�D]\}}||vs�|||<�y)Nr�)r%r�r��items)rs�	telemetryr��	attributerCs     rm�$_apply_scope_attributes_to_telemetryz*Scope._apply_scope_attributes_to_telemetry�sS���i��&�"�<�0�J�"�.�.�J� $� 0� 0� 6� 6� 8��I�u��
�*�(-�
�9�%�!9rlc���t|t�r|d}n|j}t�r|j�ydD]+\}}||jvs�||vs�|j|||<�-y)Nr�))zuser.id�id)z	user.name�username)z
user.email�email)r%r�r��should_send_default_piir�)rsr$r��attribute_name�user_attributes     rm�#_apply_user_attributes_to_telemetryz)Scope._apply_user_attributes_to_telemetry�sn���i��&�"�<�0�J�"�.�.�J�&�(�D�J�J�,>��/
�*�N�N�
����+��j�0P�-1�Z�Z��-G�
�>�*�
/
rl�causer�c�2�tjd||�y)Nz%s (%s) dropped event)r4r�)rsr/r�s   rm�_dropzScope._drop�s�����+�R��7�rlc�&�|jd�}|�}t|j�j|j	�j|j�j�}|D]#}|||�}|�|j
|d�cS|}�%|S)zX
        Runs the error processors on the event and returns the modified event.
        r�zerror processor)r�rr�r�rxr�r1)rsr�r�r��error_processors�error_processor�	new_events       rm�run_error_processorszScope.run_error_processors�s����8�8�J�'����$��%�%�'�9�9��(�(�*�<�<��&�&�(�:�:� ��$4��+�E�8�<�	��$��:�:�o�7H�I�I�!��$4��rlc��|jd�}|dk(}|s�tj�}tj�}ttt
xrt
jxsg|xr|jxsg|xr|jxsg�}|D]8}|}	t�5|||�}	ddd�|	�|j|d�cS|	}�:|S#1swY�%xYw)zX
        Runs the event processors on the event and returns the modified event.
        r�check_inNzevent processor)	r�r{r�rr\rXr�r,r1)
rsr�r�r��is_check_inrYr[�event_processors�event_processorr5s
          rm�run_event_processorszScope.run_event_processors�s����Y�Y�v�
���J�&���.�2�2�4�O�*�.�.�0�M�$�'��A�-�"A�"A�G�R��E�O�$E�$E�K���A�-�"A�"A�G�R�	 ��$4��!�	�0�2� /��t� <�I�3��$��:�:�o�7H�I�I�!��
$4���
3�2�s�"
C�C	c��|jd�}|dk(}|dk(}|jd�xsg}|jD]"}|r
|js�|j|��$||d<|j	|||�|r'd|jdi�jdi�i|d<|s�|j
|||�|j|||�|j|||�|j|||�|j|||�|j|||�|j|||�|s(|s&|j|||�|j|||�|j||�}|�y|j!||�}|�y|S)zBApplies the information contained on the scope to the given event.rrOr8�attachmentsrrN)r�r�r�ryrr�rrr
rrrrrr!r6r<)	rsr�r�r�r��is_transactionr9�attachments_to_send�
attachments	         rm�apply_to_eventzScope.apply_to_event
s����Y�Y�v�
���}�,���J�&��
#�h�h�}�5�;����+�+�J�!�Z�%C�%C�#�*�*�:�6�,�2��]���%�%�e�T�7�;����)�)�*�b�9�=�=�g�r�J�!�E�*����&�&�u�d�G�<��,�,�U�D�'�B��%�%�e�T�7�;��1�1�%��w�G��1�1�%��w�G��%�%�e�T�7�;��&�&�u�d�G�<��k��,�,�U�D�'�B��&�&�u�d�G�<��)�)�%��6���=���)�)�%��6���=���rlc��t|t�s�|j�}|jd�}|jd��	|xsd|d<|jd��X|j�4t|jt
�s|jj|d<nt�}|r|\}}|�||d<|j|�|j|�y)Nr"z$00000000-0000-0000-0000-000000000000r#)
r%rr)r�r�rr#r�r&r.)rsr$�
trace_contextr"r'�_r#s       rm�apply_to_telemetryzScope.apply_to_telemetry>s����)�\�2� �2�2�4�M�$�(�(��4�H��}�}�Z�(�0��F� F��*�%��}�}�Y�'�/��:�:�)�*��J�J� 0�3�,0�:�:�+=�+=�I�i�(�3S�3U�0�3�%A�
��7�"�.�3:�I�i�0��1�1�)�<��0�0��;rlc�\�|j�|j|_|j�|j|_|j�|j|_|j�%|jj	|j�|j
�|j
|_|jr%|jj	|j�|jr%|jj	|j�|jr%|jj	|j�|jr%|jj|j�|jr|j|jz|_|jr%|jj	|j�|jr|j|_
|jr|j|_|jr%|jj|j�|j r|j |_|j"r|j"|_|j$r|j$|_|j&rh|j&st)|j&�|_nA|j&j+�D]$}|j&j-|d|d��&|j.r&|j.j	|j.�yy)z+Update the scope with another scope's data.N�flag�result)r�r�r�r�r[r�r�r�r�r�rr�r�r�r�r�r�r�r�r�rr�r|r�)rsr�rHs   rmr�zScope.update_from_scope\sM���<�<�#��,�,�D�K����)� %� 2� 2�D�����)� %� 2� 2�D���"�"�.��"�"�)�)�%�*A�*A�B��;�;�"����D�J��;�;��J�J���e�k�k�*��?�?��N�N�!�!�%�/�/�2��=�=��L�L����
�
�.�������$�$�U�%7�%7�8��)�)��-�-��0N�0N�N�
�)��/�/��/�/�6�6��4�4�
��(�(�+0�+H�+H�D�(��;�;����D�J�������$�$�U�%7�%7�8��>�>�!�N�N�D�M��%�%�(-�(B�(B�D�%��>�>�!�N�N�D�M��<�<��;�;�&�u�|�|�4���!�L�L�,�,�.�D��K�K�O�O�D��L�$�x�.�A�/�������#�#�E�$5�$5�6�rlc�$�|�||_|�||_|�|jj|�|�|jj|�|�|j
j|�|�||_|�|jj|�yy)zUpdate the scope's attributes.N)r�r�r�r[r�r�r�r�)rsrYrF�extrasrrmrKr�s        rmr�zScope.update_from_kwargs�s������D�K����D�J����L�L����'����N�N�!�!�(�+����J�J���d�#��"� +�D���!����#�#�J�/�"rlc	��d|jj�dtt|���d|j�d|j
�d�	S)N�<z id=z name=z type=�>)r�rd�hexr(r�r�r
s rm�__repr__zScope.__repr__�s2���N�N�#�#���4��M��J�J��J�J�	
�	
rlc��|j�E|j�jdjd�xst}t|��|_|jS)Nr��	max_flags)�capacity)r�r�r�r�rr)rsrRs  rmr zScope.flags�sQ���;�;�����!�)�)�.�9�=�=�k�J�)�(�
�%�i�8�D�K��{�{�rlr%rDc�4�t|�|j|<y)z�
        Set an attribute on the scope.

        Any attributes-based telemetry (logs, metrics) captured while this scope
        is active will inherit attributes set on the scope.
        N)r1r�)rsr%rCs   rmr�zScope.set_attribute�s��'7�u�&=�����#rlc�>�	|j|=y#t$rYywxYw)zMRemove an attribute if set on the scope. No-op if there is no such attribute.N)r��KeyError)rsr%s  rm�remove_attributezScope.remove_attribute�s'��	�� � ��+���	��	�s�
�	�)NN)r�zOptional[ScopeType]r�zOptional[sentry_sdk.Client]r�Nr�)r�rwr�N)r�rwr�N�r�N)r�r�)r�rWr��Optional[Dict[str, Any]]r�rw)r�zsentry_sdk.client.BaseClientrq)r�z&Optional[sentry_sdk.client.BaseClient]r�N)r��Optional[Dict[str, str]])r�rZr�N)r�r6r�r6r�r�)r�r6r�r6r�zOptional[Baggage])r�r�)r�zIterator[Tuple[str, str]])r�r6r�r6r�z&Generator[Tuple[str, str], None, None])r�r%)r=zdict[str, Any]r�N)rCrMr�N)rC�Optional[List[str]]r�N)r�r6)rCr6r�N)rCrYr�N)r��Optional[Span])rr\r�N)r�r_)rr_r�N)r��Optional[Profile])rfr]r�N)rmzMapping[str, object]r�N)NNNNF)r�zOptional[Breadcrumb]r�zOptional[BreadcrumbHint]r�r6r�N)NNN�manual)
r�rHr�zOptional[Hint]r�rWr�r6r�r�)r�z
Optional[Log]r�N)r�zOptional[Metric]r�N)r�z'Optional[Union[BaseException, ExcInfo]]r�rWr�r6r�r�)r�r6r�r6r�N)r�rIr�N)r�rGr�zOptional[Type[BaseException]]r�N)r�rHr�rKr�rYr�N)r$z Union[Log, Metric, StreamedSpan]r�N)r�rHr�rKr�r�)r�rHr�rKr�rYr�r�)r�rwr�N)NNNNNNN)rYr�rFr�rKrYrz#Optional[Dict[str, Dict[str, Any]]]rmrZrKr[r�r�r�N)r�r)hrdrerfr��	__slots__rur��classmethodr�r�rxr�r�r�r�r�r�r�rzr�rr�rrrr)rcr/r1r,rr@r�r�rFrIrKr�rO�setterrVrYrXrrrfrkrnrqrsrurwryr}rr�rB�boolr�r�r�SENTRYr�r�r��floatr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrrrrr!r&r.r1r6r<r�rBrFr�r�rPr r�rWrkrlrmrwrw�s3	����I�D%)�04�T�!�T�.�T�
�	T�2+�Z�����.��.������2��2��
��
�A�(�
8��
8�"/3�>B�#�+�#�"<�#�
�	#�J�"$��"$�JBF�/�>�/�	
�/�*�2�49�;?�3�7�3�	
�3�$
B�F�(C�(
�4�E��U��s��$@�$��$�&+�$�	1�$�L4��
�&6�
�	
�
��
�=�@�
��
���"��"��1��1�0���?��?�@6��6�o�6�QU�6�,����'��D��D�
�[�[�	J��	J��L��L����
��
�����
�^�^� �� � �3� �u� �� � �$"�c�"�d�"�$�
�$� �$�
�	$�&�
�&�
�&�"�
�"��"�
�	"�$�
�$�
�$�7�3�7�4�7�,�,�*�<@�$(� $�(,�$)�

�8�
�"�
��	
�
&�
�"�

�
�
�0)-�+/�//�%�//�)�//��	//�

�//�f04�(�/�/�?C�	f�,�f��f�"=�	f�
.�f�
(�
f�R#/�"5�"5�A��A�AF�A�	�A�FO��O�+�O�.�	O�
�O�
�
O�bC�u�C��C�#� $�"&��

�,�
�
�
��	
�
 �
��

�
�
�H"&�#'�	#��#��#�!�	#�
�#�
�
#�J5�$;�$	7�*.�#'�	"F��"F�'�"F�!�	"F�
�"F�
�
"F�L<@�#'�$�8�$�!�$��	$�

�$�L
�7�2�1�,��,�
�,�(04�,��,�-�,�
�	,�4)��)�$*�)�5O�)�	
�)����$*��5O��	
��0'��'�$*�'�5O�'�	
�'�5��5�$*�5�5O�5�	
�5�?��?�$*�?�5O�?�	
�?�5��5�$*�5�5O�5�	
�5�?��?�$*�?�5O�?�	
�?�<��<�$*�<�5O�<�	
�<�
9��
9�$*�
9�5O�
9�	
�
9����$*��5O��	
��.�;�.�	
�.�H�;�H�	
�H�&�5��c��o���*�:�
/3�	1��1��1�,�	1�

�1��1�f�<��<�:/7�f!%�)-�-1�:>�+/�-1�-1�0��0�'�0�+�	0�
8�0�)�
0�+�0�+�0�
�0�4
�#�
�����>�s�>�3C�>��>��#��$�rlrwc#�K�tj�}|j�}tj	|�}	|��	tj|�y#ttf$r ttj��YywxYw#	tj|�w#ttf$r ttj��YwwxYwxYw�w)a
    .. versionadded:: 2.0.0

    Context manager that forks the current scope and runs the wrapped code in it.
    After the wrapped code is executed, the original scope is restored.

    Example Usage:

    .. code-block:: python

        import sentry_sdk

        with sentry_sdk.new_scope() as scope:
            scope.set_tag("color", "green")
            sentry_sdk.capture_message("hello") # will include `color` tag.

        sentry_sdk.capture_message("hello, again") # will NOT include `color` tag.

    N)rwr�rzr�r|�reset�LookupError�
ValueErrorr+r�r�)r[r��tokens   rmr�r��s�����,�+�+�-�M��"�"�$�I����y�)�E�7���	7�� � ��'���Z�(�	7�&�s�|�|�~�6�	7��	7�� � ��'���Z�(�	7�&�s�|�|�~�6�	7�s^�:C�B
�A�C�,B�C�B�C�
C�B"�!C�",C�C�C�C�Cc#�jK�tj|�}	|��	tj|�y#ttf$r tt
j��YywxYw#	tj|�w#ttf$r tt
j��YwwxYwxYw�w)ag
    .. versionadded:: 2.0.0

    Context manager that uses the given `scope` and runs the wrapped code in it.
    After the wrapped code is executed, the original scope is restored.

    Example Usage:
    Suppose the variable `scope` contains a `Scope` object, which is not currently
    the active scope.

    .. code-block:: python

        import sentry_sdk

        with sentry_sdk.use_scope(scope):
            scope.set_tag("color", "green")
            sentry_sdk.capture_message("hello") # will include `color` tag.

        sentry_sdk.capture_message("hello, again") # will NOT include `color` tag.

    N)r�r|rfrgrhr+r�r�)r�ris  rm�	use_scoperk�s�����0
���u�%�E�7���	7�� � ��'���Z�(�	7�&�s�|�|�~�6�	7��	7�� � ��'���Z�(�	7�&�s�|�|�~�6�	7�sZ�B3�A&�4�B3�,A#� B3�"A#�#B3�&B0�(A>�=B0�>,B-�*B0�,B-�-B0�0B3c#�FK�tj�}|j�}tj	|�}tj�}|j�}tj	|�}	|��	tj|�	tj|�y#ttf$r ttj��Y�EwxYw#ttf$r ttj��YywxYw#	tj|�n2#ttf$r ttj��YnwxYw	tj|�w#ttf$r ttj��YwwxYwxYw�w)am
    .. versionadded:: 2.0.0

    Context manager that forks the current isolation scope and runs the wrapped code in it.
    The current scope is also forked to not bleed data into the existing current scope.
    After the wrapped code is executed, the original scopes are restored.

    Example Usage:

    .. code-block:: python

        import sentry_sdk

        with sentry_sdk.isolation_scope() as scope:
            scope.set_tag("color", "green")
            sentry_sdk.capture_message("hello") # will include `color` tag.

        sentry_sdk.capture_message("hello, again") # will NOT include `color` tag.

    N)
rwr�rzr�r|rxr{rfrgrhr+r�r�)r[�forked_current_scope�
current_tokenrYr��isolation_tokens      rmrYrYsG����.�+�+�-�M�(�-�-�/��"�&�&�';�<�M��/�/�1�O�)�.�.�0��&�*�*�+>�?�O�
7�!�!�	7�� � ��/�	7��"�"�?�3��	�Z�(�	7�&�s�|�|�~�6�	7��
�Z�(�	7�&�s�|�|�~�6�	7��	7�� � ��/���Z�(�	7�&�s�|�|�~�6�	7��	7��"�"�?�3���Z�(�	7�&�s�|�|�~�6�	7�s��A3F!�6D�;B'�C�&F!�',C�F!�C�F!�,D�F!�D�F!�F�
D#�"F�#,E�F�E�F�E,�+F�,,F�F�F�F�F!c#�K�tj�}|j�}tj	|�}t
j	|�}	|��	tj
|�	t
j
|�y#ttf$r ttj��Y�EwxYw#ttf$r ttj��YywxYw#	tj
|�n2#ttf$r ttj��YnwxYw	t
j
|�w#ttf$r ttj��YwwxYwxYw�w)al
    .. versionadded:: 2.0.0

    Context manager that uses the given `isolation_scope` and runs the wrapped code in it.
    The current scope is also forked to not bleed data into the existing current scope.
    After the wrapped code is executed, the original scopes are restored.

    Example Usage:

    .. code-block:: python

        import sentry_sdk

        with sentry_sdk.isolation_scope() as scope:
            scope.set_tag("color", "green")
            sentry_sdk.capture_message("hello") # will include `color` tag.

        sentry_sdk.capture_message("hello, again") # will NOT include `color` tag.

    N)rwr�rzr�r|r{rfrgrhr+r�r�)rYr[rmrnros     rm�use_isolation_scoperqDs)����.�+�+�-�M�(�-�-�/��"�&�&�';�<�M�'�*�*�?�;�O�
7���	7�� � ��/�	7��"�"�?�3��	�Z�(�	7�&�s�|�|�~�6�	7��
�Z�(�	7�&�s�|�|�~�6�	7��	7�� � ��/���Z�(�	7�&�s�|�|�~�6�	7��	7��"�"�?�3���Z�(�	7�&�s�|�|�~�6�	7�s��AE=�C'�B�-B5�E=�,B2�/E=�1B2�2E=�5,C$�!E=�#C$�$E=�'E:�)C?�>E:�?,D.�+E:�-D.�.E:�2E�E:�,E7�4E:�6E7�7E:�:E=c�F�tj�j�S)z<Shortcut for `Scope.get_client().should_send_default_pii()`.)rwr�r+rkrlrmr+r+rs������5�5�7�7rl)r�)r�rIr�N)r�z'Callable[[], Optional[Tuple[str, str]]]r�NrX)r�zOptional[Tuple[str, str]])r�r6r�r6)r�rTr�rT)r��Generator[Scope, None, None])r�rwr�rs)rYrwr�rs)�rr�r7�collectionsr�
contextlibrrrrr�enumr	�	functoolsr�	itertoolsr�typingr
rr��sentry_sdk._typesr�sentry_sdk.attachmentsr�sentry_sdk.constsrrrr�sentry_sdk.feature_flagsrr�'sentry_sdk.profiler.continuous_profilerrrr�(sentry_sdk.profiler.transaction_profilerr�sentry_sdk.sessionr�sentry_sdk.tracesrrr�sentry_sdk.tracingrr r!r"r#�sentry_sdk.tracing_utilsr$r%r&r'r(r)�sentry_sdk.utilsr*r+r,r-r.r/r0r1r2r3r4�collections.abcr5r6r7r8r9r:r;r<r=r>r?r@rA�typing_extensionsrBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrVrX�__annotations__r{r�r\r]r_ror�r�r�r�rbr�r�r�rwr�rkrYrqr+r�r�rkrlrm�<module>r�s��	�
���%��'����&��,�-���G���
=�&���
���������'�
�
�
�
�)������ 5��#��A����A���8�C��H�-�.�A����A�$(�
� �'��/��>���O�T�:��24��/�4�Y]� �"U�\����(�(�&.�*�1�*�	�*�,�
�8�$�8�-��}�}�@8�!7��!7�H�!7��!7�H�,7��,7�^�*7��*7�Z8��8�1���rl
Back to Directory File Manager