o
    i|
                     @   s2  U d dl mZ d dl m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	 d dl
mZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ edZeeZeeejZee d< deddfddZ!deddfddZ"dede#e de$e%ef defddZ&dS )    )FunctionType)
ModuleTypeN)Any)TypeVar)config)http)core)maybe_stringify)	COMPONENT)
get_logger)IntegrationConfig)	func_name)is_wrapped_with)unwrap)wrapTconfig_djangodjango_template_basereturnc                 C   sH   t jsdS t| dd}|rt|dsdS t|jts"t|jt dS dS )zO
    Instrument the django template base module to wrap the render method.
    NTemplaterender)r   instrument_templatesgetattrhasattrr   r   traced_renderr   r   r    r   ]/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/contrib/internal/django/templates.pyinstrument_module   s   r   c                 C   s.   t | dd }|rt|dsd S t|jt d S )Nr   r   )r   r   r   r   r   r   r   r   r   uninstrument_module-   s   r   funcargskwargsc                 C   s   t js
| |i |S |d }tt|dd }|r|}nt| d}tt ji}|r-||d< t|dd }|r;t||d< tjdd|t	j
|d | |i |W  d    S 1 sXw   Y  d S )	Nr   namez.renderzdjango.template.nameenginezdjango.template.engine.classzdjango.template.render)	span_nameresource	span_typetags)r   r   r	   r   r   r
   integration_namer   context_with_datar   TEMPLATE)r    r!   r"   instancetemplate_namer&   r(   r$   r   r   r   r   6   s,   
$r   )'typesr   r   typingr   r   ddtracer   ddtrace.extr   ddtrace.internalr   ddtrace.internal.compatr	   ddtrace.internal.constantsr
   ddtrace.internal.loggerr   %ddtrace.internal.settings.integrationr    ddtrace.internal.utils.importlibr   ddtrace.internal.wrappingr   r   r   r   __name__logcastdjangor   __annotations__r   r   tupledictstrr   r   r   r   r   <module>   s,    *	