o
    Á¿i!  ã                   @   s<   d dl Z d dlmZ e  d¡ZdZe  d¡ZdZdd„ Z	dS )	é    N)Úelasticsearchz/([0-9]+)([/\?]|$)z/?\2z	[0-9]{2,}ú?c                 C   sD   |   tj¡}|   tj¡}t t|¡}t t|¡}dj	||d| _
| S )a  Quantize an elasticsearch span

    We want to extract a meaningful `resource` from the request.
    We do it based on the method + url, with some cleanup applied to the URL.

    The URL might a ID, but also it is common to have timestamped indexes.
    While the first is easy to catch, the second should probably be configurable.

    All of this should probably be done in the Agent. Later.
    z{method} {url})ÚmethodÚurl)Úget_tagÚmetadataÚURLÚMETHODÚ	ID_REGEXPÚsubÚID_PLACEHOLDERÚINDEX_REGEXPÚINDEX_PLACEHOLDERÚformatÚresource)Úspanr   r   Úquantized_url© r   úc/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/contrib/internal/elasticsearch/quantize.pyÚquantize   s   r   )
ÚreÚddtrace.extr   r   Úcompiler
   r   r   r   r   r   r   r   r   Ú<module>   s    

