
    i              	          d dl Z d dlZd dlZd dlm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a ej                    Z ej        dej        d	ej        f         
          ZdedefdZdedefdZddedej        e
         ddfdZ	 ddedddej        e
         de
fdZede
fd            Z ede
de!fd            Z"ede!ddfd            Z# ed          Z$ ed          Z%dS )    N)wraps)environ)uuid4)Context_RuntimeContext)OTEL_PYTHON_CONTEXT)entry_points_F.)boundfuncreturnc                 F    t                     dt          j        t          j        t          j        f         dt          j        t          j        t          j        f         dt          j        t          j                 f fd            }t          j        t          |          S )zvA decorator used to initialize the global RuntimeContext

    Returns:
        A wrapper of the decorated method.
    argskwargsr   c            
      |   t           5  t          d}t          j        t          |          }	  t          t          t          d|                                                                          an+# t          $ r t                              d|           Y nw xY wd d d            n# 1 swxY w Y    | i |S )Ncontextvars_contextopentelemetry_context)groupnamezFailed to load context: %s)_RUNTIME_CONTEXT_LOCK_RUNTIME_CONTEXTr   getr   nextiterr	   load	Exceptionlogger	exception)r   r   default_contextconfigured_contextr   s       ^/var/www/cyber-strat/venv/lib/python3.11/site-packages/mysql/opentelemetry/context/__init__.pywrapperz&_load_runtime_context.<locals>.wrapper*   sB    # 	W 	W' #8%,['& &"W(t(&=%7   ( ( dff( ($$ ! W W W$$%ACUVVVVVW)	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W, tT$V$$$s5   $B+AA43B+4%BB+BB++B/2B/)r   typingTupleAnyDictOptionalcastr
   )r   r"   s   ` r!   _load_runtime_contextr)   #   s     4[[%|FJ
23%+fj&*45% 
	$% % % % % [%< ;r7###    keynamec                 D    | 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   )r+   s    r!   
create_keyr/   L   s     S=3uww<<''r*   keycontextobjectc                 r    ||                     |           n t                                           |           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)r0   r1   s     r!   	get_valuer5   X   s2      '27;;s8I8I#8N8NNr*   valuec                 r    |t                      }|                                }||| <   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.
    )r4   copyr   )r0   r6   r1   
new_valuess       r!   	set_valuer:   g   s6      --JJsO:r*   c                  4    t                                           S )zTo 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.
    )r   r4    r*   r!   r4   r4   ~   s     '')))r*   c                 6    t                               |           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)r1   s    r!   r>   r>      s     ""7+++r*   tokenc                     	 t                               |            dS # t          $ r t                              d           Y dS w xY w)zResets 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   )r?   s    r!   rA   rA      sZ    5&&&&& 5 5 534444445s    $AAsuppress_instrumentationsuppress_http_instrumentation)N)&logging	threadingr#   	functoolsr   osr   uuidr   #mysql.opentelemetry.context.contextr   r   )mysql.opentelemetry.environment_variablesr   ,mysql.opentelemetry.util._importlib_metadatar	   	getLogger__name__r   r   Lockr   TypeVarCallabler%   r
   r)   r.   r/   r'   r5   r:   r4   r2   r>   rA   _SUPPRESS_INSTRUMENTATION_KEY"_SUPPRESS_HTTP_INSTRUMENTATION_KEYr<   r*   r!   <module>rS      s^                           I H H H H H H H I I I I I I E E E E E E		8	$	$ &	(( V^DVZ @AAA&$ &$r &$ &$ &$ &$R	( 	( 	( 	( 	( 	(O O3 O!9 OX O O O O  DH 	(.(@   . *W * * * * 
,G 
, 
, 
, 
, 
, 
5& 
5T 
5 
5 
5 
5  !+
+E F F %/Z0O%P%P " " "r*   