o
    i
                  	   @   s.  d dl Z d dl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 edeee jdddd defddZedd e dD Zedk rede dde
dd deeef fdd Zd!d" Z d#d$ Z!dS )%    N)wrap_function_wrapper)config)context_provider)DDTraceDeprecationWarning)asbool)unwrap)	deprecate   )application)
decorators)handlers)templatetornadoDD_TORNADO_DISTRIBUTED_TRACINGT)default)distributed_tracingreturnc                   C   s   t tddS )Nversionz0.0.0)getattrr    r   r   Z/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/contrib/internal/tornado/patch.pyget_version   s   r   c                 C   s   g | ]}t |qS r   )int).0xr   r   r   
<listcomp>    s    r   .)   r	   r   zTornado z is deprecatedzUse Tornado v6.1 or later and configure tracing using environment variables and ``ddtrace-run`` or ``import ddtrace.auto`` instead.z4.0.0)messagecategoryremoval_versionc                   C   s   ddiS )Nr   z>=6.1r   r   r   r   r   _supported_versions,   s   r!   c                   C   s   t tddrdS dt_tddtj tddtj tddtj tdd	tj	 tdd
tj
 tddtj ttj_tjtj_dS )z}
    Tracing function that patches the Tornado web application so that it will be
    traced using the given ``tracer``.
    __datadog_patchFNTztornado.webzApplication.__init__zRequestHandler._executezRequestHandler.on_finishzRequestHandler.log_exceptionzRequestHandler.flushztornado.templatezTemplate.generate)r   r   r"   _wr
   tracer_configr   execute	on_finishlog_exception	_on_flushr   generater   ddtracetracerr   wrap_executor_wrap_executorr   r   r   r   patch0   s   r.   c                   C   s`   t tddsdS dt_ttjjd ttjjd ttjjd ttjjd ttjjd dS )	zD
    Remove all tracing functions in a Tornado web application.
    r"   FN_executer&   r'   __init__r)   )	r   r   r"   _uwebRequestHandlerApplicationr   Templater   r   r   r   unpatchK   s   r6   )"osr   wraptr   r#   r*   r   .ddtrace.contrib.internal.tornado.stack_contextr   #ddtrace.internal.utils.deprecationsr   ddtrace.internal.utils.formatsr   ddtrace.internal.utils.wrappersr   r1   ddtrace.vendor.debtcollectorr    r
   r   r   r   _adddictgetenvstrr   tuplesplitVERSION_TUPLEr!   r.   r6   r   r   r   r   <module>   s@    
	