Ë
    §Œj9_  ã                   óF  — d Z ddlZddlZddlmZ ddlmZmZmZm	Z	 er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mZmZmZmZmZmZmZmZ dd
lmZmZ ddlm Z m!Z!  ejD                  e#«      Z$	 ddl%m&Z& dZ' G d„ de«      Z, G d„ d«      Z-y# e($ r dZ'dZ)dZ*dZ&dZ+Y Œ'w xY w)z¤
OpenTelemetry metrics collector for redis-py.

This module defines and manages all metric instruments according to
OTel semantic conventions for database clients.
é    N)ÚEnum)ÚTYPE_CHECKINGÚCallableÚOptionalÚUnion)ÚConnectionPool)ÚAsyncDatabase)ÚConnectionPoolInterface)ÚSyncDatabase)	Ú$REDIS_CLIENT_CONNECTION_CLOSE_REASONÚ$REDIS_CLIENT_CONNECTION_NOTIFICATIONÚAttributeBuilderÚConnectionStateÚ	CSCReasonÚ	CSCResultÚGeoFailoverReasonÚPubSubDirectionÚget_pool_name)ÚMetricGroupÚ
OTelConfig)Údeprecated_argsÚdeprecated_function)ÚMeterTFc                   ó   — e Zd ZdZdZdZdZy)ÚCloseReasona  
    Enum representing the reason why a Redis client connection was closed.

    Values:
        APPLICATION_CLOSE: The connection was closed intentionally by the application
            (for example, during normal shutdown or explicit cleanup).
        ERROR: The connection was closed due to an unexpected error
            (for example, network failure or protocol error).
        HEALTHCHECK_FAILED: The connection was closed because a health check
            or liveness check for the connection failed.
    Úapplication_closeÚerrorÚhealthcheck_failedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚAPPLICATION_CLOSEÚERRORÚHEALTHCHECK_FAILED© ó    úe/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/redis/observability/metrics.pyr   r   0   s   „ ñ
ð ,ÐØ€EØ-Ñr'   r   c                   ód  — e Zd ZdZdZdZdedefd„ZdOd	„Z	dOd
„Z
dOd„ZdOd„ZdOd„ZdOd„ZdOd„Z	 	 	 	 	 	 	 dPdee   dee   dee   dee   dee   dee   dee   fd„Zdededededef
d„Zded   ded   defd„Z	 dQded ed!eddfd"„Z ed#d$¬%«      d&eddfd'„«       Zd&eddfd(„Zdeddfd)„Z d*ed+   d,e!ddfd-„Z"ded,e!ddfd.„Z# e$d/gd0d1¬2«      	 	 	 	 	 	 	 	 	 dRd3ed,e!dee   dee   d4ee   d/ee   dee   dee   dee   dee   d5ee   ddfd6„«       Z%	 	 dSd7ee&   dee   ddfd8„Z'd9eded:eddfd;„Z(deddfd<„Z)	 	 dSd=e*d>ee   d?ee   ddfd@„Z+ e$dAgdBd1¬2«      	 	 	 dTdCe!dDee   dEee   dAee   ddf
dF„«       Z,	 dUdGee-   ddfdH„Z.	 dUdIedee/   ddfdJ„Z0dKeddfdL„Z1e2de!fdM„«       Z3defdN„Z4y)VÚRedisMetricsCollectorap  
    Collects and records OpenTelemetry metrics for Redis operations.

    This class manages all metric instruments and provides methods to record
    various Redis operations including connection pool events, command execution,
    and cluster-specific operations.

    Args:
        meter: OpenTelemetry Meter instance
        config: OTel configuration object
    zredis-pyz1.0.0ÚmeterÚconfigc                 ó~  — t         st        d«      ‚|| _        || _        t	        «       | _        t        j                  | j                  j                  v r| j                  «        t        j                  | j                  j                  v r| j                  «        t        j                  | j                  j                  v r| j                  «        t        j                  | j                  j                  v r| j                  «        t        j                   | j                  j                  v r| j#                  «        t        j$                  | j                  j                  v r| j'                  «        t        j(                  | j                  j                  v r| j+                  «        t,        j/                  d«       y )NzROpenTelemetry API is not installed. Install it with: pip install opentelemetry-apiz!RedisMetricsCollector initialized)ÚOTEL_AVAILABLEÚImportErrorr+   r,   r   Úattr_builderr   Ú
RESILIENCYÚmetric_groupsÚ_init_resiliency_metricsÚCOMMANDÚ_init_command_metricsÚCONNECTION_BASICÚ_init_connection_basic_metricsÚCONNECTION_ADVANCEDÚ!_init_connection_advanced_metricsÚPUBSUBÚ_init_pubsub_metricsÚ	STREAMINGÚ_init_streaming_metricsÚCSCÚ_init_csc_metricsÚloggerÚinfo)Úselfr+   r,   s      r(   Ú__init__zRedisMetricsCollector.__init__R   s<  € ÝÜðAóð ð
 ˆŒ
ØˆŒÜ,Ó.ˆÔô ×!Ñ! T§[¡[×%>Ñ%>Ñ>Ø×)Ñ)Ô+ä×Ñ $§+¡+×";Ñ";Ñ;Ø×&Ñ&Ô(ä×'Ñ'¨4¯;©;×+DÑ+DÑDØ×/Ñ/Ô1ä×*Ñ*¨d¯k©k×.GÑ.GÑGØ×2Ñ2Ô4ä×Ñ §¡×!:Ñ!:Ñ:Ø×%Ñ%Ô'ä× Ñ  D§K¡K×$=Ñ$=Ñ=Ø×(Ñ(Ô*ä�?‰?˜dŸk™k×7Ñ7Ñ7Ø×"Ñ"Ô$ä�‰Ð7Õ8r'   ÚreturnNc                 óÖ   — | j                   j                  ddd¬«      | _        | j                   j                  ddd¬«      | _        | j                   j                  dd	d
¬«      | _        y)zInitialize resiliency metrics.zredis.client.errorsz{error}z`A counter of all errors (both returned to the user and handled internally in the client library)©ÚnameÚunitÚdescriptionz&redis.client.maintenance.notificationsz{notification}z,Tracks server-side maintenance notificationsz"redis.client.geofailover.failoversz{geofailover}z6Total count of failovers happened using MultiDbClient.N)r+   Úcreate_counterÚclient_errorsÚmaintenance_notificationsÚgeo_failovers©rB   s    r(   r3   z.RedisMetricsCollector._init_resiliency_metricsv   sv   € à!ŸZ™Z×6Ñ6Ø&ØØzð 7ó 
ˆÔð *.¯©×)BÑ)BØ9Ø!ØFð *Có *
ˆÔ&ð "ŸZ™Z×6Ñ6Ø5Ø ØPð 7ó 
ˆÕr'   c                 óT  — | j                   j                  ddd| j                  j                  ¬«      | _        | j                   j                  ddd¬«      | _        | j                   j                  d	d
d¬«      | _        d| _	        | j                   j                  ddd¬«      | _
        y)z$Initialize basic connection metrics.z db.client.connection.create_timeÚszTime to create a new connection©rG   rH   rI   Ú#explicit_bucket_boundaries_advisoryz'redis.client.connection.relaxed_timeoutz{relaxation}z@Counts up for relaxed timeout, counts down for unrelaxed timeoutrF   zredis.client.connection.handoffz	{handoff}zIConnections that have been handed off (e.g., after a MOVING notification)Nzdb.client.connection.countú{connection}z4Number of connections currently in the pool by state)r+   Úcreate_histogramr,   Úbuckets_connection_create_timeÚconnection_create_timeÚcreate_up_down_counterÚconnection_relaxed_timeoutrJ   Úconnection_handoffÚconnection_countÚconnection_count_updownrN   s    r(   r7   z4RedisMetricsCollector._init_connection_basic_metricsŠ   s¶   € à&*§j¡j×&AÑ&AØ3ØØ9Ø04·±×0ZÑ0Zð	 'Bó '
ˆÔ#ð +/¯*©*×*KÑ*KØ:ØØZð +Ló +
ˆÔ'ð #'§*¡*×";Ñ";Ø2ØØcð #<ó #
ˆÔð !%ˆÔð (,§z¡z×'HÑ'HØ-ØØNð (Ió (
ˆÕ$r'   c                 ó   — | j                   j                  ddd¬«      | _        | j                   j                  ddd| j                  j
                  ¬«      | _        | j                   j                  d	d
d¬«      | _        y)z'Initialize advanced connection metrics.zdb.client.connection.timeoutsz	{timeout}zaThe number of connection timeouts that have occurred trying to obtain a connection from the pool.rF   zdb.client.connection.wait_timerP   z/Time to obtain an open connection from the poolrQ   zredis.client.connection.closedrS   z"Total number of closed connectionsN)r+   rJ   Úconnection_timeoutsrT   r,   Úbuckets_connection_wait_timeÚconnection_wait_timeÚconnection_closedrN   s    r(   r9   z7RedisMetricsCollector._init_connection_advanced_metrics¬   sƒ   € à#'§:¡:×#<Ñ#<Ø0ØØ{ð $=ó $
ˆÔ ð %)§J¡J×$?Ñ$?Ø1ØØIØ04·±×0XÑ0Xð	 %@ó %
ˆÔ!ð "&§¡×!:Ñ!:Ø1ØØ<ð ";ó "
ˆÕr'   c                 ót   — | j                   j                  ddd| j                  j                  ¬«      | _        y)z0Initialize command execution metric instruments.zdb.client.operation.durationrP   zCommand execution durationrQ   N)r+   rT   r,   Úbuckets_operation_durationÚoperation_durationrN   s    r(   r5   z+RedisMetricsCollector._init_command_metricsÁ   s4   € à"&§*¡*×"=Ñ"=Ø/ØØ4Ø04·±×0VÑ0Vð	 #>ó #
ˆÕr'   c                 óJ   — | j                   j                  ddd¬«      | _        y)z%Initialize PubSub metric instruments.zredis.client.pubsub.messagesz	{message}z&Tracks published and received messagesrF   N)r+   rJ   Úpubsub_messagesrN   s    r(   r;   z*RedisMetricsCollector._init_pubsub_metricsÊ   s'   € à#Ÿz™z×8Ñ8Ø/ØØ@ð  9ó  
ˆÕr'   c                 ót   — | j                   j                  ddd| j                  j                  ¬«      | _        y)z(Initialize Streaming metric instruments.zredis.client.stream.lagrP   zkEnd-to-end lag per message, showing how stale are the messages when the application starts processing them.rQ   N)r+   rT   r,   Ú"buckets_stream_processing_durationÚ
stream_lagrN   s    r(   r=   z-RedisMetricsCollector._init_streaming_metricsÒ   s6   € àŸ*™*×5Ñ5Ø*Øð FØ04·±×0^Ñ0^ð	 6ó 
ˆ�r'   c                 óÖ   — | j                   j                  ddd¬«      | _        | j                   j                  ddd¬«      | _        | j                   j                  dd	d
¬«      | _        y)z8Initialize Client Side Caching (CSC) metric instruments.zredis.client.csc.requestsz	{request}z)The total number of requests to the cacherF   zredis.client.csc.evictionsz
{eviction}z#The total number of cache evictionszredis.client.csc.network_savedÚByz,The total number of bytes saved by using CSCN)r+   rJ   Úcsc_requestsÚcsc_evictionsÚcsc_network_savedrN   s    r(   r?   z'RedisMetricsCollector._init_csc_metricsÛ   su   € à ŸJ™J×5Ñ5Ø,ØØCð 6ó 
ˆÔð "ŸZ™Z×6Ñ6Ø-ØØ=ð 7ó 
ˆÔð "&§¡×!:Ñ!:Ø1ØØFð ";ó "
ˆÕr'   Úserver_addressÚserver_portÚnetwork_peer_addressÚnetwork_peer_portÚ
error_typeÚretry_attemptsÚis_internalc                 óD  — t        | d«      sy| j                  j                  ||¬«      }|j                  | j                  j	                  |||¬«      «       |j                  | j                  j                  ||¬«      «       | j                  j                  d|¬«       y)a�  
        Record error count

        Args:
            server_address: Server address
            server_port: Server port
            network_peer_address: Network peer address
            network_peer_port: Network peer port
            error_type: Error type
            retry_attempts: Retry attempts
            is_internal: Whether the error is internal (e.g., timeout, network error)
        rK   N©rn   ro   )rp   rq   rs   )rr   rt   é   ©Ú
attributes)Úhasattrr0   Úbuild_base_attributesÚupdateÚbuild_operation_attributesÚbuild_error_attributesrK   Úadd)	rB   rn   ro   rp   rq   rr   rs   rt   Úattrss	            r(   Úrecord_error_countz(RedisMetricsCollector.record_error_countñ   sª   € ô, �t˜_Ô-Øà×!Ñ!×7Ñ7Ø)Ø#ð 8ó 
ˆð 	�‰Ø×Ñ×8Ñ8Ø%9Ø"3Ø-ð 9ó ô	
ð 	�‰Ø×Ñ×4Ñ4Ø%Ø'ð 5ó ô	
ð 	×Ñ×Ñ˜q¨UÐÕ3r'   Úmaint_notificationc                 óü   — t        | d«      sy| j                  j                  ||¬«      }|j                  | j                  j	                  ||¬«      «       ||t
        <   | j                  j                  d|¬«       y)a7  
        Record maintenance notification count

        Args:
            server_address: Server address
            server_port: Server port
            network_peer_address: Network peer address
            network_peer_port: Network peer port
            maint_notification: Maintenance notification
        rL   Nrv   )rp   rq   rw   rx   )rz   r0   r{   r|   r}   r   rL   r   )rB   rn   ro   rp   rq   r‚   r€   s          r(   Úrecord_maint_notification_countz5RedisMetricsCollector.record_maint_notification_count  s‡   € ô$ �tÐ8Ô9Øà×!Ñ!×7Ñ7Ø)Ø#ð 8ó 
ˆð
 	�‰Ø×Ñ×8Ñ8Ø%9Ø"3ð 9ó ô	
ð 7IˆÔ2Ñ3Ø×&Ñ&×*Ñ*¨1¸Ð*Õ?r'   Ú	fail_from)r   r	   Úfail_toÚreasonc                 ó’   — t        | d«      sy| j                  j                  |||¬«      }| j                  j	                  d|¬«      S )z´
        Record geo failover

        Args:
            fail_from: Database failed from
            fail_to: Database failed to
            reason: Reason for the failover
        rM   N)r…   r†   r‡   rw   rx   )rz   r0   Úbuild_geo_failover_attributesrM   r   )rB   r…   r†   r‡   r€   s        r(   Úrecord_geo_failoverz)RedisMetricsCollector.record_geo_failoverC  sT   € ô �t˜_Ô-Øà×!Ñ!×?Ñ?ØØØð @ó 
ˆð ×!Ñ!×%Ñ% a°EÐ%Ó:Ð:r'   Ú	pool_nameÚconnection_stateÚcounterc                 ó’   — t        | d«      sy| j                  j                  ||¬«      }| j                  j	                  ||¬«       y)a  
        Record a connection count change for a single state.

        Args:
            pool_name: Connection pool name
            connection_state: State to update (IDLE or USED)
            counter: Number to add (positive) or subtract (negative)
        r[   N)r‹   rŒ   rx   )rz   r0   Úbuild_connection_attributesr[   r   )rB   r‹   rŒ   r�   r€   s        r(   Úrecord_connection_countz-RedisMetricsCollector.record_connection_count]  sN   € ô �tÐ6Ô7Øà×!Ñ!×=Ñ=ØØ-ð >ó 
ˆð 	×$Ñ$×(Ñ(¨¸UÐ(ÕCr'   z{Connection count is now tracked via record_connection_count(). This functionality will be removed in the next major versionz7.4.0)r‡   ÚversionÚcallbackc                 óœ   — t         j                  | j                  j                  vry| j                  j                  ddd|g¬«      | _        y)zŸ
        Initialize observable gauge for connection count metric.

        Args:
            callback: Callback function to retrieve connection counts
        Nz%db.client.connection.count.deprecatedrS   zŒThe number of connections that are currently in state described by the state attribute (deprecated - use db.client.connection.count instead)©rG   rH   rI   Ú	callbacks)r   r6   r,   r2   r+   Úcreate_observable_gaugerZ   ©rB   r’   s     r(   Úinit_connection_countz+RedisMetricsCollector.init_connection_countt  sO   € ô ×'Ñ'¨t¯{©{×/HÑ/HÑHØð
 !%§
¡
× BÑ BØ8Øðeà�jð !Có !
ˆÕr'   c                 ó´   — t         j                  | j                  j                  vr| j                  sy| j
                  j                  ddd|g¬«      | _        y)z–
        Initialize observable gauge for CSC items metric.

        Args:
            callback: Callback function to retrieve CSC items count
        Nzredis.client.csc.itemsz{item}z5The total number of cached responses currently storedr”   )r   r>   r,   r2   Ú	csc_itemsr+   r–   r—   s     r(   Úinit_csc_itemsz$RedisMetricsCollector.init_csc_items‘  sL   € ô �?‰? $§+¡+×";Ñ";Ñ;ÀDÇNÂNØàŸ™×;Ñ;Ø)ØØOØ�jð	 <ó 
ˆ�r'   c                 ó�   — t        | d«      sy| j                  j                  |¬«      }| j                  j	                  d|¬«       y)zo
        Record a connection timeout event.

        Args:
            pool_name: Connection pool name
        r]   N©r‹   rw   rx   )rz   r0   r�   r]   r   ©rB   r‹   r€   s      r(   Úrecord_connection_timeoutz/RedisMetricsCollector.record_connection_timeout¥  sD   € ô �tÐ2Ô3Øà×!Ñ!×=Ñ=È	Ð=ÓRˆØ× Ñ ×$Ñ$ Q°5Ð$Õ9r'   Úconnection_pool)r
   r   Úduration_secondsc                 ó¢   — t        | d«      sy| j                  j                  t        |«      ¬«      }| j                  j                  ||¬«       y)zÁ
        Record time taken to create a new connection.

        Args:
            connection_pool: Connection pool implementation
            duration_seconds: Creation time in seconds
        rV   Nr�   rx   )rz   r0   r�   r   rV   Úrecord)rB   r    r¡   r€   s       r(   Úrecord_connection_create_timez3RedisMetricsCollector.record_connection_create_time²  sQ   € ô �tÐ5Ô6Øà×!Ñ!×=Ñ=Ü# OÓ4ð >ó 
ˆð 	×#Ñ#×*Ñ*Ð+;ÈÐ*ÕNr'   c                 ó�   — t        | d«      sy| j                  j                  |¬«      }| j                  j	                  ||¬«       y)z·
        Record time taken to obtain a connection from the pool.

        Args:
            pool_name: Connection pool name
            duration_seconds: Wait time in seconds
        r_   Nr�   rx   )rz   r0   r�   r_   r£   )rB   r‹   r¡   r€   s       r(   Úrecord_connection_wait_timez1RedisMetricsCollector.record_connection_wait_timeÆ  sE   € ô �tÐ3Ô4Øà×!Ñ!×=Ñ=È	Ð=ÓRˆØ×!Ñ!×(Ñ(Ð)9ÀeÐ(ÕLr'   Ú
batch_sizezXThe batch_size argument is no longer used and will be removed in the next major version.z7.2.1)Úargs_to_warnr‡   r‘   Úcommand_nameÚdb_namespaceÚis_blockingc           	      ó€  — t        | d«      sy| j                  j                  |«      sy| j                  j	                  |||¬«      }|j                  | j                  j                  |||	|
|¬«      «       |j                  | j                  j                  |¬«      «       | j                  j                  ||¬«       y)aÀ  
        Record command execution duration.

        Args:
            command_name: Redis command name (e.g., 'GET', 'SET', 'MULTI')
            duration_seconds: Execution time in seconds
            server_address: Redis server address
            server_port: Redis server port
            db_namespace: Redis database index
            batch_size: Number of commands in batch (for pipelines/transactions)
            error_type: Error type if operation failed
            network_peer_address: Resolved peer address
            network_peer_port: Peer port number
            retry_attempts: Number of retry attempts made
            is_blocking: Whether the operation is a blocking command
        rc   N)rn   ro   rª   )r©   rp   rq   rs   r«   ©rr   rx   )
rz   r,   Úshould_track_commandr0   r{   r|   r}   r~   rc   r£   )rB   r©   r¡   rn   ro   rª   r§   rr   rp   rq   rs   r«   r€   s                r(   Úrecord_operation_durationz/RedisMetricsCollector.record_operation_durationÚ  sÌ   € ôF �tÐ1Ô2Øð �{‰{×/Ñ/°Ô=Øð ×!Ñ!×7Ñ7Ø)Ø#Ø%ð 8ó 
ˆð 	�‰Ø×Ñ×8Ñ8Ø)Ø%9Ø"3Ø-Ø'ð 9ó ô	
ð 	�‰Ø×Ñ×4Ñ4Ø%ð 5ó ô	
ð
 	×Ñ×&Ñ&Ð'7ÀEÐ&ÕJr'   Úclose_reasonc                 ó  — t        | d«      sy| j                  j                  «       }|r|j                  |t        <   |j                  | j                  j                  |¬«      «       | j                  j                  d|¬«       y)zÍ
        Record a connection closed event.

        Args:
            close_reason: Reason for closing (e.g. 'error', 'application_close')
            error_type: Error type if closed due to error
        r`   Nr­   rw   rx   )	rz   r0   r�   Úvaluer   r|   r~   r`   r   )rB   r°   rr   r€   s       r(   Úrecord_connection_closedz.RedisMetricsCollector.record_connection_closed  s}   € ô �tÐ0Ô1Øà×!Ñ!×=Ñ=Ó?ˆÙØ:F×:LÑ:LˆEÔ6Ñ7à�‰Ø×Ñ×4Ñ4Ø%ð 5ó ô	
ð 	×Ñ×"Ñ" 1°Ð"Õ7r'   Úconnection_nameÚrelaxedc                 óª   — t        | d«      sy| j                  j                  |¬«      }||t        <   | j                  j                  |rdnd|¬«       y)a
  
        Record a connection timeout relaxation event.

        Args:
            connection_name: Connection name
            maint_notification: Maintenance notification type
            relaxed: True to count up (relaxed), False to count down (unrelaxed)
        rX   Nr�   rw   éÿÿÿÿrx   )rz   r0   r�   r   rX   r   )rB   r´   r‚   rµ   r€   s        r(   Ú!record_connection_relaxed_timeoutz7RedisMetricsCollector.record_connection_relaxed_timeout7  sS   € ô �tÐ9Ô:Øà×!Ñ!×=Ñ=ÈÐ=ÓXˆØ6HˆÔ2Ñ3Ø×'Ñ'×+Ñ+±©A¸bÈUÐ+ÕSr'   c                 ó�   — t        | d«      sy| j                  j                  |¬«      }| j                  j	                  d|¬«       y)z‘
        Record a connection handoff event (e.g., after MOVING notification).

        Args:
            pool_name: Connection pool name
        rY   Nr�   rw   rx   )rz   r0   r�   rY   r   rž   s      r(   Úrecord_connection_handoffz/RedisMetricsCollector.record_connection_handoffL  sD   € ô �tÐ1Ô2Øà×!Ñ!×=Ñ=È	Ð=ÓRˆØ×Ñ×#Ñ# A°%Ð#Õ8r'   Ú	directionÚchannelÚshardedc                 ó”   — t        | d«      sy| j                  j                  |||¬«      }| j                  j	                  d|¬«       y)zò
        Record a PubSub message (published or received).

        Args:
            direction: Message direction ('publish' or 'receive')
            channel: Pub/Sub channel name
            sharded: True if sharded Pub/Sub channel
        re   N)r»   r¼   r½   rw   rx   )rz   r0   Úbuild_pubsub_message_attributesre   r   )rB   r»   r¼   r½   r€   s        r(   Úrecord_pubsub_messagez+RedisMetricsCollector.record_pubsub_message^  sR   € ô �tÐ.Ô/Øà×!Ñ!×AÑAØØØð Bó 
ˆð
 	×Ñ× Ñ  ¨uÐ Õ5r'   Úconsumer_namez[The consumer_name argument is no longer used and will be removed in the next major version.Úlag_secondsÚstream_nameÚconsumer_groupc                 ó’   — t        | d«      sy| j                  j                  ||¬«      }| j                  j	                  ||¬«       y)zí
        Record the lag of a streaming message.

        Args:
            lag_seconds: Lag in seconds
            stream_name: Stream name
            consumer_group: Consumer group name
            consumer_name: Consumer name
        rh   N)rÃ   rÄ   rx   )rz   r0   Úbuild_streaming_attributesrh   r£   )rB   rÂ   rÃ   rÄ   rÁ   r€   s         r(   Úrecord_streaming_lagz*RedisMetricsCollector.record_streaming_lagx  sK   € ô* �t˜\Ô*Øà×!Ñ!×<Ñ<Ø#Ø)ð =ó 
ˆð 	�‰×Ñ˜{°uÐÕ=r'   Úresultc                 ó�   — t        | d«      sy| j                  j                  |¬«      }| j                  j	                  d|¬«       y)z}
        Record a Client Side Caching (CSC) request.

        Args:
            result: CSC result ('hit' or 'miss')
        rk   N)rÈ   rw   rx   )rz   r0   Úbuild_csc_attributesrk   r   )rB   rÈ   r€   s      r(   Úrecord_csc_requestz(RedisMetricsCollector.record_csc_request˜  sC   € ô �t˜^Ô,Øà×!Ñ!×6Ñ6¸fÐ6ÓEˆØ×Ñ×Ñ˜a¨EÐÕ2r'   Úcountc                 ó�   — t        | d«      sy| j                  j                  |¬«      }| j                  j	                  ||¬«       y)zœ
        Record a Client Side Caching (CSC) eviction.

        Args:
            count: Number of evictions
            reason: Reason for eviction
        rl   N)r‡   rx   )rz   r0   rÊ   rl   r   )rB   rÌ   r‡   r€   s       r(   Úrecord_csc_evictionz)RedisMetricsCollector.record_csc_eviction¨  sC   € ô �t˜_Ô-Øà×!Ñ!×6Ñ6¸fÐ6ÓEˆØ×Ñ×Ñ˜u°ÐÕ7r'   Úbytes_savedc                 óŒ   — t        | d«      sy| j                  j                  «       }| j                  j	                  ||¬«       y)z”
        Record the number of bytes saved by using Client Side Caching (CSC).

        Args:
            bytes_saved: Number of bytes saved
        rm   Nrx   )rz   r0   rÊ   rm   r   )rB   rÏ   r€   s      r(   Úrecord_csc_network_savedz.RedisMetricsCollector.record_csc_network_savedº  s?   € ô �tÐ0Ô1Øà×!Ñ!×6Ñ6Ó8ˆØ×Ñ×"Ñ" ;¸5Ð"ÕAr'   c                  ó*   — t        j                  «       S )z
        Get monotonic time for duration measurements.

        Returns:
            Current monotonic time in seconds
        )ÚtimeÚ	monotonicr&   r'   r(   Úmonotonic_timez$RedisMetricsCollector.monotonic_timeÌ  s   € ô �~‰~ÓÐr'   c                 ó<   — d| j                   › d| j                  › d�S )NzRedisMetricsCollector(meter=z	, config=Ú))r+   r,   rN   s    r(   Ú__repr__zRedisMetricsCollector.__repr__Ö  s   € Ø-¨d¯j©j¨\¸À4Ç;Á;À-ÈqÐQÐQr'   )rD   N)NNNNNNN)rw   )	NNNNNNNNN)NN)NNN)N)5r   r    r!   r"   Ú
METER_NAMEÚMETER_VERSIONr   r   rC   r3   r7   r9   r5   r;   r=   r?   r   ÚstrÚintÚ	ExceptionÚboolr�   r„   r   r   rŠ   r   r�   r   r   r˜   r›   rŸ   Úfloatr¤   r¦   r   r¯   r   r³   r¸   rº   r   rÀ   rÇ   r   rË   r   rÎ   rÑ   ÚstaticmethodrÕ   rØ   r&   r'   r(   r*   r*   B   s°  „ ñ
ð €JØ€Mð"9˜eð "9¨Zó "9óH
ó( 
óD
ó*
ó
ó
ó
ð0 )-Ø%)Ø.2Ø+/Ø*.Ø(,Ø&*ñ,4à  ™ð,4ð ˜c‘]ð,4ð ' s™mð	,4ð
 $ C™=ð,4ð ˜YÑ'ð,4ð ! ™ð,4ð ˜d‘^ó,4ð\"@àð"@ð ð"@ð "ð	"@ð
 ð"@ð  ó"@ðH;àÐ8Ñ9ð;ð Ð6Ñ7ð;ð "ó	;ð< ñ	DàðDð *ðDð ð	Dð
 
óDñ. ðGàôð

àð
ð 
ò
óð

ð0
àð
ð 
ó
ð(:°3ð :¸4ó :ðOàÐJÑKðOð  ðOð 
ó	Oð(MàðMð  ðMð 
ó	Mñ( Ø"�^ØiØôð )-Ø%)Ø&*Ø$(Ø*.Ø.2Ø+/Ø(,Ø&*ñ;Kàð;Kð  ð;Kð ! ™ð	;Kð
 ˜c‘]ð;Kð ˜s‘mð;Kð ˜S‘Mð;Kð ˜YÑ'ð;Kð ' s™mð;Kð $ C™=ð;Kð ! ™ð;Kð ˜d‘^ð;Kð 
ò;Kóð
;Kð~ /3Ø*.ñ8à˜{Ñ+ð8ð ˜YÑ'ð8ð 
ó	8ð6TàðTð  ðTð ð	Tð
 
óTð*9àð9ð 
ó9ð* "&Ø"&ñ	6à"ð6ð ˜#‘ð6ð ˜$‘ð	6ð
 
ó6ñ4 Ø%Ð&ØlØôð &*Ø(,Ø'+ñ>àð>ð ˜c‘]ð>ð ! ™ð	>ð
   ‘}ð>ð 
ò>óð
>ð: '+ñ3à˜Ñ#ð3ð 
ó3ð& '+ñ8àð8ð ˜Ñ#ð8ð 
ó	8ð$BàðBð 
óBð$ ð ˜Eò  ó ð ðR˜#ô Rr'   r*   ).r"   ÚloggingrÓ   Úenumr   Útypingr   r   r   r   Úredis.asyncio.connectionr   Úredis.asyncio.multidb.databaser	   Úredis.connectionr
   Úredis.multidb.databaser   Úredis.observability.attributesr   r   r   r   r   r   r   r   r   Úredis.observability.configr   r   Úredis.utilsr   r   Ú	getLoggerr   r@   Úopentelemetry.metricsr   r.   r/   ÚCounterÚ	HistogramÚUpDownCounterr   r*   r&   r'   r(   Ú<module>rð      s¤   ðñó Û Ý ß ;Ó ;áÝ7Ý<Ý8Ý3÷
÷ 
õ 
÷ ?ß <à	ˆ×	Ñ	˜8Ó	$€ð	Ý+à€Nô.�$ô .÷$U
Rò U
Røð5 ò Ø€NØ€GØ€IØ€EØ‚Mðús   Á0B ÂB ÂB 