
    h`k                        S SK r S SKJr  S SKrS SKrS SKJrJrJrJ	r	J
r
JrJrJrJrJrJrJr  S SKrSSKJr  SSKJrJrJr  SSKJr  SSKJrJrJr  SS	KJ r J!r!  SS
K"J#r#J$r$  SSK%J&r&J'r'J(r(  \" SSS9r)\" S\S\4   S9r*S r+S\,4S jr-\-" 5       q.S r/S r0 " S S\5      r1 " S S\15      r2 " S S\15      r3 " S S\15      r4 " S S\15      r5 " S S \15      r6 " S! S"\15      r7g)#    N)Lock)AnyCallableDictIterableListLiteralOptionalSequenceTupleTypeTypeVarUnion   )values)ExceptionCounterInprogressTrackerTimer)Metric)	CollectorCollectorRegistryREGISTRY)ExemplarSample)floatToGoStringINF)_validate_exemplar_validate_labelnames_validate_metric_nameTMetricWrapperBase)boundF.c                 6   U(       d  [        S5      eSnU(       a  XRS-   -  nU(       a  XSS-   -  nXQ-  nU S:X  a  UR                  S5      (       a  US S nU(       a!  UR                  SU-   5      (       d  USU-   -  nU(       a  U S;   a  [        SU-   5      eU$ )	NzMetric name should not be empty _counter_totali)infostatesetz2Metric name is of a type that cannot have a unit: )
ValueErrorendswith)metric_typename	namespace	subsystemunit	full_names         lC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\prometheus_client/metrics.py_build_full_namer4      s    :;;I_$	_$	IiI$6$6x$@$@crN	I&&sTz22S4Z	33MPYYZZ    returnc                  d    [         R                  R                  SS5      R                  5       S;  $ )N!PROMETHEUS_DISABLE_CREATED_SERIESFalse)true1t)osenvirongetlower r5   r3   _get_use_createdrB   ,   s'    ::>>=wGMMOWiiir5   c                      Sq g)zJDisable exporting _created metrics on counters, histograms, and summaries.FN_use_createdrA   r5   r3   disable_created_metricsrF   3   s	     Lr5   c                      Sq g)zIEnable exporting _created metrics on counters, histograms, and summaries.TNrD   rA   r5   r3   enable_created_metricsrH   9   s	     Lr5   c                   l   \ rS rSr% Sr\\   \S'   Sr\	\   \S'   S r
S rS rS	 rS
\\   4S jrS
\\   4S jrS
\4S jrS
\4S jrSSSS\S4S\S\S\S\\   S\S\S\S\\   S\\	\      S
S4S jjrS\S\S\S
\4S jrS\S
S4S jrS$S jrS
\\   4S jrS
\\   4S  jrS
\\   4S! jrS" r S#r!g)%r!   ?   N_typerA   _reserved_labelnamesc                 p    U R                   (       + =(       d    U R                   =(       a    U R                  $ N_labelnames_labelvaluesselfs    r3   _is_observable MetricWrapperBase._is_observableC   s)     ###O(8(8(NT=N=NOr5   c                 p    U R                  5       (       d!  [        S[        U R                  5      -  5      eg )Nz!%s metric is missing label values)rT   r+   strrK   rR   s    r3   _raise_if_not_observable*MetricWrapperBase._raise_if_not_observableI   s1     ""$$@3tzz?RSS %r5   c                 J    U R                   =(       a    U R                  (       + $ rN   rO   rR   s    r3   
_is_parentMetricWrapperBase._is_parentP   s    9(9(9$99r5   c                 n    [        U R                  U R                  U R                  U R                  5      $ rN   )r   _name_documentationrK   _unitrR   s    r3   _get_metricMetricWrapperBase._get_metricS   s%    djj$"5"5tzz4::NNr5   r6   c                 $    U R                  5       /$ rN   )ra   rR   s    r3   describeMetricWrapperBase.describeV   s      "##r5   c           	          U R                  5       nU R                  5        H(  u  p#pEpgUR                  U R                  U-   X4XVU5        M*     U/$ rN   )ra   _samples
add_sampler^   )rS   metricsuffixlabelsvalue	timestampexemplarnative_histogram_values           r3   collectMetricWrapperBase.collectY   sQ    !!#RVR_R_RaNFEhdjj616)Wmn Sbxr5   c                 8    U R                    SU R                   3$ )N:)rK   r^   rR   s    r3   __str__MetricWrapperBase.__str___   s    **Qtzzl++r5   c                 j    [        U 5      nUR                   SUR                   SU R                   S3$ )N.())type
__module____name__r^   )rS   r-   s     r3   __repr__MetricWrapperBase.__repr__b   s6    4j(();+?+?*@$**QOOr5   r%   rS   r.   documentation
labelnamesr/   r0   r1   registryrQ   c	                    [        U R                  XXV5      U l        [        X5      U l        [        U=(       d    S5      U l        0 U l        X l        X`l	        [        U R                  5        U R                  5       (       a  [        5       U l        0 U l        U R                  5       (       a  U R!                  5         U R                  (       d  U(       a  UR#                  U 5        g g g )NrA   )r4   rK   r^   r   rP   tuplerQ   _kwargsr_   r`   r   r[   r   _lock_metricsrT   _metric_initregister)	rS   r.   r   r   r/   r0   r1   r   rQ   s	            r3   __init__MetricWrapperBase.__init__f   s     &djj$9S
/A!,"4"5')+
djj)??DJ46DM    !!$'  !r5   labelvalueslabelkwargsc                 x  ^ U R                   (       d  [        SU -  5      eU R                  (       aB  [        SR                  U [	        [        U R                   U R                  5      5      5      5      eU(       a  T(       a  [        S5      eT(       aM  [        T5      [        U R                   5      :w  a  [        S5      e[        U4S jU R                    5       5      nO?[        U5      [        U R                   5      :w  a  [        S5      e[        S U 5       5      nU R                     XR                  ;  aW  U R                  " U R                  4U R                  U R                   U R                  US.U R                  D6U R                  U'   U R                  U   sS	S	S	5        $ ! , (       d  f       g	= f)
a  Return 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 **kwargszIncorrect label namesc              3   @   >#    U  H  n[        TU   5      v   M     g 7frN   rW   ).0lr   s     r3   	<genexpr>+MetricWrapperBase.labels.<locals>.<genexpr>   s     N=MKN 3 3=Ms   zIncorrect label countc              3   8   #    U  H  n[        U5      v   M     g 7frN   r   r   r   s     r3   r   r      s     <1A   )r   r   r1   rQ   N)rP   r+   rQ   formatdictzipsortedr   lenr   r   	__class__r^   r_   r`   r   )rS   r   r   s     `r3   rk   MetricWrapperBase.labels   s[   . KdRSS_ffS))4+<+<=>  
 ;ABBk"fT-=-=&>> !899NT=M=MNNK;3t'7'7#88 !899<<<KZZ--/-1^^JJ."&"5"5#//!,. ll.k* ==- ZZs   ,A5F++
F9c                    S[         R                  ;   d  S[         R                  ;   a  [        R                  " S[        5        U R
                  (       d  [        SU -  5      e [        U5      [        U R
                  5      :w  a#  [        S[        U R
                  5      U4-  5      e[        S U 5       5      nU R                     XR                  ;   a  U R                  U	 S S S 5        g ! , (       d  f       g = f)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)c              3   8   #    U  H  n[        U5      v   M     g 7frN   r   r   s     r3   r   +MetricWrapperBase.remove.<locals>.<genexpr>   s     8KqCFFKr   )r=   r>   warningswarnUserWarningrP   r+   r   r   r   r   )rS   r   s     r3   removeMetricWrapperBase.remove   s    %37QUWU_U_7_MMX KdRSS8{s4#3#344JcRVRbRbNcepMqqrr8K88ZZmm+MM+. ZZs   C--
C;c                     S[         R                  ;   d  S[         R                  ;   a  [        R                  " S[        5        U R
                     0 U l        SSS5        g! , (       d  f       g= f)z$Remove all labelsets from the metricr   r   zBClearing labels has not been implemented in multi-process mode yetN)r=   r>   r   r   r   r   r   rR   s    r3   clearMetricWrapperBase.clear   sI    %37QUWU_U_7_MMT ZZDM ZZs   A!!
A/c                 l    U R                  5       (       a  U R                  5       $ U R                  5       $ rN   )r[   _multi_samples_child_samplesrR   s    r3   rg   MetricWrapperBase._samples   s-    ??&&((&&((r5   c              #     #    U R                      U R                  R                  5       nS S S 5        WR                  5        Hr  u  p#[	        [        U R                  U5      5      nUR                  5        H:  u  pVpxp[        U[        U[	        UR                  5       5      -   5      XxX5      v   M<     Mt     g ! , (       d  f       N= f7frN   )
r   r   copyitemslistr   rP   rg   r   r   )rS   metricsrk   ri   series_labelsrj   sample_labelsrl   rm   rn   ro   s              r3   r    MetricWrapperBase._multi_samples   s     ZZmm((*G %mmoNF T%5%5v!>?M]c]l]l]nYuVT-$}?R?R?T:U*U%VX]jr  L  L ^o . Zs   C
B9BC
9
CC
c                     [        SU -  5      e)Nz*_child_samples() must be implemented by %rNotImplementedErrorrR   s    r3   r    MetricWrapperBase._child_samples   s    !"NQU"UVVr5   c                     [        SU -  5      e)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   rR   s    r3   r   MetricWrapperBase._metric_init   s     ""Lt"STTr5   )r_   r   rP   rQ   r   r   r^   r`   r6   N)"r|   r{   __qualname____firstlineno__rK   r
   rW   __annotations__rL   r   rT   rX   r[   ra   r   r   rd   rp   rt   r}   r   r    r   r   r   rk   r   r   r   rg   r   r   r   __static_attributes__rA   r5   r3   r!   r!   ?   ss   E8C=*,(3-,PT:O$(6* $&) , ,P# P .0"$"$9A9=(q (( #( &c](  	(
  ( ( $$56(  (6( (@5.Q 5.c 5.# 5.! 5.n/3 /4 /")(6* )L 0 LW 0 WUr5   c                       \ rS rSrSrSrSS jrSS\S\\	\
\
4      SS4S	 jjrSS
 jr\4S\\\   \\\   S4   4   S\4S jjrS\\   4S jrSrg)Counter   a  A 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'   r6   Nc                     [         R                  " U R                  U R                  U R                  S-   U R                  U R
                  U R                  5      U l        [        R                  " 5       U l	        g )Nr(   )
r   
ValueClassrK   r^   rP   rQ   r_   _valuetime_createdrR   s    r3   r   Counter._metric_init  sS    ''

DJJ

X@UW[WgWg(,(9(94;N;NP		r5   amountrn   c                    U R                  5         US:  a  [        S5      eU R                  R                  U5        U(       aD  [	        U5        U R                  R                  [        X![        R                  " 5       5      5        gg)z&Increment counter by the given amount.r   z9Counters can only be incremented by non-negative amounts.N)rX   r+   r   incr   set_exemplarr   r   )rS   r   rn   s      r3   r   Counter.inc  s`    %%'A:XYYx(KK$$Xh		%LM r5   c                 n    U R                   R                  S5        [        R                  " 5       U l        g)zqReset the counter to zero. Use this when a logical process restarts without restarting the actual python process.r   N)r   setr   r   rR   s    r3   resetCounter.reset(  s    		r5   	exception.c                 8    U R                  5         [        X5      $ )zCount 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.
)rX   r   )rS   r   s     r3   count_exceptionsCounter.count_exceptions-  s     	%%'00r5   c                     [        S0 U R                  R                  5       S U R                  R                  5       5      n[        (       a  U[        S0 U R
                  S S 5      4$ U4$ )Nr(   r   )r   r   r?   get_exemplarrE   r   )rS   samples     r3   r   Counter._child_samples7  s\    "dkkoo&7t{{?W?W?YZ<z2t}}dDA  yr5   )r   r   r   )r   N)r|   r{   r   r   __doc__rK   r   floatr
   r   rW   r   r   	Exceptionr   r   BaseExceptionr   r   r   r   r   r   r   rA   r5   r3   r   r      s    $J E$
N% NxS#X/G NSW N$
 ir 1%]0CU4P]K^`cKcEd0d*e 1  wG 1 0 r5   r   c                   F  ^  \ rS rSrSrSr\" S5      r\" S5      rSSSS\	SS	4S
\
S\
S\\
   S\
S\
S\
S\\   S\\\
      S\S   4U 4S jjjrS"S jrS#S\SS4S jjrS#S\SS4S jjrS\SS4S jrS"S jrS\4S jrS\4S jrS\/ \4   SS4S jrS\\   4S  jrS!rU =r $ )$GaugeiA  aE  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   rA   r%   Nr   r.   r   r   r/   r0   r1   r   rQ   multiprocess_modec
                    > Xl         XR                  ;  a  [        SU	-   5      e[        T
U ]  UUUUUUUUS9  U R                   U R
                  S'   U R                   U R                  ;   U l        g )NzInvalid multiprocess mode: r.   r   r   r/   r0   r1   r   rQ   r   )_multiprocess_mode_MULTIPROC_MODESr+   superr   r   _MOST_RECENT_MODES_is_most_recent)rS   r.   r   r   r/   r0   r1   r   rQ   r   r   s             r3   r   Gauge.__init__j  s     #4$9$99:=NNOO'!% 	 		
 -1,C,C()#66$:Q:QQr5   r6   c           
          [         R                  " U R                  U R                  U R                  U R                  U R
                  U R                  U R                  S9U l        g )N)r   )	r   r   rK   r^   rP   rQ   r_   r   r   rR   s    r3   r   Gauge._metric_init  sH    ''JJ

DJJ0@0@$BSBS43J3J
r5   r   c                     U R                   (       a  [        S5      eU R                  5         U R                  R	                  U5        g)z$Increment gauge by the given amount.z-inc must not be used with the mostrecent modeNr   RuntimeErrorrX   r   r   rS   r   s     r3   r   	Gauge.inc  s3    NOO%%'r5   c                     U R                   (       a  [        S5      eU R                  5         U R                  R	                  U* 5        g)z$Decrement gauge by the given amount.z-dec must not be used with the mostrecent modeNr   r   s     r3   dec	Gauge.dec  s5    NOO%%' r5   rl   c                     U R                  5         U R                  (       a7  U R                  R                  [	        U5      [
        R
                  " 5       S9  gU R                  R                  [	        U5      5        g)zSet gauge to the given value.)rm   N)rX   r   r   r   r   r   )rS   rl   s     r3   r   	Gauge.set  sI    %%'KKOOE%LDIIKO@KKOOE%L)r5   c                 L    U R                  [        R                  " 5       5        g)z"Set gauge to the current unixtime.N)r   r   rR   s    r3   set_to_current_timeGauge.set_to_current_time  s    r5   c                 8    U R                  5         [        U 5      $ )zTrack 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.
)rX   r   rR   s    r3   track_inprogressGauge.track_inprogress  s     	%%' &&r5   c                     [        U S5      $ )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   r   rR   s    r3   r   
Gauge.time  s    
 T5!!r5   fc                    ^ U R                  5         S[        S[        [           4U4S jjn[        R
                  " X 5      U l        g)zCall 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&   r6   c                 @   > [        S0 [        T" 5       5      S S 5      4$ Nr%   )r   r   )r&   r  s    r3   samples#Gauge.set_function.<locals>.samples  s    2r5:tT:<<r5   N)rX   r   r   r   types
MethodTyper   )rS   r  r  s    ` r3   set_functionGauge.set_function  s>     	%%'	=u 	=&!1 	= $..w=r5   c                 R    [        S0 U R                  R                  5       S S 5      4$ r  )r   r   r?   rR   s    r3   r   Gauge._child_samples  s#    r2t{{0$=??r5   )r   r   r   r   r   )r   )!r|   r{   r   r   r   rK   	frozensetr   r   r   rW   r   r
   r   r   r	   r   r   r   r   r   r   r  r   r  r   r   r   r  r   r   r   __classcell__r   s   @r3   r   r   A  sd   #H E   "J  K"#CD
 .0"$"$9A9= W\RR #R &c]R  	R
  R R $$56R  (6R %,  -S  %TR R6
 %    !% ! !* *4 *'"3 '"e ">hr5y1 >d >@ 0 @ @r5   r   c                   `    \ rS rSrSrSrS/rSS jrS\SS4S	 jr	S\
4S
 jrS\\   4S jrSrg)Summaryi  a  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quantiler6   Nc                    [         R                  " U R                  U R                  U R                  S-   U R                  U R
                  U R                  5      U l        [         R                  " U R                  U R                  U R                  S-   U R                  U R
                  U R                  5      U l        [        R                  " 5       U l
        g )N_count_sum)r   r   rK   r^   rP   rQ   r_   r   r!  r   r   rR   s    r3   r   Summary._metric_init  s    ''

DJJ

X@UW[WgWg(,(9(94;N;NP%%djj$**djj6>QSWScSceievevx|  yL  yL  M			r5   r   c                     U R                  5         U R                  R                  S5        U R                  R                  U5        ga.  Observe 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.
r   N)rX   r   r   r!  r   s     r3   observeSummary.observe  s0     	%%'		fr5   c                     [        U S5      $ zTime a block of code or function, and observe the duration in seconds.

Can be used as a function decorator or context manager.
r%  r
  rR   s    r3   r   Summary.time      
 T9%%r5   c           	         [        S0 U R                  R                  5       S S 5      [        S0 U R                  R                  5       S S 5      /n[        (       a(  UR                  [        S0 U R                  S S 5      5        [        U5      $ )Nr   r!  r   )r   r   r?   r!  rE   appendr   r   )rS   r  s     r3   r   Summary._child_samples  sl    8R!2D$?62tyy}}d;
 <NN6*b$--tLMW~r5   )r   r   r!  r   )r|   r{   r   r   r   rK   rL   r   r   r%  r   r   r   r   r   r   rA   r5   r3   r  r    sK    : E&<$e  &e & 0 r5   r  c                   2  ^  \ rS rSrSrSrS/rSSSSS	S
SSSSSSSS\4rSSSS\	S\4S\
S\
S\\
   S\
S\
S\
S\\   S\\\
      S\\\\
4      4U 4S jjjrS \\\\
4      S!S4S" jrS*S# jrS+S$\S%\\\
\
4      S!S4S& jjrS!\4S' jrS!\\   4S( jrS)rU =r$ ),	Histogrami  a  A 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{Gzt?g{Gz?g?g?g333333?g?g      ?g      ?g      ?      ?g      @g      @g      @g      $@rA   r%   Nr.   r   r   r/   r0   r1   r   rQ   bucketsc
                 l   > U R                  U	5        [        T
U ]	  UUUUUUUUS9  XR                  S'   g )Nr   r3  )_prepare_bucketsr   r   r   )rS   r.   r   r   r/   r0   r1   r   rQ   r3  r   s             r3   r   Histogram.__init__5  sK     	g&'!% 	 		
 #*Yr5   source_bucketsr6   c                 
   U Vs/ s H  n[        U5      PM     nnU[        U5      :w  a  [        S5      eU(       a"  US   [        :w  a  UR	                  [        5        [        U5      S:  a  [        S5      eX0l        g s  snf )NzBuckets not in sorted order   zMust have at least two buckets)r   r   r+   r   r,  r   _upper_bounds)rS   r7  br3  s       r3   r5  Histogram._prepare_bucketsM  sq    %34^58^4fWo% :;;wr{c)NN3w<!=>>$ 5s   B c                 4   / U l         [        R                  " 5       U l        U R                  S-   n[        R
                  " U R                  U R                  U R                  S-   U R                  U R                  U R                  5      U l
        U R                   Hy  nU R                   R                  [        R
                  " U R                  U R                  U R                  S-   UU R                  [        U5      4-   U R                  5      5        M{     g )N)r1  r!  _bucket)_bucketsr   r   rP   r   r   rK   r^   rQ   r_   r!  r;  r,  r   )rS   bucket_labelnamesr<  s      r3   r   Histogram._metric_initY  s    13		 ,,w6%%djj$**djj6>QSWScSceievevx|  yL  yL  M	##AMM  !2!2





Y&!!!_Q%7$99##"%  $r5   r   rn   c           	      z   U R                  5         U R                  R                  U5        [        U R                  5       Hw  u  p4X::  d  M  U R
                  U   R                  S5        U(       aF  [        U5        U R
                  U   R                  [        X![        R                  " 5       5      5          g   gr$  )
rX   r!  r   	enumerater;  r@  r   r   r   r   )rS   r   rn   ir"   s        r3   r%  Histogram.observeh  s     	%%'		f!$"4"45HAa $$Q'&x0MM!$11(8TYY[2YZ 6r5   c                     [        U S5      $ r(  r
  rR   s    r3   r   Histogram.time|  r*  r5   c                 V   / nSn[        U R                  5       Hh  u  p4X R                  U   R                  5       -  nUR	                  [        SS[        U5      0US U R                  U   R                  5       5      5        Mj     UR	                  [        S0 US S 5      5        U R                  S   S:  a6  UR	                  [        S0 U R                  R                  5       S S 5      5        [        (       a(  UR	                  [        S0 U R                  S S 5      5        [        U5      $ )Ng        r?  r1  r   r   r!  r   )rD  r;  r@  r?   r,  r   r   r   r!  rE   r   r   )rS   r  accrE  r"   s        r3   r   Histogram._child_samples  s    !$"4"45HA==#''))CNN6)dOE4J-KSRVX\XeXefgXhXuXuXwxy 6 	vhCt<=a A%NN6&"diimmotTJK<NN6*b$--tLMW~r5   )r@  r   r!  r;  r   rN   )r|   r{   r   r   r   rK   rL   r   DEFAULT_BUCKETSr   rW   r   r
   r   r   r   r   r   r5  r   r   r%  r   r   r   r   r   r  r  s   @r3   r/  r/    sG   !D E 6S$T2sBS#sTWY]_bcO
 .0"$"$9A9=8G** #* &c]*  	*
  * * $$56*  (6* #5#45* *0
%xeSj8I/J 
%t 
%e xS#X/G SW (&e & 0  r5   r/  c                   R    \ rS rSrSrSrS rS\\\4   SS4S jr	S\
\   4S	 jrS
rg)Infoi  aV  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    [        U R                  5      U l        [        5       U l        0 U l        g rN   )r   rP   _labelname_setr   r   r   rR   s    r3   r   Info._metric_init  s%    !$"2"23V
r5   valr6   Nc                 v   U R                   R                  UR                  5       5      (       a%  [        SR	                  U R
                  U5      5      e[        S UR                  5        5       5      (       a  [        S5      eU R                     [        U5      U l
        SSS5        g! , (       d  f       g= f)zSet info metric.z8Overlapping labels for Info metric, metric: {} child: {}c              3   (   #    U  H  oS L v   M
     g 7frN   rA   )r   rE  s     r3   r   Info.info.<locals>.<genexpr>  s     /,QDy,s   zLabel value cannot be NoneN)rP  intersectionkeysr+   r   rP   anyr   r   r   r   )rS   rR  s     r3   r)   	Info.info  s    ++CHHJ77W^^  #' ( (/#**,///9::ZZs)DK ZZs   B**
B8c                     U R                      [        SU R                  SS S 5      4sS S S 5        $ ! , (       d  f       g = f)N_infor2  )r   r   r   rR   s    r3   r   Info._child_samples  s*    ZZ7DKKdDAC ZZs   1
?)rP  r   r   )r|   r{   r   r   r   rK   r   r   rW   r)   r   r   r   r   rA   r5   r3   rN  rN    sA     E
$S#X $4 $D 0 Dr5   rN  c                      ^  \ rS rSrSrSrSSSS\SS4S\S\S	\\   S
\S\S\S\	\
   S\	\\      S\	\\      4U 4S jjjrSS jrS\SS4S jrS\\   4S jrSrU =r$ )Enumi  a9  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*   rA   r%   Nr.   r   r   r/   r0   r1   r   rQ   statesc
                    > [         T
U ]  UUUUUUUUS9  X;   a  [        SU 35      eU	(       d  [        SU 35      eU	=U R                  S'   U l        g )Nr   z$Overlapping labels for Enum metric: z$No states provided for Enum metric: r_  )r   r   r+   r   _states)rS   r.   r   r   r/   r0   r1   r   rQ   r_  r   s             r3   r   Enum.__init__  su     	'!% 	 		
 CD6JKKCD6JKK066Xr5   r6   c                 0    SU l         [        5       U l        g )Nr   )r   r   r   rR   s    r3   r   Enum._metric_init  s    V
r5   statec                     U R                  5         U R                     U R                  R                  U5      U l        SSS5        g! , (       d  f       g= f)zSet enum metric state.N)rX   r   ra  indexr   )rS   re  s     r3   re  
Enum.state  s5    %%'ZZ,,,,U3DK ZZs   !A
Ac                    U R                      [        U R                  5       VVs/ s H1  u  p[        SU R                  U0XR
                  :X  a  SOSS S 5      PM3     snnsS S S 5        $ s  snnf ! , (       d  f       g = f)Nr%   r   r   )r   rD  ra  r   r^   r   )rS   rE  ss      r3   r   Enum._child_samples  sk    ZZ T\\* + A rDJJ?kk1AAq$PTU* Z Zs   A18A+A1+A11
A?)r   ra  r   r   )r|   r{   r   r   r   rK   r   rW   r   r
   r   r   r   re  r   r   r   r   r  r  s   @r3   r^  r^    s     E
 .0"$"$9A9=3777 #7 &c]7  	7
  7 7 $$567  (67 "(3-07 7643 44 4 0  r5   r^  )8r=   	threadingr   r   r  typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r%   r   context_managersr   r   r   metrics_corer   r   r   r   r   r  r   r   utilsr   r   
validationr   r   r   r    r#   r4   boolrB   rE   rF   rH   r!   r   r   r  r/  rN  r^  rA   r5   r3   <module>rs     s   	         H H   < < % '  C*+CxS)*&j$ j  !oU	 oUdM M`D@ D@NC CL@! @F#D #DL: :r5   