o
    `۷i).                     @   sl   d dl mZ G dd dZzd dlmZmZmZmZ G dd dZW dS  e	y5   G dd de
ZY dS w )	    )Optionalc                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )
NullMetriczGMock metric class to be used in case of prometheus_client import error.c                 O      d S N selfargskwargsr   r   Z/home/ubuntu/vllm_env/lib/python3.10/site-packages/ray/autoscaler/_private/prom_metrics.pyset      zNullMetric.setc                 O   r   r   r   r   r   r   r   observe
   r   zNullMetric.observec                 O   r   r   r   r   r   r   r   inc   r   zNullMetric.incc                 O   s   | S r   r   r   r   r   r   labels   r   zNullMetric.labelsc                 C   r   r   r   r   r   r   r   clear   r   zNullMetric.clearN)	__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r      s    r   )CollectorRegistryCounterGauge	Histogramc                   @   s2   e Zd Z	ddedee fddZedd ZdS )	AutoscalerPrometheusMetricsNsession_nameregistryc              	   C   s  |pt dd| _|| _g d}g d}tddddd	| j|d
j|d| _tddddd	| j|d
j|d| _tddddd	| j|d
j|d| _tddddd	| jd| _	tddddd	| jd| _
tddddd	| jd| _tddddd	| jdj|d| _tddddd	| jdj|d| _tddddd	| jdj|d| _tddddd	| jdj|d| _td d!ddd	| jdj|d| _td"d#ddd	| jdj|d| _td$d%dd&d	| jdj|d| _td'd(dd&d	| jdj|d| _td)d*dd+d	| jdj|d| _td,d-dd+d	| jdj|d| _td.d/dd0d	| jdj|d| _td1d2dd0d	| jdj|d| _td3d4dd0d	| jdj|d| _td5d6dd0d	| jdj|d| _td7d8dd0d	| jdj|d| _td9d:d;d<d	| jd| _td=d>d;d<d	| jd| _d S )?NT)auto_describe)   
         -   <   Z   x         i,  ih  i  iX  i  i  i  i  i  )g{Gz?g?   r    d   i  worker_create_node_time_secondsaU  Worker launch time. This is the time it takes for a call to a node provider's create_node method to return. Note that when nodes are launched in batches, the launch time for that batch will be observed once for *each* node in that batch. For example, if 8 nodes are launched in 3 minutes, a launch time of 3 minutes will be observed 8 times.)SessionNameseconds
autoscaler)
labelnamesunit	namespacer   bucketsworker_update_time_secondszWorker update time. This is the time between when an updater thread begins executing and when it exits successfully. This metric only observes times for successful updates.update_timezXAutoscaler update time. This is the time for an autoscaler update iteration to complete.pending_nodesz&Number of nodes pending to be started.)NodeTyper,   nodes)r/   r0   r1   r   active_nodeszNumber of nodes in the cluster.recently_failed_nodeszOThe number of recently failed nodes. This count could reset at undefined times.started_nodeszNumber of nodes started.stopped_nodeszNumber of nodes stopped.updating_nodesz+Number of nodes in the process of updating.recovering_nodesz-Number of nodes in the process of recovering.running_workerszNumber of worker nodes running.failed_create_nodeszhNumber of nodes that failed to be created due to an exception in the node provider's create_node method.failed_updatesz%Number of failed worker node updates.updatessuccessful_updatesz)Number of succesfful worker node updates.failed_recoveriesz!Number of failed node recoveries.
recoveriessuccessful_recoveriesz%Number of successful node recoveries.update_loop_exceptionszANumber of exceptions raised in the update loop of the autoscaler.
exceptionsnode_launch_exceptionsz2Number of exceptions raised while launching nodes.reset_exceptionsz;Number of exceptions raised while resetting the autoscaler.config_validation_exceptionszGNumber of exceptions raised while validating the config during a reset.drain_node_exceptionszQNumber of exceptions raised when making a DrainNode rpcprior to node termination.cluster_resourcesz'Total logical resources in the cluster.)resourcer,   	resourcespending_resourcesz)Pending logical resources in the cluster.)r   r   _session_namer   r   worker_create_node_timeworker_update_timer4   r   r5   r8   r9   r   r:   r;   r<   r=   r>   r?   r@   rB   rC   rE   rF   rH   rI   rJ   rK   rL   rO   )r   r   r   histogram_bucketsupdate_time_bucketsr   r   r   __init__   s  
	
		
$AutoscalerPrometheusMetrics.__init__c                 C   s   | j S r   )rP   r   r   r   r   r     s   z(AutoscalerPrometheusMetrics.session_name)NN)	r   r   r   strr   r   rU   propertyr   r   r   r   r   r      s    
 |r   c                   @   s$   e Zd ZddefddZdd ZdS )r   Nr   c                 C   r   r   r   )r   r   r   r   r   rU      r   rV   c                 C   s   t  S r   )r   )r   attrr   r   r   __getattr__#  s   z'AutoscalerPrometheusMetrics.__getattr__r   )r   r   r   rW   rU   rZ   r   r   r   r   r     s    N)typingr   r   prometheus_clientr   r   r   r   r   ImportErrorobjectr   r   r   r   <module>   s      