HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/mysql/opentelemetry/context/__pycache__/__init__.cpython-39.pyc
a

�,�h��@s8ddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZe�e�Zdae��Zejdejd	ejfd
�Zeed�dd
�Zeed�dd�Zd#eeje
dd�dd�Zd$edeje
e
d�dd�Zee
d�dd��Z ee
e!d�dd��Z"ee!dd�dd ��Z#ed!�Z$ed"�Z%dS)%�N)�wraps)�environ)�uuid4)�Context�_RuntimeContext)�OTEL_PYTHON_CONTEXT)�entry_points�_F.)�bound)�func�returncsNt��tjtjtjftjtjtjftjtjd��fdd��}t�t|�S)zvA decorator used to initialize the global RuntimeContext

    Returns:
        A wrapper of the decorated method.
    )�args�kwargsrc	s�t�ftdur\d}t�t|�}ztttd|d������aWnt	yZt
�d|�Yn0Wd�n1sp0Y�|i|��S)NZcontextvars_contextZopentelemetry_context)�group�namezFailed to load context: %s)�_RUNTIME_CONTEXT_LOCK�_RUNTIME_CONTEXTr�getr�next�iterr�load�	Exception�logger�	exception)r
rZdefault_contextZconfigured_context�r��W/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/opentelemetry/context/__init__.py�wrapper*s$����	0z&_load_runtime_context.<locals>.wrapper)r�typing�Tuple�Any�Dict�Optional�castr	)rrrrr�_load_runtime_context#s
�r$)�keynamercCs|dtt��S)aeTo 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)r%rrr�
create_keyLs	r(�object)�key�contextrcCs|dur|�|�St��|�S)avTo 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.
    N)r�get_current)r*r+rrr�	get_valueXsr-)r*�valuer+rcCs&|durt�}|��}|||<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.
    N)r,�copyr)r*r.r+�
new_valuesrrr�	set_valuegs
r1)rcCst��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.
    )rr,rrrrr,~s	r,)r+rcCs
t�|�S)aAssociates 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+rrrr2�sr2)�tokenrcCs0zt�|�Wnty*t�d�Yn0dS)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.
    zFailed to detach contextN)r�detachrrr)r3rrrr4�sr4Zsuppress_instrumentationZsuppress_http_instrumentation)N)N)&�logging�	threadingr�	functoolsr�osr�uuidrZ#mysql.opentelemetry.context.contextrrZ)mysql.opentelemetry.environment_variablesrZ,mysql.opentelemetry.util._importlib_metadatar�	getLogger�__name__rr�Lockr�TypeVar�Callabler r	r$r'r(r"r-r1r,r)r2r4Z_SUPPRESS_INSTRUMENTATION_KEYZ"_SUPPRESS_HTTP_INSTRUMENTATION_KEYrrrr�<module>s8
)��