
    g@                        d dl mZ d dlZd dlmZmZ 	 d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ erd d	lmZ d d
lmZ 	 	 	 	 	 	 	 	 	 	 ddZdddZy# e$ r	  ed      w xY w)    )annotationsN)TYPE_CHECKINGAny)RedisInstrumentor)RequestHookResponseHookz`logfire.instrument_redis()` requires the `opentelemetry-instrumentation-redis` package.
You can install this with:
    pip install 'logfire[redis]')ATTRIBUTES_MESSAGE_KEY)truncate_string)Span)
Connectionc                X    | rt        |      } t               j                  d||d| y)zInstrument the `redis` module so that spans are automatically created for each operation.

    See the `Logfire.instrument_redis` method for details.
    )request_hookresponse_hookN )_capture_statement_hookr   
instrument)capture_statementr   r   kwargss       Y/var/www/openai/venv/lib/python3.12/site-packages/logfire/_internal/integrations/redis.pyinstrument_redisr      s0     .|<"""dMd]cd    c                h     t        j                  t        dd      	 	 	 	 	 	 	 	 	 	 	 	 d fd}|S )N   z...)
max_lengthmiddlec           	         t        t        t        |            }| j                  ddj	                  |             | j                  t
        dj	                  t        |                    | ||g|i | y y )Nzdb.statement )listmapstrset_attributejoinr	   )spaninstancecommandargsr   str_commandr   truncate_values         r   _capture_statementz3_capture_statement_hook.<locals>._capture_statement-   sr     3sG,->388K+@A1388CP[<\3]^#xB4B6B $r   )r#   r   r$   r   r%   ztuple[object, ...]r&   r   r   r   returnNone)	functoolspartialr
   )r   r)   r(   s   ` @r   r   r   *   s[    &&2eTNCC(C3ECNQC]`C	C r   )
r   boolr   RequestHook | Noner   zResponseHook | Noner   r   r*   r+   )N)r   r/   r*   r   )
__future__r   r,   typingr   r   #opentelemetry.instrumentation.redisr   logfire.integrations.redisr   r   ImportErrorRuntimeErrorlogfire._internal.constantsr	   logfire._internal.utilsr
   opentelemetry.tracer   redisr   r   r   r   r   r   <module>r:      s    "  %	ED ? 3( ee %e '	e
 e 
e"A  
	+ s   A A