Viewing File: /opt/hc_python/lib/python3.12/site-packages/prometheus_client/__pycache__/metrics.cpython-312.pyc

�

_��g�m����ddlZddlmZddlZddlZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZddlZddlmZddlmZmZmZddlmZmZmZmZddlmZm Z m!Z!dd	l"m#Z#m$Z$dd
l%m&Z&m'Z'edd�
�Z(ededef�
�Z)d�Z*d�Z+d�Z,d�Z-de.fd�Z/e/�a0d�Z1d�Z2Gd�de�Z3Gd�de3�Z4Gd�de3�Z5Gd�de3�Z6Gd�d e3�Z7Gd!�d"e3�Z8Gd#�d$e3�Z9y)%�N)�Lock)�Any�Callable�Dict�Iterable�List�Literal�Optional�Sequence�Tuple�Type�TypeVar�Union�)�values)�ExceptionCounter�InprogressTracker�Timer)�Metric�METRIC_LABEL_NAME_RE�METRIC_NAME_RE�RESERVED_METRIC_LABEL_NAME_RE)�	Collector�CollectorRegistry�REGISTRY)�Exemplar�Sample)�floatToGoString�INF�T�MetricWrapperBase)�bound�F.c���d}|r||dzz
}|r||dzz
}||z
}|dk(r|jd�r|dd}|r|jd|z�s|d|zz
}|r|dvrtd|z��|S)N��_�counter�_totali����)�info�statesetz2Metric name is of a type that cannot have a unit: )�endswith�
ValueError)�metric_type�name�	namespace�	subsystem�unit�	full_names      �H/opt/hc_python/lib/python3.12/site-packages/prometheus_client/metrics.py�_build_full_namer4s����I���Y��_�$�	���Y��_�$�	�
���I��i��I�$6�$6�x�$@��c�r�N�	��I�&�&�s�T�z�2��S�4�Z��	���3�3��M�PY�Y�Z�Z���c��tj|�std|z��tj|�rtd|z��y)NzInvalid label metric name: �Reserved label metric name: )r�matchr,r)�ls r3�_validate_labelnamer:)sE���%�%�a�(��6��:�;�;�$�*�*�1�-��7�!�;�<�<�.r5c�x�t|�}|D])}t|�||jvs�td|z��|S)Nr7)�tupler:�_reserved_labelnamesr,)�cls�
labelnamesr9s   r3�_validate_labelnamesr@0sE���z�"�J�
���A����(�(�(��;�a�?�@�@���r5c��d}|j�D],\}}t|�|t|�z
}|t|�z
}�.|dkDrtd��y)Nr�zDExemplar labels have %d UTF-8 characters, exceeding the limit of 128)�itemsr:�lenr,)�exemplar�runes�k�vs    r3�_validate_exemplarrI9sX��
�E���� ���1��A��
��Q����
��Q����!�
�s�{��_�`�`�r5�returnc�b�tjjdd�j�dvS)N�!PROMETHEUS_DISABLE_CREATED_SERIES�False)�true�1�t)�os�environ�get�lower�r5r3�_get_use_createdrVCs'��
�:�:�>�>�=�w�G�M�M�O�Wi�i�ir5c��day)zJDisable exporting _created metrics on counters, histograms, and summaries.FN��_use_createdrUr5r3�disable_created_metricsrZJs	���Lr5c��day)zIEnable exporting _created metrics on counters, histograms, and summaries.TNrXrUr5r3�enable_created_metricsr\Ps	���Lr5c�L�eZdZUdZeeed<dZeeed<d�Z	d�Z
d�Zd�Zd	e
efd
�Zd	e
efd�Zd	efd�Zd	efd
�Zddddedfdededede
ededededeedeeed	dfd�Zdededed	efd�Zded	dfd�Zd"d�Zd	e
efd�Zd	e
efd�Zd	e
efd �Zd!�Zy)#r!N�_typerUr=c�T�|jxs|jxr|jS�N��_labelnames�_labelvalues��selfs r3�_is_observablez MetricWrapperBase._is_observableZs)���#�#�#�O��(8�(8�(N�T�=N�=N�Or5c�f�|j�s!tdt|j�z��y)Nz!%s metric is missing label values)rfr,�strr^rds r3�_raise_if_not_observablez*MetricWrapperBase._raise_if_not_observable`s.���"�"�$��@�3�t�z�z�?�R�S�S�%r5c�8�|jxr
|jSr`rards r3�
_is_parentzMetricWrapperBase._is_parentgs�����9��(9�(9�$9�9r5c�n�t|j|j|j|j�Sr`)r�_name�_documentationr^�_unitrds r3�_get_metriczMetricWrapperBase._get_metricjs%���d�j�j�$�"5�"5�t�z�z�4�:�:�N�Nr5rJc�$�|j�gSr`)rprds r3�describezMetricWrapperBase.describems��� � �"�#�#r5c��|j�}|j�D]*\}}}}}|j|j|z||||��,|gSr`)rp�_samples�
add_samplerm)re�metric�suffix�labels�value�	timestamprEs       r3�collectzMetricWrapperBase.collectpsR���!�!�#��:>�-�-�/�6�F�F�E�9�h����d�j�j�6�1�6�5�)�X�V�;J��x�r5c�8�|j�d|j��S)N�:)r^rmrds r3�__str__zMetricWrapperBase.__str__vs���*�*��Q�t�z�z�l�+�+r5c�j�t|�}|j�d|j�d|j�d�S)N�.�(�))�type�
__module__�__name__rm)rer-s  r3�__repr__zMetricWrapperBase.__repr__ys6���4�j���(�(�)��;�+?�+?�*@��$�*�*��Q�O�Or5r%rer.�
documentationr?r/r0r1�registryrcc	���t|j||||�|_t||�|_t|xsd�|_i|_||_||_	tj|j�std|jz��|j�rt�|_i|_|j#�r|j%�|js|r|j'|�yyy)NrUzInvalid metric name: )r4r^rmr@rbr<rc�_kwargsrnrorr8r,rkr�_lock�_metricsrf�_metric_init�register)	rer.r�r?r/r0r1r�rcs	         r3�__init__zMetricWrapperBase.__init__}s���&�d�j�j�$�	�9�d�S��
�/��j�A���!�,�"4�"�5���')���+�����
��#�#�D�J�J�/��4�t�z�z�A�B�B��?�?����D�J�46�D�M���� ������ � ���!�!�$�'��!r5�labelvalues�labelkwargsc�4��|jstd|z��|jrBtdj|t	t|j|j�����|r
�rtd���rKt
��t
|j�k7rtd��t�fd�|jD��}n>t|�t|j�k7rtd��td�|D��}|j5||jvrW|j|jf|j|j|j|d�|j��|j|<|j|cd	d	d	�S#1swYy	xYw)
arReturn the child for the given labelset.

        All metrics can have labels, allowing grouping of related time series.
        Taking a counter as an example:

            from prometheus_client import Counter

            c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])
            c.labels('get', '/').inc()
            c.labels('post', '/submit').inc()

        Labels can also be provided as keyword arguments:

            from prometheus_client import Counter

            c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])
            c.labels(method='get', endpoint='/').inc()
            c.labels(method='post', endpoint='/submit').inc()

        See the best practices on [naming](http://prometheus.io/docs/practices/naming/)
        and [labels](http://prometheus.io/docs/practices/instrumentation/#use-labels).
        �,No label names were set when constructing %sz@{} already has labels set ({}); can not chain calls to .labels()z"Can't pass both *args and **kwargszIncorrect label namesc3�:�K�|]}t�|����y�wr`�rh)�.0r9r�s  �r3�	<genexpr>z+MetricWrapperBase.labels.<locals>.<genexpr>�s�����N�=M���K��N� 3�=M�s�zIncorrect label countc3�2K�|]}t|����y�wr`r��r�r9s  r3r�z+MetricWrapperBase.labels.<locals>.<genexpr>�s����<��1��A�����)r�r?r1rcN)rbr,rc�format�dict�zip�sortedr<rDr�r��	__class__rmrnror�)rer�r�s  `r3rxzMetricWrapperBase.labels�s_���.����K�d�R�S�S�����_�f�f���S��)�)�4�+<�+<�=�>���
�
�;��A�B�B���k�"�f�T�-=�-=�&>�>� �!8�9�9��N�T�=M�=M�N�N�K��;��3�t�'7�'7�#8�8� �!8�9�9��<��<�<�K�
�Z�Z��$�-�-�/�-;�T�^�^��J�J�.�"&�"5�"5�#�/�/����!,�.��l�l�
.��
�
�k�*��=�=��-��Z�Z�s
�A4F�Fc��dtjvsdtjvrtjdt�|j
st
d|z��	t|�t|j
�k7r#t
dt|j
�|fz��td�|D��}|j5|j|=ddd�y#1swYyxYw)N�prometheus_multiproc_dir�PROMETHEUS_MULTIPROC_DIRzFRemoval of labels has not been implemented in  multi-process mode yet.r�z+Incorrect label count (expected %d, got %s)c3�2K�|]}t|����y�wr`r�r�s  r3r�z+MetricWrapperBase.remove.<locals>.<genexpr>�s����8�K�q�C��F�K�r�)rQrR�warnings�warn�UserWarningrbr,rDr<r�r�)rer�s  r3�removezMetricWrapperBase.remove�s���%����3�7Q�UW�U_�U_�7_��M�M�X��
�����K�d�R�S�S�8��{��s�4�#3�#3�4�4��J�c�RV�Rb�Rb�Nc�ep�Mq�q�r�r��8�K�8�8��
�Z�Z��
�
�k�*��Z�Z�s�<C�Cc���dtjvsdtjvrtjdt�|j
5i|_ddd�y#1swYyxYw)z$Remove all labelsets from the metricr�r�zBClearing labels has not been implemented in multi-process mode yetN)rQrRr�r�r�r�r�rds r3�clearzMetricWrapperBase.clear�sI��%����3�7Q�UW�U_�U_�7_��M�M�T��
��Z�Z��D�M��Z�Z�s�A�A%c�b�|j�r|j�S|j�Sr`)rk�_multi_samples�_child_samplesrds r3rtzMetricWrapperBase._samples�s*���?�?���&�&�(�(��&�&�(�(r5c#�K�|j5|jj�}ddd�j�D]s\}}t	t|j|��}|j�D]<\}}}}}	t|t|t	|j��z�|||	����>�uy#1swY��xYw�wr`)
r�r��copyrC�listr�rbrtrr�)
re�metricsrxrv�
series_labelsrw�
sample_labelsryrzrEs
          r3r�z MetricWrapperBase._multi_samples�s�����
�Z�Z��m�m�(�(�*�G��%�m�m�o�N�F�F� ��T�%5�%5�v�!>�?�M�EK�_�_�EV�A��
�u�i���V�T�-�$�}�?R�?R�?T�:U�*U�%V�X]�_h�jr�s�s�FW�.��Z�s�
C�B9�BC�9C�>Cc��td|z��)Nz*_child_samples() must be implemented by %r��NotImplementedErrorrds r3r�z MetricWrapperBase._child_samples�s��!�"N�QU�"U�V�Vr5c��td|z��)z�
        Initialize the metric object as a child, i.e. when it has labels (if any) set.

        This is factored as a separate function to allow for deferred initialization.
        z(_metric_init() must be implemented by %rr�rds r3r�zMetricWrapperBase._metric_init�s��"�"L�t�"S�T�Tr5�rJN) r�r��__qualname__r^r
rh�__annotations__r=rrfrirkrprrrrr{r~r�rr rr�rrxr�r�rrtr�r�r�rUr5r3r!r!Vss���E�8�C�=��*,��(�3�-�,�P�T�:�O�$�(�6�*�$���&�)��,��,�P�#�P�.0�"$�"$��9A�9=�(�q�(��(� #�(�&�c�]�(� �	(�
 �(��
(�$�$5�6�(� (���
�6�(��(�B5.�Q�5.�c�5.�#�5.�!�5.�n+�3�+�4�+� �)�(�6�*�)�t��� 0�t�W��� 0�W�Ur5c��eZdZdZdZdd�Zddedeee	e	fddfd�Z
dd	�Zefd
e
eeeeedffdefd�Zdeefd
�Zy)�CounteraA Counter tracks counts of events or running totals.

    Example use cases for Counters:
    - Number of requests processed
    - Number of items that were inserted into a queue
    - Total amount of data that a system has processed

    Counters can only go up (and be reset when the process restarts). If your use case can go down,
    you should use a Gauge instead.

    An example for a Counter:

        from prometheus_client import Counter

        c = Counter('my_failures_total', 'Description of counter')
        c.inc()     # Increment by 1
        c.inc(1.6)  # Increment by given value

    There are utilities to count exceptions raised:

        @c.count_exceptions()
        def f():
            pass

        with c.count_exceptions():
            pass

        # Count only one type of exception
        with c.count_exceptions(ValueError):
            pass
            
    You can also reset the counter to zero in case your logical "process" restarts
    without restarting the actual python process.

       c.reset()

    r'rJNc���tj|j|j|jdz|j|j
|j�|_tj�|_	y)Nr()
r�
ValueClassr^rmrbrcrn�_value�time�_createdrds r3r�zCounter._metric_init0sS���'�'��
�
�D�J�J��
�
�X�@U�W[�Wg�Wg�(,�(9�(9�4�;N�;N�P����	�	���
r5�amountrEc��|j�|dkrtd��|jj|�|rDt	|�|jjt
||tj���yy)z&Increment counter by the given amount.rz9Counters can only be incremented by non-negative amounts.N)rir,r��incrI�set_exemplarrr�)rer�rEs   r3r�zCounter.inc5sb���%�%�'��A�:��X�Y�Y����������x�(��K�K�$�$�X�h���	�	��%L�M�r5c�l�|jjd�tj�|_y)zqReset the counter to zero. Use this when a logical process restarts without restarting the actual python process.rN)r��setr�r�rds r3�resetz
Counter.reset?s����������	�	���
r5�	exception.c�:�|j�t||�S)z�Count exceptions in a block of code or function.

        Can be used as a function decorator or context manager.
        Increments the counter when an exception of the given
        type is raised up out of the code.
        )rir)rer�s  r3�count_exceptionszCounter.count_exceptionsDs��	
�%�%�'���i�0�0r5c���tdi|jj�d|jj��}tr|tdi|j
dd�fS|fS)Nr(r�)rr�rS�get_exemplarrYr�)re�samples  r3r�zCounter._child_samplesNsZ����"�d�k�k�o�o�&7��t�{�{�?W�?W�?Y�Z�����z�2�t�}�}�d�D�A��
��y�r5r�)rN)r�r�r��__doc__r^r��floatr
rrhr�r��	Exceptionrr
�
BaseExceptionrrr�rrr�rUr5r3r�r�s���$�J
�E�$�
N�%�N�x��S�#�X��/G�N�SW�N�$�
ir�1�%��]�0C�U�4�P]�K^�`c�Kc�Ed�0d�*e�1�wG�1���� 0�r5r�c�"��eZdZdZdZed�Zed�Zddddeddfd	e	d
e	de
e	de	d
e	de	deedee
e	dedf�fd�
Zd d�Zd!deddfd�Zd!deddfd�Zdeddfd�Zd d�Zdefd�Zdefd�Zdegefddfd�Zde
efd�Z�xZS)"�Gaugea�Gauge metric, to report instantaneous values.

     Examples of Gauges include:
        - Inprogress requests
        - Number of items in a queue
        - Free memory
        - Total memory
        - Temperature

     Gauges can go both up and down.

        from prometheus_client import Gauge

        g = Gauge('my_inprogress_requests', 'Description of gauge')
        g.inc()      # Increment by 1
        g.dec(10)    # Decrement by given value
        g.set(4.2)   # Set to a given value

     There are utilities for common use cases:

        g.set_to_current_time()   # Set to current unixtime

        # Increment when entered, decrement when exited.
        @g.track_inprogress()
        def f():
            pass

        with g.track_inprogress():
            pass

     A Gauge can also take its value from a callback:

        d = Gauge('data_objects', 'Number of objects')
        my_dict = {}
        d.set_function(lambda: len(my_dict))
    �gauge)
�all�liveall�min�livemin�max�livemax�sum�livesum�
mostrecent�livemostrecent)r�r�rUr%Nr�r.r�r?r/r0r1r�rc�multiprocess_modec

����|	|_|	|jvrtd|	z��t�
|�||||||||��|j|j
d<|j|jv|_y)NzInvalid multiprocess mode: �r.r�r?r/r0r1r�rcr�)�_multiprocess_mode�_MULTIPROC_MODESr,�superr�r��_MOST_RECENT_MODES�_is_most_recent)rer.r�r?r/r0r1r�rcr�r�s          �r3r�zGauge.__init__�s����#4����D�$9�$9�9��:�=N�N�O�O�
����'�!�����%�	�		
�-1�,C�,C����(�)�#�6�6�$�:Q�:Q�Q��r5rJc	���tj|j|j|j|j|j
|j|j��|_y)N)r�)	rr�r^rmrbrcrnr�r�rds r3r�zGauge._metric_init�sH���'�'��J�J��
�
�D�J�J��0@�0@�$�BS�BS����4�3J�3J�
��r5r�c��|jrtd��|j�|jj	|�y)z$Increment gauge by the given amount.z-inc must not be used with the mostrecent modeN�r��RuntimeErrorrir�r��rer�s  r3r�z	Gauge.inc�s3������N�O�O��%�%�'�������r5c��|jrtd��|j�|jj	|�y)z$Decrement gauge by the given amount.z-dec must not be used with the mostrecent modeNr�r�s  r3�decz	Gauge.dec�s5������N�O�O��%�%�'�������� r5ryc��|j�|jr9|jjt	|�tj
���y|jjt	|��y)zSet gauge to the given value.)rzN)rir�r�r�r�r�)rerys  r3r�z	Gauge.set�sI���%�%�'�����K�K�O�O�E�%�L�D�I�I�K�O�@��K�K�O�O�E�%�L�)r5c�J�|jtj��y)z"Set gauge to the current unixtime.N)r�r�rds r3�set_to_current_timezGauge.set_to_current_time�s���������r5c�8�|j�t|�S)z�Track inprogress blocks of code or functions.

        Can be used as a function decorator or context manager.
        Increments the gauge when the code is entered,
        and decrements when it is exited.
        )rirrds r3�track_inprogresszGauge.track_inprogress�s��	
�%�%�'� ��&�&r5c��t|d�S)z�Time a block of code or function, and set the duration in seconds.

        Can be used as a function decorator or context manager.
        r��rrds r3r�z
Gauge.time�s��
�T�5�!�!r5�fc���|j�dtdttf�fd�}t	j
||�|_y)z�Call the provided function to return the Gauge value.

        The function must return a float, and may be called from
        multiple threads. All other methods of the Gauge become NOOPs.
        r&rJc�@��tdit���dd�fS�Nr%)rr�)r&r�s �r3�samplesz#Gauge.set_function.<locals>.samples�s����2�r�5���:�t�T�:�<�<r5N)rir�rr�types�
MethodTyper�)rer�r�s ` r3�set_functionzGauge.set_function�s@���	
�%�%�'�	=�u�	=��&�!1�	=�$�.�.�w��=��r5c�R�tdi|jj�dd�fSr�)rr�rSrds r3r�zGauge._child_samples�s#���r�2�t�{�{���0�$��=�?�?r5r�)r)r�r�r�r�r^�	frozensetr�r�rrhrr
rrr	r�r�r�r�r�r�r�rr�rr�rr�rr��
__classcell__�r�s@r3r�r�XsX���#�H
�E� �"J�K��"�#C�D��
.0�"$�"$��9A�9=�W\�R��R� #�R�&�c�]�R� �	R�
 �R��
R�$�$5�6�R� (���
�6�R�%,�-S�%T�R�6
� �%� �� �!�%�!��!�*��*�4�*��'�"3�'�"�e�"�>�h�r�5�y�1�>�d�>�@��� 0�@r5r�c�P�eZdZdZdZdgZdd�Zdeddfd�Zde	fd	�Z
deefd
�Z
y)�Summarya�A Summary tracks the size and number of events.

    Example use cases for Summaries:
    - Response latency
    - Request size

    Example for a Summary:

        from prometheus_client import Summary

        s = Summary('request_size_bytes', 'Request size (bytes)')
        s.observe(512)  # Observe 512 (bytes)

    Example for a Summary using time:

        from prometheus_client import Summary

        REQUEST_TIME = Summary('response_latency_seconds', 'Response latency (seconds)')

        @REQUEST_TIME.time()
        def create_response(request):
          '''A dummy function'''
          time.sleep(1)

    Example for using the same Summary object as a context manager:

        with REQUEST_TIME.time():
            pass  # Logic to be timed
    �summary�quantilerJNc��tj|j|j|jdz|j|j
|j�|_tj|j|j|jdz|j|j
|j�|_tj�|_
y)N�_count�_sum)rr�r^rmrbrcrnrrr�r�rds r3r�zSummary._metric_inits����'�'��
�
�D�J�J��
�
�X�@U�W[�Wg�Wg�(,�(9�(9�4�;N�;N�P����%�%�d�j�j�$�*�*�d�j�j�6�>Q�SW�Sc�Sc�ei�ev�ev�x|�yL�yL�M��	��	�	���
r5r�c��|j�|jjd�|jj|�y�afObserve the given amount.

        The amount is usually positive or zero. Negative values are
        accepted but prevent current versions of Prometheus from
        properly detecting counter resets in the sum of
        observations. See
        https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations
        for details.
        rN)rirr�rr�s  r3�observezSummary.observes0��	
�%�%�'���������	�	�
�
�f�r5c��t|d�S�z�Time a block of code or function, and observe the duration in seconds.

        Can be used as a function decorator or context manager.
        r
r�rds r3r�zSummary.time���
�T�9�%�%r5c	��tdi|jj�dd�tdi|jj�dd�g}tr(|jtdi|jdd��t|�S)Nrrr�)rrrSrrY�appendr�r<)rer�s  r3r�zSummary._child_samplessj���8�R������!2�D�$�?��6�2�t�y�y�}�}���d�;�
����N�N�6�*�b�$�-�-��t�L�M��W�~�r5r�)r�r�r�r�r^r=r�r�r
rr�rrr�rUr5r3rr�sK���:
�E�&�<��$��e����&�e�&���� 0�r5rc���eZdZdZdZdgZdddddd	d
ddd
ddddefZddddedefde	de	de
e	de	de	de	deedee
e	de
eee	ff�fd�
Zde
eee	fd dfd!�Zd(d"�Zd)d#ed$eee	e	fd dfd%�Zd efd&�Zd e
efd'�Z�xZS)*�	HistogramaA Histogram tracks the size and number of events in buckets.

    You can use Histograms for aggregatable calculation of quantiles.

    Example use cases:
    - Response latency
    - Request size

    Example for a Histogram:

        from prometheus_client import Histogram

        h = Histogram('request_size_bytes', 'Request size (bytes)')
        h.observe(512)  # Observe 512 (bytes)

    Example for a Histogram using time:

        from prometheus_client import Histogram

        REQUEST_TIME = Histogram('response_latency_seconds', 'Response latency (seconds)')

        @REQUEST_TIME.time()
        def create_response(request):
          '''A dummy function'''
          time.sleep(1)

    Example of using the same Histogram object as a context manager:

        with REQUEST_TIME.time():
            pass  # Logic to be timed

    The default buckets are intended to cover a typical web/rpc request from milliseconds to seconds.
    They can be overridden by passing `buckets` keyword argument to `Histogram`.
    �	histogram�leg{�G�zt?g{�G�z�?g�������?g�������?g333333�?g�������?g�?g�?g�?��?g@g@g@g$@rUr%Nr.r�r?r/r0r1r�rc�bucketsc

�t��|j|	�t�
|�	||||||||��|	|jd<y)Nr�r)�_prepare_bucketsr�r�r�)rer.r�r?r/r0r1r�rcrr�s          �r3r�zHistogram.__init__LsM���	
���g�&�
����'�!�����%�	�		
�#*����Y�r5�source_bucketsrJc��|D�cgc]
}t|���}}|t|�k7rtd��|r!|dtk7r|j	t�t|�dkrtd��||_ycc}w)NzBuckets not in sorted order����zMust have at least two buckets)r�r�r,rrrD�
_upper_bounds)rer�brs    r3rzHistogram._prepare_bucketsdss��%3�4�^��5��8�^��4��f�W�o�%��:�;�;��w�r�{�c�)��N�N�3���w�<�!���=�>�>�$����5s�A6c
�*�g|_tj�|_|jdz}t	j
|j|j|jdz|j|j|j�|_
|jD]w}|jjt	j
|j|j|jdz||jt|�fz|j���yy)N)rr�_bucket)�_bucketsr�r�rbrr�r^rmrcrnrrrr)re�bucket_labelnamesrs   r3r�zHistogram._metric_initps���13��
��	�	���
� �,�,�w�6���%�%�d�j�j�$�*�*�d�j�j�6�>Q�SW�Sc�Sc�ei�ev�ev�x|�yL�yL�M��	��#�#�A��M�M� � ��!2�!2��
�
��
�
��
�
�Y�&�!��!�!�_�Q�%7�$9�9��#�#�
"%�
�$r5r�rEc	�n�|j�|jj|�t|j�D]r\}}||ks�|j
|jd�|rFt
|�|j
|jt||tj���yyr	)
rirr��	enumeraterr rIr�rr�)rer�rE�ir"s     r3r
zHistogram.observes���	
�%�%�'��	�	�
�
�f��!�$�"4�"4�5�H�A�u�����
�
�a� �$�$�Q�'��&�x�0��M�M�!�$�1�1�(�8�V�T�Y�Y�[�2Y�Z��
6r5c��t|d�Srr�rds r3r�zHistogram.time�r
r5c�J�g}d}t|j�D]i\}}||j|j�z
}|j	tddt
|�i|d|j|j����k|j	tdi|dd��|jddk\r6|j	tdi|jj�dd��tr(|j	tdi|jdd��t|�S)Ngrrrrrr�)r#rr rSrrrr�rrYr�r<)rer��accr$r"s     r3r�zHistogram._child_samples�s�������!�$�"4�"4�5�H�A�u��4�=�=��#�'�'�)�)�C��N�N�6�)�d�O�E�4J�-K�S�RV�X\�Xe�Xe�fg�Xh�Xu�Xu�Xw�x�y�6�	���v�h��C��t�<�=����a� �A�%��N�N�6�&�"�d�i�i�m�m�o�t�T�J�K���N�N�6�*�b�$�-�-��t�L�M��W�~�r5r�r`)r�r�r�r�r^r=r�DEFAULT_BUCKETSrrhrr
rrrr�r�rr�rr
rr�rr�r�rs@r3rr%s=���!�D
�E� �6���S�$��T�2�s�B��S�#�s�TW�Y]�_b�c�O�
.0�"$�"$��9A�9=�8G�*��*� #�*�&�c�]�*� �	*�
 �*��
*�$�$5�6�*� (���
�6�*�#�5����#4�5�*�0
%�x��e�S�j�8I�/J�
%�t�
%�
��e��x��S�#�X��/G��SW��(&�e�&���� 0�r5rc�F�eZdZdZdZd�Zdeeefddfd�Zde	e
fd�Zy)	�Infoa�Info metric, key-value pairs.

     Examples of Info include:
        - Build information
        - Version information
        - Potential target metadata

     Example usage:
        from prometheus_client import Info

        i = Info('my_build', 'Description of info')
        i.info({'version': '1.2.3', 'buildhost': 'foo@bar'})

     Info metrics do not work in multiprocess mode.
    r)c�d�t|j�|_t�|_i|_yr`)r�rb�_labelname_setrr�r�rds r3r�zInfo._metric_init�s%��!�$�"2�"2�3����V��
���r5�valrJNc�X�|jj|j��r%tdj	|j
|���t
d�|j�D��rtd��|j5t|�|_
ddd�y#1swYyxYw)zSet info metric.z8Overlapping labels for Info metric, metric: {} child: {}c3�$K�|]}|du���
y�wr`rU)r�r$s  r3r�zInfo.info.<locals>.<genexpr>�s����/�,�Q�q�D�y�,�s�zLabel value cannot be NoneN)r,�intersection�keysr,r�rb�anyrr�r�r�)rer-s  r3r)z	Info.info�s~�����+�+�C�H�H�J�7��W�^�^�� � �#�'�(�
(��/�#�*�*�,�/�/��9�:�:�
�Z�Z��s�)�D�K��Z�Z�s�B � B)c�z�|j5td|jddd�fcddd�S#1swYyxYw)N�_infor)r�rr�rds r3r�zInfo._child_samples�s*��
�Z�Z��7�D�K�K��d�D�A�C��Z�Z�s�1�:)r�r�r�r�r^r�rrhr)rrr�rUr5r3r*r*�sA���
�E��
$��S�#�X��$�4�$�D��� 0�Dr5r*c���eZdZdZdZddddeddfdededeed	ed
ededee	d
eeedeeef�fd�
Z
dd�Zdeddfd�Zde
efd�Z�xZS)�Enuma`Enum metric, which of a set of states is true.

     Example usage:
        from prometheus_client import Enum

        e = Enum('task_state', 'Description of enum',
          states=['starting', 'running', 'stopped'])
        e.state('running')

     The first listed state will be the default.
     Enum metrics do not work in multiprocess mode.
    r*rUr%Nr.r�r?r/r0r1r�rc�statesc

���t�
|�||||||||��||vrtd|����|	std|����|	x|jd<|_y)Nr�z$Overlapping labels for Enum metric: z$No states provided for Enum metric: r7)r�r�r,r��_states)rer.r�r?r/r0r1r�rcr7r�s          �r3r�z
Enum.__init__�sw���	����'�!�����%�	�		
��:���C�D�6�J�K�K���C�D�6�J�K�K�06�6����X���r5rJc�0�d|_t�|_y)Nr)r�rr�rds r3r�zEnum._metric_init�s������V��
r5�statec��|j�|j5|jj|�|_ddd�y#1swYyxYw)zSet enum metric state.N)rir�r9�indexr�)rer;s  r3r;z
Enum.state�s5���%�%�'�
�Z�Z��,�,�,�,�U�3�D�K��Z�Z�s�!A�Ac��|j5t|j�D��cgc]1\}}td|j|i||j
k(rdnddd���3c}}cddd�Scc}}w#1swYyxYw)Nr%rr)r�r#r9rrmr�)rer$�ss   r3r�zEnum._child_samplesso��
�Z�Z��T�\�\�*��+��A�q��r�D�J�J��?��d�k�k�1A�A�q�$�PT�U�*���Z����Z�s�A/�6A)�A/�)A/�/A8r�)r�r�r�r�r^rrhrr
rr�r�r;rrr�r�rs@r3r6r6�s�����
�E�
.0�"$�"$��9A�9=�37�7��7� #�7�&�c�]�7� �	7�
 �7��
7�$�$5�6�7� (���
�6�7�"�(�3�-�0�7�6�4�3�4�4�4���� 0�r5r6):rQ�	threadingrr�r��typingrrrrrr	r
rrr
rrr�r%r�context_managersrrr�metrics_corerrrrr�rrrr�rr�utilsrrr r#r4r:r@rI�boolrVrYrZr\r!r�r�rrr*r6rUr5r3�<module>rFs��	����������H�H���=�<�%�'��C�*�+���C�x��S��)�*��
� =��a�j�$�j� �!����oU�	�oU�dM��M�`D@��D@�NC��C�L@�!�@�F#D��#D�L:��:r5
Back to Directory File Manager