관리-도구
편집 파일: exposition.cpython-38.pyc
U .?�f� � @ s$ d dl mZ dZdd� Zdd� ZdS )� )�floatToGoStringz:application/openmetrics-text; version=1.0.0; charset=utf-8c C s8 | j dkr|j�d�rdS | j dkr4|j�d�r4dS dS )N�counterZ_totalT)Z histogramZgaugehistogramZ_bucketF)�type�name�endswith)�metric�sample� r �V/opt/hc_python/lib/python3.8/site-packages/prometheus_client/openmetrics/exposition.py�_is_valid_exemplar_metric s r c C s� g }| � � D �]�}�zv|j}|�d�||j�dd��dd��dd��� |�d|� d |j� d�� |jr�|�d |� d |j� d�� |jD ]�}|j r�d�d� d d� t|j �� �D ���}nd}|j �rFt||�s�td|j� d���d�d� dd� t|j j �� �D ���}|j jdk �r0d�|t|j j�|j j�}nd�|t|j j��}nd}d}|jdk �rfd |j� �}|�d�|j|t|j�||�� q�W q tk �r� } z| j�p�d|f | _� W 5 d} ~ X Y qX q|�d� d� |��d�S )zHReturns the metrics from the registry in latest text format as a string.z # HELP {} {} �\�\\� �\n�"�\"z# TYPE � z# UNIT z{{{0}}}�,c S s4 g | ],\}}d � ||�dd��dd��dd���qS �z{}="{}"r r r r r r ��format�replace��.0�k�vr r r � <listcomp> s � �z#generate_latest.<locals>.<listcomp>� zMetric z8 has exemplars, but is not a histogram bucket or counterc S s4 g | ],\}}d � ||�dd��dd��dd���qS r r r r r r r ) s � �Nz # {} {} {}z # {} {}z{}{} {}{}{} )r z# EOF zutf-8)Zcollectr �appendr � documentationr r �unitZsamples�labels�join�sorted�itemsZexemplarr � ValueError� timestampr �value� Exception�args�encode) �registry�outputr Zmname�sZlabelstrr! Zexemplarstrr&