
    qPhG                         d Z ddlmZ ddlmZmZmZmZmZ ddl	Z	ddl
mZ ddlmZ dd	lmZ d
dgZdededefdZedee   defd       ZdedefdZy)zBCommon functions shared by both the sync and the async decorators.    )contextmanager)AnyOptionalCallableType	GeneratorN   )AbstractSpan   )
get_tracer)settingschange_contextwith_current_contextfuncargsreturnc                     	 | j                   S # t        $ rF |r5dj                  |d   j                  j                  | j                        cY S | j                  cY S w xY w)a  
    Given a function and its unamed arguments, returns class_name.function_name. It assumes the first argument
    is `self`. If there are no arguments then it only returns the function name.

    :param func: the function passed in
    :type func: callable
    :param args: List of arguments passed into the function
    :type args: list
    :return: The function name with the class name
    :rtype: str
    z{}.{}r   )__qualname__AttributeErrorformat	__class____name__)r   r   s     g/var/www/dev.core.comfenalco.cic-ware.com/crm/lib/python3.12/site-packages/azure/core/tracing/common.pyget_function_and_class_namer   *   sT        >>$q'"3"3"<"<dmmLL}}s    >AAAspanc              #     K   t        j                         }|| d y	 |j                  |       5  d ddd       y# 1 sw Y   yxY w# t        $ rj t	        j
                  dt               |j                         }	 |j                  |        d |j                  |       Y y# |j                  |       w xY ww xY ww)ar  Execute this block inside the given context and restore it afterwards.

    This does not start and ends the span, but just make sure all code is executed within
    that span.

    If span is None, no-op.

    :param span: A span
    :type span: AbstractSpan
    :rtype: contextmanager
    :return: A context manager that will run the given span in the new context
    NzAYour tracing plugin should be updated to support "change_context")	r   tracing_implementationr   r   warningswarnDeprecationWarningget_current_spanset_current_span)r   span_impl_typeoriginal_spans      r   r   r   >   s      446N	?..t4    	?MMS" +;;=M?//5//>//>	?s[   CA A A C A	A C	A 3B? B(B?&C(B;;B??Cc                     t        j                         s| S t        j                         }|r|j                  |       S t	               }|s| S |j                  |       S )zPasses the current spans to the new context the function will be run in.

    :param func: The function that will be run in the new context
    :type func: callable
    :return: The func wrapped with correct context
    :rtype: callable
    )r   tracing_enabledr   r   r   )r   r#   tracers      r   r   r   b   sW     ##%3;3R3R3TN22488\F&&t,,    )__doc__
contextlibr   typingr   r   r   r   r   r   _abstract_spanr
   instrumentationr   r   __all__objectstrr   r   r    r(   r   <module>r2      s   4 I % ; ;  ( (  h v # (  ?,/  ?I  ?  ?F-x -C -r(   