o
    i|                     @   s   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 eeef Zed	d
G dd deZdS )    )	dataclass)fieldN)SpanProcessor)Span)	SpanTypes)ensure_text)LockF)eqc                   @   s   e Zd ZU eeddddZeed< eeddddZee	e
e f ed< eeddddZejed< eddddZeed< dd
dZdedd	fddZdedd	fddZdeeee	e
e f f fddZdddZd	S )EndpointCallCounterProcessorF)default_factoryinitreprcompareendpoint_countsendpoint_to_span_ids_endpoint_counts_lock)defaultr   r   _enabledreturnNc                 C   s
   d| _ d S )NT)r   self r   d/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/internal/processor/endpoint_call_counter.pyenable   s   
z#EndpointCallCounterProcessor.enablespanc                 C   s   d S Nr   )r   r   r   r   r   on_span_start   s   z*EndpointCallCounterProcessor.on_span_startc                 C   s   | j sd S |j|krN|jtjkrPt|jdd}|j}| j' | j	
|dd | j	|< || jvr4g | j|< | j| | W d    d S 1 sGw   Y  d S d S d S )Nbackslashreplace)errorsr      )r   _local_root	span_typer   WEBr   resourcespan_idr   r   getr   append)r   r   r#   r$   r   r   r   on_span_finish   s   

"z+EndpointCallCounterProcessor.on_span_finishc                 C   sJ   | j  | j}i | _| j}i | _||fW  d    S 1 sw   Y  d S r   )r   r   r   )r   countsspan_idsr   r   r   reset+   s   $z"EndpointCallCounterProcessor.resetc                 C   s   t  | _d S r   )r   r   r   r   r   r   _after_fork3   s   z(EndpointCallCounterProcessor._after_fork)r   N)__name__
__module____qualname__r   dictr   EndpointCountsType__annotations__r   strlistintr   r   typingContextManagerr   boolr   r   r   r'   tupler*   r+   r   r   r   r   r
      s   
 $
"r
   )dataclassesr   r   r5   ddtrace._trace.processorr   ddtrace._trace.spanr   ddtrace.extr   ddtrace.internal.compatr   ddtrace.internal.threadsr   r/   r2   r4   r0   r
   r   r   r   r   <module>   s    