B
    3\x                 @   s.   d Z ddlmZ edddddgZdd	 Zd
S )z
Prometheus metrics exported by Jupyter Notebook Server

Read https://prometheus.io/docs/practices/naming/ for naming
conventions for metrics & labels.
    )	HistogramZhttp_request_duration_secondsz)duration in seconds for all HTTP requestsmethodhandlerstatus_codec             C   s:   t j| jjd| jjt| j| 	 d
| j  dS )a  
    Tornado log handler for recording RED metrics.

    We record the following metrics:
       Rate - the number of requests, per second, your services are serving.
       Errors - the number of failed requests per second.
       Duration - The amount of time each request takes expressed as a time interval.

    We use a fully qualified name of the handler as a label,
    rather than every url path to reduce cardinality.

    This function should be either the value of or called from a function
    that is the 'log_function' tornado setting. This makes it get called
    at the end of every request, allowing us to record the metrics we need.
    z{}.{})r   r   r   N)HTTP_REQUEST_DURATION_SECONDSlabelsZrequestr   format	__class__
__module__type__name__Z
get_statusZobserveZrequest_time)r    r   /lib/python3.7/site-packages/notebook/metrics.pyprometheus_log_method   s
    r   N)__doc__Zprometheus_clientr   r   r   r   r   r   r   <module>   s   