o
    Á¿i’  ã                   @   s8   d dl Z d dlmZ d dlmZ d dlmZ dd„ ZdS )é    N)ÚPin)Úasbool)Útracerc                    s,   | |i |¤Ž ˆ j ‰‡ ‡fdd„}|ˆ _ dS )a  
    This seems rather odd. But to track hits, we need to patch the wrapped function that
    dogpile passes to the region and locks. Unfortunately it's a closure defined inside
    the get_or_create* methods themselves, so we can't easily patch those.
    c                     sî   t  tj¡} | r|  ¡ sˆƒ S d}d}z=ˆƒ \}}|tjjju}ˆ  |¡p&d}||fW t 	¡ }|rP| 
dt| d¡p;dƒo>|¡ | 
dt| d¡pJdƒpM|¡ S S t 	¡ }|rv| 
dt| d¡padƒod|¡ | 
dt| d¡ppdƒps|¡ w w )NFTÚhitÚTrueÚexpiredÚFalse)r   Úget_fromÚdogpileÚcacheÚenabledÚapiÚNO_VALUEÚ_is_expiredr   Úcurrent_spanÚset_tagr   Úget_tag)Úpinr   r   ÚvalueÚcreatedtimeÚspan©ÚinstanceÚori_backend_fetcher© ú_/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/contrib/internal/dogpile_cache/lock.pyÚwrapped_backend_fetcher   s(   
 þÿ þz0_wrap_lock_ctor.<locals>.wrapped_backend_fetcherN)Úvalue_and_created_fn)Úfuncr   ÚargsÚkwargsr   r   r   r   Ú_wrap_lock_ctor   s   
r!   )r
   Úddtrace._trace.pinr   Úddtrace.internal.utils.formatsr   Úddtrace.tracer   r!   r   r   r   r   Ú<module>   s
    