� ���goL� ��ddlZddlZddlZddlZddlZddlZddlmZm Z ddl mZdZ ej e ��Z dZej e��ZdZej d��Zej de �d e�d ���Zeje��Zd ed ed efd�ZGd�dej��ZGd�de��Ze���ZGd�dejeef��Z e ���Z!ddzdz Z"dZ#Gd�dej$eeeddef��Z%Gd�de��Z&dZ'dZ(e%e(e'dee!���Z)e&e)��Z*ded efd �Z+d!ed efd"�Z,dS)#�N)�Status� StatusCode)�typeszU[a-z][_0-9a-z\-\*\/]{0,255}|[a-z0-9][_0-9a-z\-\*\/]{0,240}@[a-z][_0-9a-z\-\*\/]{0,13}zA[\x20-\x2b\x2d-\x3c\x3e-\x7e]{0,255}[\x21-\x2b\x2d-\x3c\x3e-\x7e]� z [ \t]*,[ \t]*�(z)(=)(z)[ ]*�key�value�returnc���t|t��oLt�|��duo0t|t��ot�|��duS�N)� isinstance�str� _KEY_PATTERN� fullmatch�_VALUE_PATTERN)rr s �h/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/opentelemetry/trace/span.py�_is_valid_pairr/s^���3���� 8� � "� "�3� '� '�t� 3� 8� �u�c� "� "� 8� � $� $�U� +� +�4� 7� �c ��eZdZdZejd dejeddfd���Z ejd!d���Z ejdej e e jfddfd ���Zejd e d e jddfd ���Zej d"d e de jdejeddfd���Z d ddde jddfd�Zejd e ddfd���Zejdefd���Zej d dejeefdeje ddfd���Zej d#dede jdejededdf d���Zd$d�Zdejejedejedejej ddfd�Z!dS)%�Spanz4A span represents a single operation within a trace.N�end_timer c��dS)a Sets the current time as the span's end time. The span's end time is the wall time at which the operation finished. Only the first call to `end` should modify the span, and implementations are free to ignore or raise on further calls. N���selfrs r�endzSpan.end;����r� SpanContextc��dS)aGets the span's SpanContext. Get an immutable, serializable identifier for this span that can be used to create new child spans. Returns: A :class:`opentelemetry.trace.SpanContext` with a copy of this span's immutable state. Nr�rs r�get_span_contextzSpan.get_span_contextErr� attributesc��dS)a�Sets Attributes. Sets Attributes with the key and value passed as arguments dict. Note: The behavior of `None` value attributes is undefined, and hence strongly discouraged. It is also preferred to set attributes at span creation, instead of calling this method later since samplers can only consider information already present during span creation. Nr�rr"s r�set_attributeszSpan.set_attributesPrrrr c��dS)a�Sets an Attribute. Sets a single Attribute with the key and value passed as arguments. Note: The behavior of `None` value attributes is undefined, and hence strongly discouraged. It is also preferred to set attributes at span creation, instead of calling this method later since samplers can only consider information already present during span creation. Nr�rrr s r� set_attributezSpan.set_attribute^rr�name� timestampc��dS)z�Adds an `Event`. Adds a single `Event` with the name and, optionally, a timestamp and attributes passed as arguments. Implementations should generate a timestamp if the `timestamp` argument is omitted. Nr�rr)r"r*s r� add_eventzSpan.add_eventjrr�contextc�.�tjd��dS)a�Adds a `Link`. Adds a single `Link` with the `SpanContext` of the span to link to and, optionally, attributes passed as arguments. Implementations may ignore calls with an invalid span context if both attributes and TraceState are empty. Note: It is preferred to add links at span creation, instead of calling this method later since samplers can only consider information already present during span creation. zsSpan.add_link() not implemented and will be a no-op. Use opentelemetry-sdk >= 1.23 to add links after span creationN)�warnings�warn�rr.r"s r�add_linkz Span.add_linkxs(�� � � M� � � � � rc��dS)z�Updates the `Span` name. This will override the name provided via :func:`opentelemetry.trace.Tracer.start_span`. Upon this update, any sampling behavior based on Span name will depend on the implementation. Nr�rr)s r� update_namezSpan.update_name�rrc��dS)z�Returns whether this span will be recorded. Returns true if this Span is active and recording information like events with the add_event operation and attributes using set_attribute. Nrr s r� is_recordingzSpan.is_recording�rr�status� descriptionc��dS)zbSets the Status of the Span. If used, this will override the default Span status. Nr�rr9r:s r� set_statuszSpan.set_status�rrF� exception�escapedc��dS)z%Records an exception as a span event.Nr�rr>r"r*r?s r�record_exceptionzSpan.record_exception�rrc��|S)z^Invoked when `Span` is used as a context manager. Returns the `Span` itself. rr s r� __enter__zSpan.__enter__�s �� � r�exc_type�exc_val�exc_tbc�.�|���dS)z3Ends context manager and calls `end` on the `Span`.N)r)rrErFrGs r�__exit__z Span.__exit__�s�� ��� � � � � rr �r r�NN�NNF)r r)"�__name__� __module__� __qualname__�__doc__�abc�abstractmethod�typing�Optional�intrr!�Mappingrr�AttributeValuer%r(� Attributesr-r3r6�boolr8�Unionrrr=� BaseExceptionrBrD�Type� python_types� TracebackTyperIrrrrr8s,������>�>��� � �F�O�C�0� �D� � � ��� � �� � � ��� � ��  � �.��e�.B�)B�C�  � �  �  �  ���  � ��  ��  �U�-A�  �d�  �  �  ���  � ��(,�*.�  �  ��  ��$�  ��?�3�'�  � �  �  �  ���  � (,� � �� ��$� � �  � � � �* �� �� �� � � ��� � �� �d� � � ��� � ��-1� � �� �V�Z�/�0� ��_�S�)� � �  � � ��� � ��(,�*.�� 4�4� �4��$�4��?�3�'� 4� � 4� � 4�4�4���4�������/�&�+�m�"<�=�����/���� � :�;� � � �����rrc�N�eZdZdZdZdZedd���Zede fd���Z dS) � TraceFlagsarA bitmask that represents options specific to the trace. The only supported option is the "sampled" flag (``0x01``). If set, this flag indicates that the trace may have been sampled upstream. See the `W3C Trace Context - Traceparent`_ spec for details. .. _W3C Trace Context - Traceparent: https://www.w3.org/TR/trace-context/#trace-flags r�r c�"�||j��Sr )�DEFAULT��clss r� get_defaultzTraceFlags.get_default�s���s�3�;���rc�:�t|tjz��Sr )rYr`�SAMPLEDr s r�sampledzTraceFlags.sampled�s���D�:�-�-�.�.�.rN�r r`) rMrNrOrPrcrh� classmethodrf�propertyrYrirrrr`r`�so������ � ��G��G�� � � ��[� ��/��/�/�/��X�/�/�/rr`c���eZdZdZ ddejejejeefddfd�Z de de fd�Z dedefd �Z dejefd �Zdefd �Zdefd �Zded eddfd�Zded eddfd�Zdeddfd�Zdefd�Zedejeddfd���Zedd���Zdejefd�Zdejeeffd�Zdejefd�Z dS)� TraceStatea�A list of key-value pairs representing vendor-specific trace info. Keys and values are strings of up to 256 printable US-ASCII characters. Implementations should conform to the `W3C Trace Context - Tracestate`_ spec, which describes additional restrictions on valid field values. .. _W3C Trace Context - Tracestate: https://www.w3.org/TR/trace-context/#tracestate-field N�entriesr c�X�i|_|�dSt|��tkr"t�dt��dS|D]a\}}t ||��r0||jvrt�d|���:||j|<�Et�d||���bdS)Nz,There can't be more than %s key/value pairs.zDuplicate key: %s found.�&Invalid key/value pair (%s, %s) found.)�_dict�len�%_TRACECONTEXT_MAXIMUM_TRACESTATE_KEYS�_logger�warningr)rrorr s r�__init__zTraceState.__init__�s��� �� � �?� �F� �w�<�<�?� ?� ?� �O�O�>�5� � � � �F�!� � �J�C���c�5�)�)� ��$�*�$�$��O�O�$>��D�D�D��"'�� �3������<�c�5����� � r�itemc��||jvSr �rr)rrxs r� __contains__zTraceState.__contains__s���t�z�!�!rrc��|j|Sr rz)rrs r� __getitem__zTraceState.__getitem__ s���z�#��rc�*�t|j��Sr )�iterrrr s r�__iter__zTraceState.__iter__ s���D�J���rc�*�t|j��Sr )rsrrr s r�__len__zTraceState.__len__s���4�:���rc�f�d�|j���D��}t|��S)Nc�&�g|]\}}d|�d|�d���S)z{key=z, value=�}r��.0rr s r� <listcomp>z'TraceState.__repr__.<locals>.<listcomp>s?�� � � ���U� ,�S� +� +�%� +� +� +� � � r)rr�itemsr)r�pairss r�__repr__zTraceState.__repr__s<�� � �"�j�.�.�0�0� � � ���5�z�z�rr c��t||��st�d||��|St|��tkrt�d��|S||jvrt�d|��|S||fgt |j�����z}t|��S)aAdds a key-value pair to tracestate. The provided pair should adhere to w3c tracestate identifiers format. Args: key: A valid tracestate key to add value: A valid tracestate value to add Returns: A new TraceState with the modifications applied. If the provided key-value pair is invalid or results in tracestate that violates tracecontext specification, they are discarded and same tracestate will be returned. rqz'There can't be more 32 key/value pairs.z#The provided key %s already exists.) rrurvrsrtrr�listr�rn)rrr � new_states r�addzTraceState.adds����c�5�)�)� � �O�O�8�#�u� � � ��K� �t�9�9�=� =� =� �O�O�E� F� F� F��K� �$�*� � � �O�O�A�3� G� G� G��K��5�\�N�T�$�*�*:�*:�*<�*<�%=�%=�=� ��)�$�$�$rc� �t||��st�d||��|S|j���}|�|d��||fg|����}t|��S)aUpdates a key-value pair in tracestate. The provided pair should adhere to w3c tracestate identifiers format. Args: key: A valid tracestate key to update value: A valid tracestate value to update for key Returns: A new TraceState with the modifications applied. If the provided key-value pair is invalid or results in tracestate that violates tracecontext specification, they are discarded and same tracestate will be returned. rqN)rrurvrr�copy�popr�rn)rrr � prev_stater�s r�updatezTraceState.update8s����c�5�)�)� � �O�O�8�#�u� � � ��K��Z�_�_�&�&� ����s�D�!�!�!��5�\�7�J�$4�$4�$6�$6�7� ��)�$�$�$rc� �||jvrt�d|��|S|j���}|�|��t |�����}t|��S)a�Deletes a key-value from tracestate. Args: key: A valid tracestate key to remove key-value pair from tracestate Returns: A new TraceState with the modifications applied. If the provided key-value pair is invalid or results in tracestate that violates tracecontext specification, they are discarded and same tracestate will be returned. z"The provided key %s doesn't exist.)rrrurvr�r�r�r�rn)rrr�r�s r�deletezTraceState.deleteQsu�� �d�j� � � �O�O�@�#� F� F� F��K��Z�_�_�&�&� ����s������)�)�+�+�,�,� ��)�$�$�$rc�n�d�d�|j���D����S)z�Creates a w3c tracestate header from a TraceState. Returns: A string that adheres to the w3c tracestate header format. �,c3�,K�|]\}}|dz|zV��dS)�=Nrr�s r� <genexpr>z'TraceState.to_header.<locals>.<genexpr>ms/����O�O�j�c�5��c� �E�)�O�O�O�O�O�Or)�joinrrr�r s r� to_headerzTraceState.to_headerfs3���x�x�O�O�D�J�<L�<L�<N�<N�O�O�O�O�O�Or� header_listc��i}|D]�}tjt|��}|D]{}|s�t�|��}|s)t �d|��|��ccS|���}|\}} } ||vr|��ccS| ||<�|��|t|� ������S)aParses one or more w3c tracestate header into a TraceState. Args: header_list: one or more w3c tracestate headers. Returns: A valid TraceState that contains values extracted from the tracestate header. If the format of one headers is illegal, all values will be discarded and an empty tracestate will be returned. If the number of keys is beyond the maximum, all values will be discarded and an empty tracestate will be returned. z2Member doesn't match the w3c identifiers format %s) �re�split�_delimiter_pattern�_member_patternrrurv�groupsr�r�) rer�r��header�members�member�matchr�r�_eqr s r� from_headerzTraceState.from_headeros���"��!� #� #�F�(*��1C�V�(L�(L�G�!� #� #�����'�1�1�&�9�9���!��O�O�L������3�5�5�L�L�L�L�L�16������"(���S�%��%�<�<��3�5�5�L�L�L�L�L�"��c� � �! #�"�s�4�� � � � �&�&�'�'�'rc��|��Sr rrds rrfzTraceState.get_default�s ���s�u�u� rc�4�|j���Sr )rr�keysr s rr�zTraceState.keys�s���z��� � � rc�4�|j���Sr )rrr�r s rr�zTraceState.items�s���z���!�!�!rc�4�|j���Sr )rr�valuesr s rr�zTraceState.values�s���z� � �"�"�"rr �r rn)!rMrNrOrPrSrT�Sequence�Tuplerrw�objectrYr{r}�Iteratorr�rUr�r�r�r�r�r�rk�Listr�rf�KeysViewr�� ItemsViewr�� ValuesViewr�rrrrnrn�s\�������� � ���� �O�F�L��c��2� 3� �� � ����6"��"�D�"�"�"�"��s��s����� �&�/�#�.� � � � ��������#�����%�s�%�3�%�<�%�%�%�%�>%�#�%�c�%�l�%�%�%�%�2%�#�%�,�%�%�%�%�*P�3�P�P�P�P��$(�f�k�#�&6�$(�<�$(�$(�$(��[�$(�L�����[��!�f�o�c�*�!�!�!�!�"�v�'��S��1�"�"�"�"�#��)�#�.�#�#�#�#�#�#rrn��ral����c �\�eZdZdZeefdedededej ddej dd df d �Z d ej eeeddffd �Z e d efd ���Ze d efd ���Ze d efd���Ze dd���Ze dd���Ze d efd���Zded dfd�Zded dfd�Zd efd�ZdS)ra�The state of a Span to propagate between processes. This class includes the immutable attributes of a :class:`.Span` that must be propagated to a span's children and across process boundaries. Args: trace_id: The ID of the trace that this span belongs to. span_id: This span's ID. is_remote: True if propagated from a remote parent. trace_flags: Trace options to propagate. trace_state: Tracing-system-specific info to propagate. �trace_id�span_id� is_remote� trace_flagsr`� trace_staternr c ���|�t}|�t}t|cxko tkncot|cxko t knc}t �|||||||f��Sr )�DEFAULT_TRACE_OPTIONS�DEFAULT_TRACE_STATE�INVALID_TRACE_ID�_TRACE_ID_MAX_VALUE�INVALID_SPAN_ID�_SPAN_ID_MAX_VALUE�tuple�__new__)rer�r�r�r�r��is_valids rr�zSpanContext.__new__�s��� � �/�K� � �-�K� �x� >� >� >� >�+>� >� >� >� >� @��'�?�?�?�?�-?�?�?�?�?� � �}�}� � �w� �;� �X� N� � � rc�B�|j|j|j|j|jfSr �r�r�r�r�r�r s r�__getnewargs__zSpanContext.__getnewargs__�s)�� �M� �L� �N� � � � �  � rc��|dS)Nrrr s rr�zSpanContext.trace_id�� ���A�w�rc��|dS)Nrarr s rr�zSpanContext.span_id�r�rc��|dS)Nr�rr s rr�zSpanContext.is_remote�r�rc��|dS)N�rr s rr�zSpanContext.trace_flags�r�rc��|dS)N�rr s rr�zSpanContext.trace_state�r�rc��|dS)N�rr s rr�zSpanContext.is_valid�r�r�argsNc�>�t�dd���dS�Nz.Immutable type, ignoring call to set attributeT)� stack_info�ru�debug�rr�s r� __setattr__zSpanContext.__setattr__��,��� � � <�� � � � � � rc�>�t�dd���dSr�r�r�s r� __delattr__zSpanContext.__delattr__�r�rc ��t|��j�dt|j���dt |j���d|jd�d|j�d|j�d� S)Nz (trace_id=0xz , span_id=0xz, trace_flags=0x�02xz, trace_state=z , is_remote=�)) �typerM�format_trace_idr��format_span_idr�r�r�r�r s rr�zSpanContext.__repr__�s����t�*�*�%�c�c�?�4�=�3Q�3Q�c�c�_m�nr�nz�_{�_{�c�c�NR�N^�c�c�c�rv�rB�c�c�RV�R`�c�c�c� crrjr�)rMrNrOrPr�r�rUrYrSrTr�r�r�rlr�r�r�r�r�r�rr�r�r�rrrrr�s������� � �$6K�5H�  � �� �� ��  � �_�\�2�  � �_�\�2�  � � � � � �.  � ��c�3��l�L�@� A�  �  �  �  ���#�����X���������X����4�����X�������X�������X����$�����X�� �� �� � � � �  �� �� � � � � c�#�c�c�c�c�c�crrc ��eZdZdZdd�Zdd�Zdefd�Zdd ej e ddfd �Z d ej e ejfddfd �Zd e dejddfd�Z d de d ejdej e ddfd�Z dddd ejddfd�Zde ddfd�Z ddejeefdej e ddfd�Z d!ded ejdej e deddf d�Zde fd�ZdS)"�NonRecordingSpanz~The Span that is used when no Span implementation is available. All operations are no-op except context propagation. r.rr Nc��||_dSr ��_context)rr.s rrwzNonRecordingSpan.__init__s ���� � � rc��|jSr r�r s rr!z!NonRecordingSpan.get_span_context s ���}�rc��dS)NFrr s rr8zNonRecordingSpan.is_recording s���urrc��dSr rrs rrzNonRecordingSpan.end��� �rr"c��dSr rr$s rr%zNonRecordingSpan.set_attributess �� �rrr c��dSr rr's rr(zNonRecordingSpan.set_attributer�rr)r*c��dSr rr,s rr-zNonRecordingSpan.add_events �� �rc��dSr rr2s rr3zNonRecordingSpan.add_link#� �� �rc��dSr rr5s rr6zNonRecordingSpan.update_name*r�rr9r:c��dSr rr<s rr=zNonRecordingSpan.set_status-r�rFr>r?c��dSr rrAs rrBz!NonRecordingSpan.record_exception4s �� �rc��d|j�d�S)NzNonRecordingSpan(r�r�r s rr�zNonRecordingSpan.__repr__=s��5�4�=�5�5�5�5r)r.rr NrJr rKrL)rMrNrOrPrwr!rYr8rSrTrUrrVrrrWr%r(rXr-r3r6rZrrr=r[rBr�rrrr�r�sd��������  � � � ������d����� � �F�O�C�0� �D� � � � � � �.��e�.B�)B�C� � � � � � �  �� �U�-A� �d� � � � � (,�*.�  � �� ��$� ��?�3�'�  � �  � � � �(,� � �� ��$� � �  � � � � �� �� � � � � -1� � �� �V�Z�/�0� ��_�S�)� � �  � � � �(,�*.��  � � � ��$� ��?�3�'�  � �  � �  � � � �6�#�6�6�6�6�6�6rr�Fr�r�c�"�t|d��S)z�Convenience trace ID formatting method Args: trace_id: Trace ID int Returns: The trace ID as 32-byte hexadecimal string �032x��format)r�s rr�r�Ms�� �(�F� #� #�#rr�c�"�t|d��S)z�Convenience span ID formatting method Args: span_id: Span ID int Returns: The span ID as 16-byte hexadecimal string �016xr�)r�s rr�r�Xs�� �'�6� "� "�"r)-rQ�loggingr�rr]rSr0�opentelemetry.trace.statusrr�opentelemetry.util� _KEY_FORMAT�compiler� _VALUE_FORMATrrtr�r�� getLoggerrMrurrYr�ABCrrUr`rfr�rVrnr�r�r�r�rr�r�r��INVALID_SPAN_CONTEXT� INVALID_SPANr�r�rrr�<module>r s�� � � � ����� � � � ����� � � � �����9�9�9�9�9�9�9�9�$�$�$�$�$�$�A� ��r�z�+�&�&� �I�����M�*�*��)+�%��R�Z� 0�1�1���"�*�I��I�I�=�I�I�I�J�J�� �'� �H� %� %�����C��D�����J�J�J�J�J�3�7�J�J�J�Z/�/�/�/�/��/�/�/�0#�.�.�0�0��A#�A#�A#�A#�A#����S��)�A#�A#�A#�H!�,�,�.�.����f�q�j����Uc�Uc�Uc�Uc�Uc� �L��c�4��|�T�A�B�Uc�Uc�Uc�p=6�=6�=6�=6�=6�t�=6�=6�=6�@%��5��"�{� � ��%�#� ���� �� 4�5�5� �$�c�$�c�$�$�$�$�#�C�#�C�#�#�#�#�#�#r
Memory