o
    i                     @   sv   d dl Z d dlZd dlmZ eeZdedeeeef  fddZ	deddfddZ
d	ed
eddfddZdd ZdS )    N)
get_loggerraw_dd_trace_methodsreturnc                 C   s   | sg S g }|  dD ]Q}d|vrtd| g   S | d\}}|dkr0td| g   S | dD ]&}t| dd sTtd	||d
krKdnd g     S |||f q5q|S )a  Return a list of the module,methodname tuples to trace based on the
    specification of DD_TRACE_METHODS.

    DD_TRACE_METHODS is specified to be FullyQualifiedModuleName:comma-separated-methods;...

    Note that support for wildcard methods with * is not implemented.
    ;:zkInvalid DD_TRACE_METHODS: %s. Methods must be specified after a colon following the fully qualified module.__main__zInvalid DD_TRACE_METHODS: %s. Methods cannot be traced on the __main__ module. __main__ when sitecustomize module is run is the builtin __main__.,.zInvalid method name: %r. %s z You might have a trailing comma.z.Method names must be valid Python identifiers.)splitlogwarningstrisidentifierappend)r   dd_trace_methodsqualified_methodsqualified_method_prefixmethodsmethod r   Q/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/internal/tracemethods.py_parse_trace_methods   s<   	r   c                 C   s    t | D ]	\}}t|| qdS )z%Install tracing on the given methods.N)r   trace_method)r   module_namemethod_namer   r   r   _install_trace_methodsA   s   r   moduler   c                    s   t j|  fdd}d S )Nc                    s   t |  t d S )N)wraptwrap_function_wrappertrace_wrapper)mr   r   r   _H   s   ztrace_method.<locals>._)r   importerwhen_imported)r   r   r$   r   r#   r   r   G   s   
r   c                    s   ddl m j t|dr|jtd urd|jj f  tr1 fdd}||i |S jd d}|	d	d
 |i |W  d    S 1 sPw   Y  d S )Nr   )tracer	__class__z%s.%sc                     sT   j d d}|dd | i |I d H W  d    S 1 s#w   Y  d S )Ntrace.annotationresource	componenttrace)r-   _set_tag_str)akwspanr+   r'   wrappedr   r   async_wrapperW   s
   $z$trace_wrapper.<locals>.async_wrapperr)   r*   r,   r-   )
ddtrace.tracer'   __name__hasattrr(   typeinspectiscoroutinefunctionr-   r.   )r3   instanceargskwargsr4   r1   r   r2   r   r!   M   s   
$r!   )r9   r   ddtrace.internal.loggerr   r6   r   r   listtupler   r   r   r!   r   r   r   r   <module>   s    6