o
    i                     @   sV   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G dd dZd	S )
    )OrderedDict)	monotonic)Any)Callable)configz-infc                   @   s   e Zd ZdZdZdedef ddfddZd	eedf deedf fd
dZ	de
defddZdddZdefddZd	ededefddZdS )deduplicationi     func.returnNc                 C   s   || _ t | _d S N)r	   r   reported_logs)selfr	    r   R/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/appsec/_deduplications.py__init__   s   zdeduplication.__init__argsc                 C   s   |S r   r   )r   r   r   r   r   _extract   s   zdeduplication._extractraw_log_hashc                 C   s   | j |dS )Ng        )r   get)r   r   r   r   r   get_last_time_reported   s   z$deduplication.get_last_time_reportedc                 C   s   | j   dS )zT
        Reset the cache of reported logs
        For testing purposes only
        N)r   clearr   r   r   r   _reset_cache   s   zdeduplication._reset_cachec                 C   s   t jS r   )
asm_config_asm_deduplication_enabledr   r   r   r   _check_deduplication!   s   z"deduplication._check_deduplicationkwargsc                 O   s   d}|   rJtddd | |D }| j|t| j }t }||krH|| j|< | j	| t
| j| jkr@| jjdd | j|i |}|S | j|i |}|S )NF c                 S   s   g | ]}t |qS r   )str).0argr   r   r   
<listcomp>'   s    z*deduplication.__call__.<locals>.<listcomp>)last)r   hashjoinr   r   r   M_INF_time_lapser   move_to_endlen_max_cache_sizepopitemr	   )r   r   r   resultr   last_reported_timestampcurrentr   r   r   __call__$   s   
zdeduplication.__call__)r
   N)__name__
__module____qualname__r&   r)   r   r   r   tupler   intfloatr   r   boolr   r.   r   r   r   r   r      s    "
r   N)collectionsr   timer   typingr   r   ddtrace.internal.settings.asmr   r   r4   r%   r   r   r   r   r   <module>   s    