
    ]Ci<                     x   S SK r S SKJrJrJrJrJrJr  SSKJ	r	J
r
Jr  Sr\ R                  " S5      r\ R                  " S5      r\ R                  " S5      r " S	 S
5      r " S S\5      r\r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)    N)DictListOptionalSequenceTupleUnion   )ExemplarSample	Timestamp)countergaugesummary	histogramgaugehistogramunknowninfostatesetz^[a-zA-Z_:][a-zA-Z0-9_:]*$z^[a-zA-Z_][a-zA-Z0-9_]*$z^__.*$c                       \ rS rSrSrSS\S\S\S\4S jjrSS\S	\\\4   S
\S\	\
\\4      S\	\   SS4S jjrS\S\4S jrS\4S jrS rSrg)Metric   zA single metric family and its samples.

This is intended only for internal use by the instrumentation client.

Custom collectors should use GaugeMetricFamily, CounterMetricFamily
and SummaryMetricFamily instead.
namedocumentationtypunitc                 "   U(       a!  UR                  SU-   5      (       d  USU-   -  n[        R                  U5      (       d  [        SU-   5      eXl        X l        X@l        US:X  a  SnU[        ;  a  [        SU-   5      eX0l        / U l	        g )N_zInvalid metric name: untypedr   zInvalid metric type: )
endswithMETRIC_NAME_REmatch
ValueErrorr   r   r   METRIC_TYPEStypesamples)selfr   r   r   r   s        X/home/james-whalen/.local/lib/python3.13/site-packages/prometheus_client/metrics_core.py__init__Metric.__init__   s    cDj11C$JD##D))4t;<<	"/	)Cl"4s:;;	%'    Nlabelsvalue	timestampexemplarreturnc           	      P    U R                   R                  [        XX4U5      5        g)z7Add a sample to the metric.

Internal-only, do not use.N)r%   appendr   )r&   r   r+   r,   r-   r.   s         r'   
add_sampleMetric.add_sample'   s     	F48LMr*   otherc                 b   [        U[        5      =(       a    U R                  UR                  :H  =(       ay    U R                  UR                  :H  =(       aY    U R                  UR                  :H  =(       a9    U R
                  UR
                  :H  =(       a    U R                  UR                  :H  $ N)
isinstancer   r   r   r$   r   r%   )r&   r4   s     r'   __eq__Metric.__eq__-   s    5&) 2II+2&&%*=*==2 II+2 II+	2
 LLEMM1	3r*   c                     SR                  U R                  U R                  U R                  U R                  U R
                  5      $ )NzMetric({}, {}, {}, {}, {}))formatr   r   r$   r   r%   )r&   s    r'   __repr__Metric.__repr__5   s:    +22IIIIIILL
 	
r*   c                     U R                    Vs/ s H  o"S   U;   d  M  UPM     nnU(       a3  [        U R                  U R                  U R                  5      nX4l         U$ gs  snf )zMBuild a snapshot of a metric with samples restricted to a given set of names.r   N)r%   r   r   r   r$   )r&   namessr%   ms        r'   _restricted_metricMetric._restricted_metric>   sS    "ll<ldem1l<tyy$"4"4dii@AIH =s
   A"A")r   r   r%   r$   r   ) NN)__name__
__module____qualname____firstlineno____doc__strr(   r   floatr   r   r   r
   r2   objectboolr8   r<   rB   __static_attributes__ r*   r'   r   r      s    (S ( (3 (c (Ns NDcN N5 NU]^cdmotdt^uUv N  JR  S[  J\ N  hl N3F 3t 3
# 
r*   r   c                       \ rS rSrSr   SS\S\S\\   S\\\      S\4
S	 jjr	SS\\   S\S
\\
\\4      SS4S jjrSrg)UnknownMetricFamilyH   zGA single unknown metric and its samples.
For use by custom collectors.
Nr   r   r,   r+   r   c                     [         R                  XUSU5        Ub  Ub  [        S5      eUc  / n[        U5      U l        Ub  U R                  / U5        g g )Nr   1Can only specify at most one of value and labels.r   r(   r"   tuple_labelnames
add_metricr&   r   r   r,   r+   r   s         r'   r(   UnknownMetricFamily.__init__M   s\     	M9dC%"3PQQ>F =OOB& r*   r-   r/   c                     U R                   R                  [        U R                  [	        [        U R                  U5      5      X#5      5        g)zhAdd a metric to the metric family.
Args:
labels: A list of label values
value: The value of the metric.
Nr%   r1   r   r   dictziprX   r&   r+   r,   r-   s       r'   rY   UnknownMetricFamily.add_metric]   s6     	F499d3t7G7G3P.QSXder*   rX   NNrD   r6   rF   rG   rH   rI   rJ   rK   r   rL   r   r(   r   r   rY   rO   rP   r*   r'   rR   rR   H   s     +/37'' #' !' "(3-0	'
 ' f# fu fRWXachXhRiIj fvz f fr*   rR   c                       \ rS rSrSr    SS\S\S\\   S\\\      S\\   S	\4S
 jjr	  SS\\   S\S\\   S\\
\\4      SS4
S jjrSrg)CounterMetricFamilyj   zAA single counter and its samples.

For use by custom collectors.
Nr   r   r,   r+   createdr   c                     UR                  S5      (       a  US S n[        R                  XUSU5        Ub  Ub  [        S5      eUc  / n[	        U5      U l        Ub  U R                  / X55        g g )N_totalir   rU   )r   r   r(   r"   rW   rX   rY   )r&   r   r   r,   r+   rh   r   s          r'   r(   CounterMetricFamily.__init__p   sv     ==""9DM9dC%"3PQQ>F =OOB/ r*   r-   r/   c                 L   U R                   R                  [        U R                  S-   [	        [        U R                  U5      5      X$5      5        UbQ  U R                   R                  [        U R                  S-   [	        [        U R                  U5      5      X45      5        gg)zAdd a metric to the metric family.

Args:
  labels: A list of label values
  value: The value of the metric
  created: Optional unix timestamp the child was created at.
rj   N_createdr]   )r&   r+   r,   rh   r-   s        r'   rY   CounterMetricFamily.add_metric   s     	F499x#7c$BRBRTZ>[9\^copLLtyy:'=tCHXHXZ`Da?bdk wx r*   rb   NNNrD   rE   rd   rP   r*   r'   rf   rf   j   s     +/37,000 #0 !0 "(3-0	0
 #5/0 0. /3BF	y#C=yy %UOy 'uY-='>?	y
 y yr*   rf   c                       \ rS rSrSr   SS\S\S\\   S\\\      S\4
S	 jjr	SS\\   S\S
\\
\\4      SS4S jjrSrg)GaugeMetricFamily   z?A single gauge and its samples.

For use by custom collectors.
Nr   r   r,   r+   r   c                     [         R                  XUSU5        Ub  Ub  [        S5      eUc  / n[        U5      U l        Ub  U R                  / U5        g g )Nr   rU   rV   rZ   s         r'   r(   GaugeMetricFamily.__init__   s\     	M7DA%"3PQQ>F =OOB& r*   r-   r/   c                     U R                   R                  [        U R                  [	        [        U R                  U5      5      X#5      5        g)z\Add a metric to the metric family.

Args:
  labels: A list of label values
  value: A float
Nr]   r`   s       r'   rY   GaugeMetricFamily.add_metric   s6     	F499d3t7G7G3P.QSXder*   rb   rc   r6   rd   rP   r*   r'   rq   rq      s     +/37'' #' !' "(3-0	'
 ' f# fu fRWXachXhRiIj fvz f fr*   rq   c                       \ rS rSrSr    SS\S\S\\   S\\   S\\	\      S	\4S
 jjr
 SS\	\   S\S\S\\\\4      SS4
S jjrSrg)SummaryMetricFamily   zAA single summary and its samples.

For use by custom collectors.
Nr   r   count_value	sum_valuer+   r   c                     [         R                  XUSU5        US L US L :w  a  [        S5      eUb  Ub  [        S5      eUc  / n[        U5      U l        Ub  Ub  U R                  / X45        g g g )Nr   z4count_value and sum_value must be provided together.rU   rV   )r&   r   r   rz   r{   r+   r   s          r'   r(   SummaryMetricFamily.__init__   s     	M9dC;$#67STT+"9PQQ>F ="y'<OOB7 (="r*   r-   r/   c                 D   U R                   R                  [        U R                  S-   [	        [        U R                  U5      5      X$5      5        U R                   R                  [        U R                  S-   [	        [        U R                  U5      5      X45      5        g)zAdd a metric to the metric family.

Args:
  labels: A list of label values
  count_value: The count value of the metric.
  sum_value: The sum value of the metric.
_count_sumNr]   )r&   r+   rz   r{   r-   s        r'   rY   SummaryMetricFamily.add_metric   st     	F499x#7c$BRBRTZ>[9\^iuvF499v#5tC@P@PRX<Y7Z\eqrr*   rb   ro   r6   )rF   rG   rH   rI   rJ   rK   r   intrL   r   r(   r   r   rY   rO   rP   r*   r'   rx   rx      s     /3.23788 #8 'sm8 %UO	8
 "(3-08 82 8<s#C=s #s $s
 E%"234s s sr*   rx   c                       \ rS rSrSr    SS\S\S\\\\	\\
4   \	\\
\4   4         S\\
   S\\\      S	\4S
 jjr SS\\   S\\\	\\
4   \	\\
\4   4      S\\
   S\\\\
4      SS4
S jjrSrg)HistogramMetricFamily   zCA single histogram and its samples.

For use by custom collectors.
Nr   r   bucketsr{   r+   r   c                     [         R                  XUSU5        Ub  Uc  [        S5      eUb  Ub  [        S5      eUc  / n[        U5      U l        Ub  U R                  / X45        g g )Nr   z-sum value cannot be provided without buckets.3Can only specify at most one of buckets and labels.rV   )r&   r   r   r   r{   r+   r   s          r'   r(   HistogramMetricFamily.__init__   sr     	M;E W_LMM'"5RSS>F =OOB3 r*   r-   r/   c                    U H  nUSS u  pgSn[        U5      S:X  a  US   nU R                  R                  [        U R                  S-   [        [        [        U R                  U5      5      SU4/-   5      UUU5      5        M     [        US   S   5      S:  a  Ub  U R                  R                  [        U R                  S-   [        [        U R                  U5      5      US   S	   U5      5        U R                  R                  [        U R                  S
-   [        [        U R                  U5      5      X45      5        ggg)a:  Add a metric to the metric family.

Args:
  labels: A list of label values
  buckets: A list of lists.
      Each inner list can be a pair of bucket name and value,
      or a triple of bucket name, value, and exemplar.
      The buckets must be sorted, and +Inf present.
  sum_value: The sum value of the metric.
N      _bucketler   r   r	   r   )
lenr%   r1   r   r   r^   listr_   rX   rL   )	r&   r+   r   r{   r-   bbucketr,   r.   s	            r'   rY    HistogramMetricFamily.add_metric   s1    AbqEMFH1v{Q4LL		I%T#d..78T6N;KKL!   A1$)>LLtyy8+T#d6F6F2O-PRYZ\R]^_R`bklnLLtyy6)4D4D4Df0M+NPYeg	 *?$r*   rb   ro   r6   )rF   rG   rH   rI   rJ   rK   r   r   r   r   rL   r
   r(   r   rY   rO   rP   r*   r'   r   r      s    gk.23744 #4 #8E%U
2CU3PUW_K_E`2`,a#bc4 %UO	4
 "(3-04 4. CG	!g#C=!g$U5e+<eCPXDX>Y+Y%Z[!g 'uo!g 'uY-='>?	!g LP	!g !gr*   r   c                       \ rS rSrSr    SS\S\S\\\\\	4         S\\	   S\\\      S	\4S
 jjr
 SS\\   S\\\\	4      S\\	   S\\\	\4      SS4
S jjrSrg)GaugeHistogramMetricFamilyi   zIA single gauge histogram and its samples.

For use by custom collectors.
Nr   r   r   
gsum_valuer+   r   c                     [         R                  XUSU5        Ub  Ub  [        S5      eUc  / n[        U5      U l        Ub  U R                  / X45        g g )Nr   r   rV   )r&   r   r   r   r   r+   r   s          r'   r(   #GaugeHistogramMetricFamily.__init__&  s]     	M3CTJ'"5RSS>F =OOB4 r*   r-   r/   c                    U Hd  u  pVU R                   R                  [        U R                  S-   [	        [        [        U R                  U5      5      SU4/-   5      Xd5      5        Mf     U R                   R                  [        U R                  S-   [	        [        U R                  U5      5      US   S   U5      [        U R                  S-   [	        [        U R                  U5      5      X45      /5        g)zAdd a metric to the metric family.

Args:
  labels: A list of label values
  buckets: A list of pairs of bucket names and values.
      The buckets must be sorted, and +Inf present.
  gsum_value: The sum value of the metric.
r   r   _gcountr   r	   _gsumN)	r%   r1   r   r   r^   r   r_   rX   extend)r&   r+   r   r   r-   r   r,   s          r'   rY   %GaugeHistogramMetricFamily.add_metric7  s     %MFLL		I%T#d..78T6N;KKL!" # % 	499y($s43C3CV/L*MwWY{[\~_hi499w&S1A1A6-J(KZc
 	r*   rb   ro   r6   )rF   rG   rH   rI   rJ   rK   r   r   r   rL   r(   r   r   rY   rO   rP   r*   r'   r   r      s     CG/33755 #5 #8E#u*,=#>?5 &e_	5
 "(3-05 5* CG	#C=$U3:%67  ( 'uUI-='>?	
  r*   r   c                       \ rS rSrSr  SS\S\S\\\\4      S\\\      4S jjr	 SS\\   S\\\4   S	\\
\\4      S
S4S jjrSrg)InfoMetricFamilyiR  z>A single info and its samples.

For use by custom collectors.
Nr   r   r,   r+   c                     [         R                  XUS5        Ub  Ub  [        S5      eUc  / n[        U5      U l        Ub  U R                  / U5        g g )Nr   rU   rV   r&   r   r   r,   r+   s        r'   r(   InfoMetricFamily.__init__X  sZ     	M6:%"3PQQ>F =OOB& r*   r-   r/   c                     U R                   R                  [        U R                  S-   [	        [	        [        U R                  U5      5      40 UD6SU5      5        g)zeAdd a metric to the metric family.

Args:
  labels: A list of label values
  value: A dict of labels
_infor	   Nr]   r`   s       r'   rY   InfoMetricFamily.add_metricg  sN     	FIIc$**F34>>	
 	r*   rb   rE   r6   )rF   rG   rH   rI   rJ   rK   r   r   r   r(   r   r   rL   rY   rO   rP   r*   r'   r   r   R  s     4837	'' #' !c3h0' "(3-0	'$ CG#C=sCx. 'uY-='>? 	 r*   r   c                       \ rS rSrSr  SS\S\S\\\\4      S\\	\      4S jjr
 SS\	\   S\\\4   S	\\\\4      S
S4S jjrSrg)StateSetMetricFamilyiz  zBA single stateset and its samples.

For use by custom collectors.
Nr   r   r,   r+   c                     [         R                  XUS5        Ub  Ub  [        S5      eUc  / n[        U5      U l        Ub  U R                  / U5        g g )Nr   rU   rV   r   s        r'   r(   StateSetMetricFamily.__init__  sZ     	M:>%"3PQQ>F =OOB& r*   r-   r/   c                 2   [        U5      n[        UR                  5       5       Ho  u  pEU(       a  SOSnU R                  R	                  [        U R                  [        [        U R                  U R                  4-   X4-   5      5      UU5      5        Mq     g)z}Add a metric to the metric family.

Args:
  labels: A list of label values
  value: A dict of string state names to booleans
r	   r   N)
rW   sorteditemsr%   r1   r   r   r^   r_   rX   )r&   r+   r,   r-   stateenabledvs          r'   rY   StateSetMetricFamily.add_metric  sx     v$U[[]3NE1ALL		S))TYYL8&8:KLM	!  4r*   rb   rE   r6   )rF   rG   rH   rI   rJ   rK   r   r   rN   r   r(   r   r   rL   rY   rO   rP   r*   r'   r   r   z  s     5937	'' #' !c4i1' "(3-0	'$ CG#C=sDy/ 'uY-='>? 	 r*   r   )retypingr   r   r   r   r   r   r%   r
   r   r   r#   compiler    METRIC_LABEL_NAME_RERESERVED_METRIC_LABEL_NAME_REr   rR   UntypedMetricFamilyrf   rq   rx   r   r   r   r   rP   r*   r'   <module>r      s    	 ? ? 0 0 9:zz"=>  "

9 5 6 6rf& f> * )y& )yXf f@)s& )sX:gF :g|/ /d%v %P(6 (r*   