Ë
    oñsjÔ  ã                  ó  — d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ  ej                  e«      Zdd„Z e«       Zdd	„Zddd
„Z	 d	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd„Z ed«      Z ed«      Z ed«      Zg d¢Zy)é    )ÚannotationsN)ÚToken)Úuuid4)ÚContextÚ_RuntimeContext)ÚContextVarsRuntimeContext)ÚOTEL_PYTHON_CONTEXTc            	     ó*  — t         j                  j                  t        «      } | s
t	        «       S ddlm} 	  t        t         |d| ¬«      «      «      j                  «       «       S # t        $ r# t        j                  d| «       t	        «       cY S w xY w)zWInitialize the RuntimeContext

    Returns:
        An instance of RuntimeContext.
    r   )Úentry_pointsÚopentelemetry_context)ÚgroupÚnamez?Failed to load context: %s, falling back to contextvars_context)ÚosÚenvironÚgetr	   r   Ú&opentelemetry.util._importlib_metadatar   ÚnextÚiterÚloadÚ	ExceptionÚloggerÚ	exception)Úconfigured_contextr   s     úQ/root/.hermes/venv/lib/python3.12/site-packages/opentelemetry/context/__init__.pyÚ_load_runtime_contextr      s“   € ô Ÿ™Ÿ™Ô(;Ó<ÐÙÜ(Ó*Ð*õð+ðŒtÜÙØ1Ð8Jôóó
÷ ‰$‹&óð 	øô ò +Ü×ÑØMØô	
ô )Ó*Ò*ð+ús   ·.A& Á&)BÂBc                ó4   — | dz   t        t        «       «      z   S )ae  To allow cross-cutting concern to control access to their local state,
    the RuntimeContext API provides a function which takes a keyname as input,
    and returns a unique key.
    Args:
        keyname: The key name is for debugging purposes and is not required to be unique.
    Returns:
        A unique string representing the newly created key.
    ú-)Ústrr   )Úkeynames    r   Ú
create_keyr    5   s   € ð S‰=œ3œu›w›<Ñ'Ð'ó    c                óZ   — ||j                  | «      S t        «       j                  | «      S )av  To access the local state of a concern, the RuntimeContext API
    provides a function which takes a context and a key as input,
    and returns a value.

    Args:
        key: The key of the value to retrieve.
        context: The context from which to retrieve the value, if None, the current context is used.

    Returns:
        The value associated with the key.
    )r   Úget_current)ÚkeyÚcontexts     r   Ú	get_valuer&   A   s*   € ð  'Ð2ˆ7;‰;sÓÐN¼»×8IÑ8IÈ#Ó8NÐNr!   c                óZ   — |€
t        «       }|j                  «       }||| <   t        |«      S )aÑ  To record the local state of a cross-cutting concern, the
    RuntimeContext API provides a function which takes a context, a
    key, and a value as input, and returns an updated context
    which contains the new value.

    Args:
        key: The key of the entry to set.
        value: The value of the entry to set.
        context: The context to copy, if None, the current context is used.

    Returns:
        A new `Context` containing the value set.
    )r#   Úcopyr   )r$   Úvaluer%   Ú
new_valuess       r   Ú	set_valuer+   P   s/   € ð  €Ü“-ˆØ—‘“€JØ€JˆsOÜ:ÓÐr!   c                 ó*   — t         j                  «       S )zÍTo access the context associated with program execution,
    the Context API provides a function which takes no arguments
    and returns a Context.

    Returns:
        The current `Context` object.
    )Ú_RUNTIME_CONTEXTr#   © r!   r   r#   r#   g   s   € ô ×'Ñ'Ó)Ð)r!   c                ó,   — t         j                  | «      S )a  Associates a Context with the caller's current execution unit. Returns
    a token that can be used to restore the previous Context.

    Args:
        context: The Context to set as current.

    Returns:
        A token that can be used with `detach` to reset the context.
    )r-   Úattach)r%   s    r   r0   r0   r   s   € ô ×"Ñ" 7Ó+Ð+r!   c                óx   — 	 t         j                  | «       y# t        $ r t        j	                  d«       Y yw xY w)zçResets the Context associated with the caller's current execution unit
    to the value it had before attaching a specified Context.

    Args:
        token: The Token that was returned by a previous call to attach a Context.
    zFailed to detach contextN)r-   Údetachr   r   r   )Útokens    r   r2   r2      s3   € ð5Ü×Ñ Õ&øÜò 5Ü×ÑÐ3Ö4ð5ús   ‚ ˜9¸9Úon_emit_recursion_countÚsuppress_instrumentationÚsuppress_http_instrumentation)r   r0   r    r2   r#   r&   r+   )Úreturnr   )r   r   r7   r   )N)r$   r   r%   úContext | Noner7   Úobject)r$   r   r)   r9   r%   r8   r7   r   )r7   r   )r%   r   r7   úToken[Context])r3   r:   r7   ÚNone)Ú
__future__r   Úloggingr   Úcontextvarsr   Úuuidr   Úopentelemetry.context.contextr   r   Ú)opentelemetry.context.contextvars_contextr   Ú#opentelemetry.environment_variablesr	   Ú	getLoggerÚ__name__r   r   r-   r    r&   r+   r#   r0   r2   Ú_ON_EMIT_RECURSION_COUNT_KEYÚ_SUPPRESS_INSTRUMENTATION_KEYÚ"_SUPPRESS_HTTP_INSTRUMENTATION_KEYÚ__all__r.   r!   r   ú<module>rI      s·   ðõ #ã Û 	Ý Ý ÷ CÝ OÝ Cà	ˆ×	Ñ	˜8Ó	$€ó+ñ> )Ó*Ð ó	(ôOð  8<ðØ	ðØðØ&4ðàóó.*ó
,ó
5ñ   *Ð*CÓDÐ Ù *Ð+EÓ FÐ Ù%/Ø#ó&Ð "òr!   