Ë
    `Qêj%  ã            	       óÂ  — d dl Z d dlZd dlZd dlmZmZmZ d dlmZ d dl	m
Z
mZmZ d dlmZmZ d dlmZ  ej"                  e«      Zdedefd	„Zed
eeej.                  f   dedz  deeej.                  f   fd„«       Zed
ej.                  dedz  dej.                  fd„«       Zd
ej.                  dedz  dej.                  fd„Z G d„ deeej.                  f   «      Zy)é    N)ÚMappingÚMutableMappingÚSequence)ÚNoneType)ÚTYPE_CHECKINGÚAnyÚoverload)Úassert_neverÚ
deprecated)ÚtypesÚkeyÚreturnc                 óš   — t        | «      j                  t        j                  uxs% t        | «      j                  t        j                  uS ©N)ÚtypeÚ__str__ÚobjectÚ__repr__)r   s    úf/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/opentelemetry/attributes/__init__.pyÚ_is_non_custom_strr      s6   € Ü�‹9×Ñ¤F§N¡NÐ2Ò_´d¸3³i×6HÑ6HÔPV×P_ÑP_Ð6_Ð_ó    ÚvalueÚmax_string_value_lengthc                  ó   — y r   © ©r   r   s     r   Ú_clean_attribute_valuer      s   € ð $'r   c                  ó   — y r   r   r   s     r   r   r   "   s   € ð r   c                 óÚ  ‡— t        | t        t        t        t        t
        f«      r| S t        | t        «      r-‰�)t        | «      ‰kD  rt        j                  d‰«       | d‰ } | S t        | t        «      rt        ˆfd„| D «       «      S t        | t        «      rŒi }| j                  «       D ]u  \  }}|st        j                  d|«       Œt        |t        «      s8t        j                  dt        |«      |«       t        |«      rt        |«      }nŒgt!        |‰«      ||<   Œw |S t"        rt%        | «       t        j                  dt        | «      «       t        | «      rt        | «      S y)aŸ  Recursively checks if an attribute value is valid and cleans it if required.

    String values are truncated to max_string_value_length if provided.
    Anything that isn't of `types.AnyValue`, we attempt to cast to `str`.
    If this fails, the value is replaced with None. Sequence's are converted to tuples and mappings
    are copied into new dicts.

    Returns:
        The recursively cleaned AnyValue.
    Nz<String attribute value exceeds max length of %d, truncating.c              3   ó6   •K  — | ]  }t        |‰«      –— Œ y ­wr   )r   )Ú.0Úvr   s     €r   ú	<genexpr>z)_clean_attribute_value.<locals>.<genexpr>B   s   øè ø€ ÒWÈAÔ+¨AÐ/F×GÑWùs   ƒzSinvalid attribute key `%s`. must be non-empty string. Dropping key from attributes.z£Invalid type `%s` for attribute key `%s`, must be a str. Key's `__str__/__repr__` method will be called if it exists, otherwise the key/value pair will be dropped.zæInvalid type `%s` for attribute value. Expected one of bool, str, None, bytes, int, float or a Mapping or Sequence of those types. Value's __str__ method will be called if it exists, otherwise the value will be replaced with None.)Ú
isinstancer   ÚboolÚintÚfloatÚbytesÚstrÚlenÚ_loggerÚwarningr   Útupler   Úitemsr   r   r   r   r
   )r   r   Úcleaned_mappingr   Úvals    `   r   r   r   )   sS  ø€ ô �%œ(¤D¬#¬u´eÐ<Ô=ØˆÜ�%œÔØ"Ð.´3°u³:Ð@WÒ3WÜ�O‰OØNØ'ôð Ð2Ð2Ð3ˆEØˆÜ�%œÔ"ÜÓWÐQVÔWÓWÐWÜ�%œÔ!Ø57ˆØŸ™›ò 	X‰HˆC�ÙÜ—‘ØiØôð ä˜c¤3Ô'Ü—‘ð zÜ˜“IØôô
 & cÔ*Ü˜c›(‘CàÜ#9¸#Ð?VÓ#WˆO˜CÒ ð%	Xð& ÐÝÜ�UÔÜ‡O�Oð	RäˆU‹ôô
 ˜%Ô Ü�5‹zÐØr   c                   ó4  — e Zd ZdZe	 	 	 	 ddedz  dej                  dededz  ddf
d„«       Z	e e
d	«      	 	 	 	 	 ddedz  dej                  dededz  d
eddfd„«       «       Z		 	 	 	 	 ddedz  dej                  dededz  d
eddfd„Z	defd„Zdedej                  fd„Zdd„Zdedej                  ddfd„Zdeeej                  f   ddfd„Zdedej                  ddfd„Zdeddfd„Zd„ Zdefd„Zdeeef   dd fd„Zdeeej                  f   fd„Zy)ÚBoundedAttributesa  A dict with a fixed max capacity which cleans and potentially drops values to ensure they are valid attribute values.

    Args:
        maxlen: The maximum number of attributes to store, use None for no limit.
        attributes: The initial attributes to store.
        immutable: Defaults to true. Whether to allow adding/removing of attributes after the initialisation of the instance.
        max_value_len: The maximum length of string values, use None for no limit.
        extended_attributes: Deprecated. Kept for backwards compatibility. Extended attributes are now always used for attributes everywhere.

    When the dict is full and a new element is added, the oldest element is dropped. Attributes are made to be immutable when set in this container.
    So passing a mutable list as an attribute value, and then mutating it after will not change it's value in this container.
    NÚmaxlenÚ
attributesÚ	immutableÚmax_value_lenr   c                  ó   — y r   r   )Úselfr3   r4   r5   r6   s        r   Ú__init__zBoundedAttributes.__init__s   s   € ð r   zæCreating BoundedAttributes with `extended_attributes` set is deprecated. The `extended_attributes` param is no longer used and will be removed in a future release. Extended attributes are now always used for attributes everywhere.Úextended_attributesc                  ó   — y r   r   ©r8   r3   r4   r5   r6   r:   s         r   r9   zBoundedAttributes.__init__|   s   € ð r   c                 óø   — |�|dk  rt        d«      ‚|�|dk  rt        d«      ‚i | _        || _        d| _        || _        t        j                  «       | _        d| _        |r| j                  |«       || _        y )Nr   z.maxlen must be valid int greater or equal to 0z5max_value_len must be valid int greater or equal to 0F)
Ú
ValueErrorÚ_dictr3   Údroppedr6   Ú	threadingÚLockÚ_lockÚ
_immutableÚ
_set_itemsr<   s         r   r9   zBoundedAttributes.__init__‹   s}   € ð Ð &¨1¢*ÜÐMÓNÐNØÐ$¨¸Ò):ÜÐTÓUÐUØ02ˆŒ
ØˆŒØˆŒØ*ˆÔÜ—^‘^Ó%ˆŒ
àˆŒÙØ�O‰O˜JÔ'Ø#ˆ�r   c                 ó.   — t        | j                  «      › S r   )Údictr?   ©r8   s    r   r   zBoundedAttributes.__repr__¢   s   € Ü�t—z‘zÓ"Ð#Ð$r   r   c                 ó    — | j                   |   S r   )r?   ©r8   r   s     r   Ú__getitem__zBoundedAttributes.__getitem__¥   s   € Ø�z‰z˜#‰Ðr   c                 ó2   — | j                   rt        d«      ‚y )Nz)Cannot mutate immutable BoundedAttributes)rD   Ú	TypeErrorrH   s    r   Ú_raise_if_immutablez%BoundedAttributes._raise_if_immutable¨   s   € Ø�?Š?ÜÐGÓHÐHð r   r   c                 ó  — | j                  «        | j                  �;| j                  dk(  r,| j                  5  | xj                  dz  c_        	 d d d «       y |rt	        |t
        «      sAt        j                  d|«       | j                  5  | xj                  dz  c_        d d d «       y t        || j                  «      }| j                  5  | j                  ||«       d d d «       y # 1 sw Y   ŒšxY w# 1 sw Y   y xY w# 1 sw Y   y xY w)Nr   é   zIinvalid key `%s`. must be non-empty string. Dropping key from attributes.)rN   r3   rC   r@   r$   r)   r+   r,   r   r6   Ú_setitem_locked)r8   r   r   Úcleaneds       r   Ú__setitem__zBoundedAttributes.__setitem__¬   så   € Ø× Ñ Ô"Ø�;‰;Ð" t§{¡{°aÒ'7Ø—‘ñ Ø—’ Ñ!•Ø÷ð ñ œ* S¬#Ô.Ü�O‰OØ[Øôð —‘ñ "Ø—’ Ñ!•÷"àÜ(¨°×0BÑ0BÓCˆØ�Z‰Zñ 	/Ø× Ñ   gÔ.÷	/ð 	/÷ð ú÷"àú÷	/ð 	/ús#   ¸C)ÂC5ÃDÃ)C2Ã5C>ÄD
c                 óò  — | j                  «        | j                  �C| j                  dk(  r4| j                  5  | xj                  t	        |«      z  c_        d d d «       y t        || j                  «      }| j                  5  | xj                  t	        |«      t	        |«      z
  z  c_        |j                  «       D ]  \  }}| j                  ||«       Œ 	 d d d «       y # 1 sw Y   y xY w# 1 sw Y   y xY w)Nr   )	rN   r3   rC   r@   r*   r   r6   r.   rQ   )r8   r4   Úcleaned_attributesr   r   s        r   rE   zBoundedAttributes._set_items¾   sÑ   € Ø× Ñ Ô"Ø�;‰;Ð" t§{¡{°aÒ'7Ø—‘ñ 0Ø—’¤ J£Ñ/•÷0àÜ;QÐR\Ð^b×^pÑ^pÓ;qÐØ�Z‰Zñ 	1Ø�LŠLœC 
›O¬cÐ2DÓ.EÑEÑE�LØ0×6Ñ6Ó8ò 1‘
��UØ×$Ñ$ S¨%Õ0ñ1÷	1ð 	1÷	0àú÷	1ð 	1ús   ¸C!ÂAC-Ã!C*Ã-C6c                 óv  — || j                   v r| j                   |= | j                  �ƒt        | j                   «      | j                  k\  rat        j	                  d«       | j                   t        t        | j                   j                  «       «      «      = | xj                  dz  c_        || j                   |<   y )NzuAttributes dict is full. Dropping the oldest key-value pair from attributes to make space for the new key-value pair.rP   )	r?   r3   r*   r+   r,   ÚnextÚiterÚkeysr@   )r8   r   r   s      r   rQ   z!BoundedAttributes._setitem_lockedÊ   s†   € Ø�$—*‘*ÑØ—
‘
˜3�Ø�;‰;Ð"¤s¨4¯:©:£¸$¿+¹+Ò'EÜ�O‰Oð Hôð —
‘
œ4¤ T§Z¡Z§_¡_Ó%6Ó 7Ó8Ð9Ø�LŠL˜AÑ�Làˆ�
‰
�3Šr   c                 ó>   — | j                  «        | j                  |= y r   )rN   r?   rJ   s     r   Ú__delitem__zBoundedAttributes.__delitem__×   s   € Ø× Ñ Ô"Ø�J‰J�s‰Or   c                 óÄ   — | j                   rt        | j                  «      S | j                  5  t        t	        | j                  «      «      cd d d «       S # 1 sw Y   y xY wr   )rD   rX   r?   rC   ÚlistrH   s    r   Ú__iter__zBoundedAttributes.__iter__Û   sE   € Ø�?Š?Ü˜Ÿ
™
Ó#Ð#Ø�Z‰Zñ 	*Üœ˜TŸZ™ZÓ(Ó)÷	*÷ 	*ò 	*ús   ®AÁAc                 ó,   — t        | j                  «      S r   )r*   r?   rH   s    r   Ú__len__zBoundedAttributes.__len__á   s   € Ü�4—:‘:‹Ðr   Úmemoc                 ó*  — t        | j                  | j                  | j                  ¬«      }||t	        | «      <   | j
                  5  t        j                  | j                  |«      |_        | j                  |_	        d d d «       |S # 1 sw Y   |S xY w)N)r3   r5   r6   )
r2   r3   rD   r6   ÚidrC   ÚcopyÚdeepcopyr?   r@   )r8   ra   Úcopy_s      r   Ú__deepcopy__zBoundedAttributes.__deepcopy__ä   sz   € Ü!Ø—;‘;Ø—o‘oØ×,Ñ,ô
ˆð
 ˆŒR�‹X‰Ø�Z‰Zñ 	)ô Ÿ-™-¨¯
©
°DÓ9ˆEŒKØ ŸL™LˆEŒM÷		)ð
 ˆ÷	)ð
 ˆús   Á7BÂBc                 ó6   — | j                   j                  «       S r   )r?   rd   rH   s    r   rd   zBoundedAttributes.copyò   s   € Ø�z‰z�‰Ó Ð r   )NNTN)NNTNF)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r&   r   Ú
Attributesr%   r9   r   r)   r   ÚAnyValuerK   rN   rS   r   rE   rQ   r[   r^   r`   rG   r   rg   r   rd   r   r   r   r2   r2   e   s%  „ ñð ð "Ø'+ØØ$(ñà�d‘
ðð ×$Ñ$ðð ð	ð
 ˜T‘zðð 
òó ðð Ùð	bóð "Ø'+ØØ$(Ø$)ñà�d‘
ðð ×$Ñ$ðð ð	ð
 ˜T‘zðð "ðð 
òóó ðð "Ø'+ØØ$(Ø$)ñ$à�d‘
ð$ð ×$Ñ$ð$ð ð	$ð
 ˜T‘zð$ð "ð$ð 
ó$ð.%˜#ó %ð˜sð  u§~¡~ó óIð/˜sð /¨5¯>©>ð /¸dó /ð$
1 W¨S°%·.±.Ð-@Ñ%Að 
1Àdó 
1ð  3ð  ¨u¯~©~ð  À$ó  ð˜sð  tó ò*ð˜ó ð  c¨3 h¡ð Ð4Gó ð!�n S¨%¯.©.Ð%8Ñ9ô !r   r2   )rd   ÚloggingrA   Úcollections.abcr   r   r   r   r   Útypingr   r   r	   Útyping_extensionsr
   r   Úopentelemetry.utilÚ	getLoggerri   r+   r%   r   r)   rn   r&   r   r2   r   r   r   ú<module>ru      s  ðó Û Û ß =Ñ =Ý ß /Ñ /ç 6å $à
ˆ'×
Ñ
˜HÓ
%€ð`˜Cð ` Dó `ð 
ð'Ø�3˜Ÿ™Ð&Ñ'ð'à  4™Zð'ð ˆS�%—.‘.Ð Ñ!ò'ó 
ð'ð 
ðØ�>‰>ðà  4™Zðð ‡^�^òó 
ðð9Ø�>‰>ð9à  4™Zð9ð ‡^�^ó9ôxN!˜ s¨E¯N©NÐ':Ñ;õ N!r   