
    0Fie                    J    d dl mZ d dlmZmZ d dlmZ  G d de          ZdS )    )annotations)CounterMetricFamilyGaugeMetricFamily)PrometheusCollectorc                  $     e Zd Z fdZd Z xZS )SemaphoreMetricCollectorc                X    t                                          |           d| _        d S )N	semaphore)super__init__	subsystem)selfserver	__class__s     Olib/python3.11/site-packages/distributed/http/scheduler/prometheus/semaphore.pyr   z!SemaphoreMetricCollector.__init__	   s&       $    c              #  X  K   	 | j         j        d         }n# t          $ r Y d S w xY wt          |                     d          ddg          }t          |                     d          ddg          }t          |                     d          d	dg          }t          |                     d
          ddg          }t          |                     d          ddg          }t          |                     d          ddgd          }|j                                        D ]\  }}	|                    |g|	           |                    |gt          |j
        |                              |                    |g|j        d         |                    |                    |g|j        d
         |                    |                    |g|j        d         |                    |                    |g|j        d         |                    |V  |V  |V  |V  |V  |V  d S )N
semaphores
max_leaseszhMaximum leases allowed per semaphore
Note: This will be constant for each semaphore during its lifetime.name)labelsactive_leasesz/Amount of currently active leases per semaphorepending_leasesz0Amount of currently pending leases per semaphoreacquire_totalz-Total number of leases acquired per semaphorerelease_totalzTotal number of leases released per semaphore
Note: If a semaphore is closed while there are still leases active, this count will not equal `semaphore_acquired_total` after execution.average_pending_lease_timea  Exponential moving average of the time it took to acquire a lease per semaphore
Note: This only includes time spent on scheduler side, it does not include time spent on communication.
Note: This average is calculated based on order of leases instead of time of lease acquisition.s)r   unitpending)r   
extensionsKeyErrorr   
build_namer   r   items
add_metriclenleasesmetrics)
r   sem_extsemaphore_max_leases_familysemaphore_active_leases_familysemaphore_pending_leasessemaphore_acquire_totalsemaphore_release_total$semaphore_average_pending_lease_timesemaphore_namesemaphore_max_leasess
             r   collectz SemaphoreMetricCollector.collect   s     	k,\:GG 	 	 	FF	&7OOL))2 8'
 '
 '
# *;OOO,,=8*
 *
 *
&
 $5OO,-->8$
 $
 $
  #6OOO,,;8#
 #
 #
 #6OOO,,T 8#
 #
 #
 0AOO899, 8
0
 
0
 
0
, 5<4F4L4L4N4N 	 	0N0'22 "6   +55 #gn^&D"E"E   %// '/)"<^"L   $.. '//"B>"R   $.. '//"B>"R   1;;  <=nM    *))),,,,&&&&%%%%%%%%222222s    
%%)__name__
__module____qualname__r   r1   __classcell__)r   s   @r   r   r      sN        % % % % %J3 J3 J3 J3 J3 J3 J3r   r   N)
__future__r   prometheus_client.corer   r   distributed.http.prometheusr   r    r   r   <module>r:      s    " " " " " " I I I I I I I I ; ; ; ; ; ;O3 O3 O3 O3 O32 O3 O3 O3 O3 O3r   