o
    Á¿i	  ã                   @   s@   d dl mZ d dlmZ d dlmZ dd„ Zdd„ Zdd	„ Zd
S )é    )Úparse_addresses)Ú_extract_conn_tags)Únetc                 C   s.   t |ddƒrd | |j¡}| ¡ S | }| ¡ S )zB
    Combine the resource name with the cache prefix (if any)
    Ú
key_prefixNz{} {})ÚgetattrÚformatr   Úlower)ÚresourceÚcacheÚname© r   ú^/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/contrib/internal/flask_cache/utils.pyÚ_resource_from_cache_prefix   s
   ýr   c                 C   s<   t | ddƒ}|du rdD ]}t | |dƒ}|dur |S q|S )zS
    Get the client from the cache instance according to the current operation
    Ú_clientN)Ú_write_clientÚ_read_clientÚ_read_clients)r   )r
   ÚclientÚattrr   r   r   Ú_extract_client   s   þr   c                 C   sÖ   i }t | dƒr1t| jtƒr/t| jƒdkr/| jd j}|d |tj< |d |tj< |d |tj	< |S t | dƒrFt
| jjƒ}|jdi |¤Ž |S t | dƒrit| jƒ}|ri|d \}}}}||tj< ||tj< ||tj	< |S )z7
    For the given client extracts connection tags
    Úserversr   é   Úconnection_poolÚ	addressesNr   )ÚhasattrÚ
isinstancer   ÚlistÚlenÚaddressr   ÚTARGET_HOSTÚTARGET_PORTÚSERVER_ADDRESSÚextract_redis_tagsr   Úconnection_kwargsÚupdater   r   )r   ÚtagsÚcontact_pointÚ
redis_tagsÚaddrsÚ_ÚhostÚportr   r   r   r   $   s(   

ó

÷



r   N)	Ú&ddtrace.contrib.internal.pylibmc.addrsr   Ú$ddtrace.contrib.internal.redis_utilsr   r"   Úddtrace.extr   r   r   r   r   r   r   Ú<module>   s   