o
    bi                     @   sx   d dl mZ 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y;   G dd deZ
Y d	S w )
    )Optional)COMPONENT_METRICS_TAG_KEYSc                   @   s(   e Zd Z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   S/home/ubuntu/.local/lib/python3.10/site-packages/ray/dashboard/dashboard_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.incN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r      s
    r   )CollectorRegistryCounterGauge	Histogramc                   @   s    e Zd Zddee fddZdS )DashboardPrometheusMetricsNregistryc              	   C   s   |pt dd| _g d}tddddd| j|d	| _td
dddd| jd| _tddttdd| jd| _	tddttdd| jd| _
tddttdd| jd| _tddttdd| jd| _tddttdd| jd| _d S )NT)auto_describe)g{Gzt?g{Gz?g?g?g333333?g?g      ?g      ?g      ?   g      @   g      @
      (   <   'dashboard_api_requests_duration_secondsz&Total duration in seconds per endpoint)endpointhttp_statusVersionSessionName	Componentsecondsray)unit	namespacer   bucketsdashboard_api_requests_countz!Total requests count per endpoint)methodr#   r$   r%   r&   r'   requests)r*   r+   r   dashboard_event_loop_tasksz<Number of tasks currently pending in the event loop's queue.tasksdashboard_event_loop_lagzEvent loop lag in seconds.component_cpuzDashboard CPU percentage usage.
percentagecomponent_ussz(USS usage of all components on the node.mbcomponent_rssz(RSS usage of all components on the node.)r   r   r   metrics_request_durationr   metrics_request_countr   tupler   metrics_event_loop_tasksmetrics_event_loop_lagmetrics_dashboard_cpumetrics_dashboard_mem_ussmetrics_dashboard_mem_rss)r	   r   histogram_buckets_sr   r   r   __init__   sz   	z#DashboardPrometheusMetrics.__init__r   )r   r   r   r   r   rA   r   r   r   r   r      s    r   c                   @   s   e Zd Zdd ZdS )r   c                 C   s   t  S r   )r   )r	   attrr   r   r   __getattr__z   s   z&DashboardPrometheusMetrics.__getattr__N)r   r   r   rC   r   r   r   r   r   y   s    N)typingr   ray.dashboard.constsr   r   prometheus_clientr   r   r   r   r   ImportErrorobjectr   r   r   r   <module>   s    ^