JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr ֓gmddlZddlmZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z mZmZmZmZddlZddlmZddlmZmZmZddlmZmZmZmZddlmZm Z m!Z!dd l"m#Z#m$Z$dd l%m&Z&m'Z'ed d Z(ededef Z)dZ*dZ+dZ,dZ-de.fdZ/e/a0dZ1dZ2Gdd eZ3Gdde3Z4Gdde3Z5Gdde3Z6Gdd e3Z7Gd!d"e3Z8Gd#d$e3Z9y)%N)Lock) AnyCallableDictIterableListLiteralOptionalSequenceTupleTypeTypeVarUnion)values)ExceptionCounterInprogressTrackerTimer)MetricMETRIC_LABEL_NAME_REMETRIC_NAME_RERESERVED_METRIC_LABEL_NAME_RE) CollectorCollectorRegistryREGISTRY)ExemplarSample)floatToGoStringINFTMetricWrapperBase)boundF.cd}|r||dzz }|r||dzz }||z }|dk(r|jdr|dd}|r|jd|zs|d|zz }|r|dvrtd|z|S)N_counter_totali)infostatesetz2Metric name is of a type that cannot have a unit: )endswith ValueError) metric_typename namespace subsystemunit full_names H/opt/hc_python/lib/python3.12/site-packages/prometheus_client/metrics.py_build_full_namer4sIY_$ Y_$  IiI$6$6x$@crN  I&&sTz2S4Z  33MPYYZZ ctj|std|ztj|rtd|zy)NzInvalid label metric name: Reserved label metric name: )rmatchr,r)ls r3_validate_labelnamer:)sE  % %a (6:;;$**1-7!;<<.r5cxt|}|D])}t|||jvstd|z|S)Nr7)tupler:_reserved_labelnamesr,)cls labelnamesr9s r3_validate_labelnamesr@0sEz"J A (( (;a?@ @ r5cd}|jD],\}}t||t|z }|t|z }.|dkDr tdy)NrzDExemplar labels have %d UTF-8 characters, exceeding the limit of 128)itemsr:lenr,)exemplarruneskvs r3_validate_exemplarrI9sX E 1A Q Q! s{_``r5returncbtjjddjdvS)N!PROMETHEUS_DISABLE_CREATED_SERIESFalse)true1t)osenvirongetlowerr5r3_get_use_createdrVCs' ::>>=w G M M OWi iir5cday)zJDisable exporting _created metrics on counters, histograms, and summaries.FN _use_createdrUr5r3disable_created_metricsrZJs Lr5cday)zIEnable exporting _created metrics on counters, histograms, and summaries.TNrXrUr5r3enable_created_metricsr\Ps Lr5cLeZdZUdZeeed<dZeeed<dZ dZ dZ dZ d e efd Zd e efd Zd efd Zd efd Zddddedfdededede ededededeedeeed dfdZdededed efdZded dfdZd"dZd e efdZd e efdZd e efd Zd!Zy)#r!N_typerUr=cT|j xs|jxr |jSN _labelnames _labelvaluesselfs r3_is_observablez MetricWrapperBase._is_observableZs)###O(8(8(NT=N=NOr5cf|js!tdt|jzy)Nz!%s metric is missing label values)rfr,strr^rds r3_raise_if_not_observablez*MetricWrapperBase._raise_if_not_observable`s.""$@3tzz?RS S%r5c8|jxr |j Sr`rards r3 _is_parentzMetricWrapperBase._is_parentgs9(9(9$99r5cnt|j|j|j|jSr`)r_name_documentationr^_unitrds r3 _get_metriczMetricWrapperBase._get_metricjs%djj$"5"5tzz4::NNr5rJc$|jgSr`)rprds r3describezMetricWrapperBase.describems  "##r5c|j}|jD]*\}}}}}|j|j|z||||,|gSr`)rp_samples add_samplerm)remetricsuffixlabelsvalue timestamprEs r3collectzMetricWrapperBase.collectpsR!!#:>--/ 6FFE9h   djj6165)X V;Jxr5c8|jd|jS)N:)r^rmrds r3__str__zMetricWrapperBase.__str__vs**Qtzzl++r5cjt|}|jd|jd|jdS)N.())type __module____name__rm)rer-s r3__repr__zMetricWrapperBase.__repr__ys64j (();+?+?*@$**QOOr5r%rer. documentationr?r/r0r1registryrcc t|j|||||_t|||_t |xsd|_i|_||_||_ tj|jstd|jz|jrt|_i|_|j#r|j%|j s|r|j'|yyy)NrUzInvalid metric name: )r4r^rmr@rbr<rc_kwargsrnrorr8r,rkr_lock_metricsrf _metric_initregister) rer.rr?r/r0r1rrcs r3__init__zMetricWrapperBase.__init__}s&djj$ 9dS /jA!,"4"5') + ##DJJ/4tzzAB B ?? DJ46DM         !!$'!r5 labelvalues labelkwargsc 4|jstd|z|jrBtdj|t t |j|j|r r tdrKt t |jk7r tdtfd|jD}n>t|t|jk7r tdtd|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|ywr`rh).0r9rs r3 z+MetricWrapperBase.labels..sN=MKN 3=MszIncorrect label countc32K|]}t|ywr`rrr9s r3rz+MetricWrapperBase.labels..s< 1A )rr?r1rcN)rbr,rcformatdictzipsortedr<rDrr __class__rmrnror)rerrs `r3rxzMetricWrapperBase.labelss_.KdRS S   _ffS))4+<+<=>  ;AB B k"fT-=-=&>> !899NT=M=MNNK;3t'7'7#88 !899< <.s8KqCFKr) rQrRwarningswarn UserWarningrbr,rDr<rr)rers r3removezMetricWrapperBase.removes % 37QUWU_U_7_ MMX KdRS S8 { s4#3#34 4JcRVRbRbNcepMqqr r8K88 ZZ k*ZZs <CCcdtjvsdtjvrtjdt|j 5i|_dddy#1swYyxYw)z$Remove all labelsets from the metricrrzBClearing labels has not been implemented in multi-process mode yetN)rQrRrrrrrrds r3clearzMetricWrapperBase.clearsI % 37QUWU_U_7_ MMT ZZDMZZs AA%cb|jr|jS|jSr`)rk_multi_samples_child_samplesrds r3rtzMetricWrapperBase._sampless* ?? &&( (&&( (r5c #K|j5|jj}dddjD]s\}}t t |j |}|jD]<\}}}}} t|t|t |jz||| >uy#1swYxYwwr`) rrcopyrClistrrbrtrr) remetricsrxrv series_labelsrw sample_labelsryrzrEs r3rz MetricWrapperBase._multi_sampless ZZmm((*G%mmoNFF T%5%5v!>?MEK__EVA uiVT-$}?R?R?T:U*U%VX]_hjrssFW.Zs CB9BC9C>Cctd|z)Nz*_child_samples() must be implemented by %rNotImplementedErrorrds r3rz MetricWrapperBase._child_sampless!"NQU"UVVr5ctd|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 %rrrds r3rzMetricWrapperBase._metric_inits ""Lt"STTr5rJN) rr __qualname__r^r rh__annotations__r=r rfrirkrprrrrr{r~rrr rrrrxrrrrtrrrrUr5r3r!r!VssE8C=*,(3-,P T:O$(6*$&) ,,P#P.0"$"$9A9=(q(( #(&c]( (  (  ($$56( ( 6((B5.Q5.c5.#5.!5.n+3+4+ )(6*) t 0tW 0WUr5ceZdZdZdZddZddedeee e fddfdZ dd Z e fd e eeeeed ffdefd 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'rJNctj|j|j|jdz|j|j |j |_tj|_ y)Nr() r ValueClassr^rmrbrcrn_valuetime_createdrds r3rzCounter._metric_init0sS'' DJJ X@UW[WgWg(,(9(94;N;NP   r5amountrEc|j|dkr td|jj||rDt ||jj t ||tjyy)z&Increment counter by the given amount.rz9Counters can only be incremented by non-negative amounts.N)rir,rincrI set_exemplarrr)rerrEs r3rz Counter.inc5sb %%' A:XY Y   x ( KK $ $Xh %L M r5cl|jjdtj|_y)zqReset the counter to zero. Use this when a logical process restarts without restarting the actual python process.rN)rsetrrrds r3resetz Counter.reset?s   r5 exception.c:|jt||S)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. )rir)rers r3count_exceptionszCounter.count_exceptionsDs %%'i00r5ctdi|jjd|jj}tr|tdi|j ddfS|fS)Nr(r)rrrS get_exemplarrYr)resamples r3rzCounter._child_samplesNsZ"dkkoo&7t{{?W?W?YZ z2t}}dDA yr5r)rN)rrr__doc__r^rfloatr rrhrr Exceptionrr BaseExceptionr rrrrrrUr5r3rrs$J E$ N%NxS#X/GNSWN$ ir1%]0CU4P]K^`cKcEd0d*e1wG1 0r5rc"eZdZdZdZedZedZddddeddfd e d e d e e d e d e de de e de e e dedffd Zd dZd!deddfdZd!deddfdZdeddfdZd dZdefdZdefdZdegefddfdZde efdZxZS)"GaugeaGauge 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) allliveallminliveminmaxlivemaxsumlivesum mostrecentlivemostrecent)rrrUr%Nrr.rr?r/r0r1rrcmultiprocess_modec | |_| |jvrtd| zt ||||||||||j|j d<|j|j v|_y)NzInvalid multiprocess mode: r.rr?r/r0r1rrcr)_multiprocess_mode_MULTIPROC_MODESr,superrr_MOST_RECENT_MODES_is_most_recent) rer.rr?r/r0r1rrcrrs r3rzGauge.__init__s#4 D$9$9 9:=NNO O '!%  -1,C,C ()#66$:Q:QQr5rJc tj|j|j|j|j|j |j |j|_y)N)r) rrr^rmrbrcrnrrrds r3rzGauge._metric_initsH'' JJ DJJ0@0@$BSBS   43J3J  r5rc|jr td|j|jj |y)z$Increment gauge by the given amount.z-inc must not be used with the mostrecent modeNr RuntimeErrorrirrrers r3rz Gauge.incs3   NO O %%' r5c|jr td|j|jj | y)z$Decrement gauge by the given amount.z-dec must not be used with the mostrecent modeNrrs r3decz Gauge.decs5   NO O %%'  r5ryc|j|jr9|jjt |t j y|jjt |y)zSet gauge to the given value.)rzN)rirrrrr)rerys r3rz Gauge.setsI %%'    KKOOE%LDIIKO @ KKOOE%L )r5cJ|jtjy)z"Set gauge to the current unixtime.N)rrrds r3set_to_current_timezGauge.set_to_current_times r5c8|jt|S)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. )rirrds r3track_inprogresszGauge.track_inprogresss %%' &&r5ct|dS)zTime a block of code or function, and set the duration in seconds. Can be used as a function decorator or context manager. rrrds r3rz Gauge.times T5!!r5fc|jdtdttffd }t j |||_y)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&rJc@tditddfSNr%)rr)r&rs r3samplesz#Gauge.set_function..sampless2r5:tT:< hr5y1 >d >@ 0@r5rcPeZdZdZdZdgZd dZdeddfdZde fd Z de e fd Z y) SummaryaA 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 summaryquantilerJNctj|j|j|jdz|j|j |j |_tj|j|j|jdz|j|j |j |_tj|_ y)N_count_sum) rrr^rmrbrcrnrrrrrds r3rzSummary._metric_inits'' DJJ X@UW[WgWg(,(9(94;N;NP %%djj$**djj6>QSWScSceievevx|yLyLM   r5rc|j|jjd|jj|yafObserve 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)rirrrrs r3observezSummary.observes0 %%'  fr5ct|dSzTime a block of code or function, and observe the duration in seconds. Can be used as a function decorator or context manager. r rrds r3rz Summary.time T9%%r5c tdi|jjddtdi|jjddg}tr(|j tdi|j ddt|S)Nrrr)rrrSrrYappendrr<)rers r3rzSummary._child_samplessj 8R!2D$ ? 62tyy}}d ;   NN6*b$--tL MW~r5r)rrrrr^r=rrr rrrrrrUr5r3rrsK: E&<$ e  &e& 0r5rceZdZdZdZdgZdddddd d d d d ddddefZddddedefde de de e de de de de e de e e de eee fffd Zde eee fd dfd!Zd(d"Zd)d#ed$e ee e fd dfd%Zd efd&Zd e efd'ZxZS)* 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`. histogramleg{Gzt?g{Gz?g?g?g333333?g?g?g?g??g@g@g@g$@rUr%Nr.rr?r/r0r1rrcbucketsc t|j| t | ||||||||| |jd<y)Nrr)_prepare_bucketsrrr) rer.rr?r/r0r1rrcrrs r3rzHistogram.__init__LsM g& '!%  #* Yr5source_bucketsrJc|Dcgc] }t|}}|t|k7r td|r!|dtk7r|j tt |dkr td||_ycc}w)NzBuckets not in sorted orderzMust have at least two buckets)rrr,rrrD _upper_bounds)rerbrs r3rzHistogram._prepare_bucketsdss%34^58^4 fWo %:; ; wr{c) NN3  w >$5sA6c *g|_tj|_|jdz}t j |j |j|jdz|j|j|j|_ |jD]w}|jjt j |j |j|jdz||jt|fz|jyy)N)rr_bucket)_bucketsrrrbrrr^rmrcrnrrrr)rebucket_labelnamesrs r3rzHistogram._metric_initps13    ,,w6%%djj$**djj6>QSWScSceievevx|yLyLM ##A MM !2!2   Y&!!!_Q%7$99## "% $r5rrEc n|j|jj|t|jD]r\}}||ks |j |jd|rFt ||j |jt||tjyyr ) rirr enumeraterr rIrrr)rerrEir"s r3r zHistogram.observes %%' f!$"4"45HAu a $$Q'&x0MM!$11(8VTYY[2YZ 6r5ct|dSr rrds r3rzHistogram.timer r5c Jg}d}t|jD]i\}}||j|jz }|j t ddt |i|d|j|jk|j t di|dd|jddk\r6|j t di|jjddtr(|j t di|jddt|S)Ngrrrrrr) r#rr rSrrrrrrYrr<)reraccr$r"s r3rzHistogram._child_sampless!$"4"45HAu 4==#'') )C NN6)dOE4J-KSRVX\XeXefgXhXuXuXwx y6 vhCt<=   a A % NN6&"diimmotTJ K  NN6*b$--tL MW~r5rr`)rrrrr^r=rDEFAULT_BUCKETSrrhrr rr rrrrrrr rrrrrrs@r3rr%s=!D E 6S$T2sBS#sTWY]_bcO .0"$"$9A9=8G** #*&c]* *  *  *$$56* ( 6*#5#45*0 %xeSj8I/J %t % exS#X/GSW(&e&  0 r5rcFeZdZdZdZdZdeeefddfdZde e fdZ y) InfoaInfo 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)cdt|j|_t|_i|_yr`)rrb_labelname_setrrrrds r3rzInfo._metric_inits%!$"2"23V  r5valrJNcX|jj|jr%tdj |j |t d|jDr td|j5t||_ dddy#1swYyxYw)zSet info metric.z8Overlapping labels for Info metric, metric: {} child: {}c3$K|]}|du ywr`rU)rr$s r3rzInfo.info..s/,QqDy,szLabel value cannot be NoneN) r, intersectionkeysr,rrbanyrrrr)rer-s r3r)z Info.infos~    + +CHHJ 7W^^  #'( ( /#**,/ /9: : ZZs)DKZZs B  B)cz|j5td|jdddfcdddS#1swYyxYw)N_infor)rrrrds r3rzInfo._child_sampless* ZZ7DKKdDACZZs1:) rrrrr^rrrhr)rrrrUr5r3r*r*sA E $S#X$4$D 0Dr5r*ceZdZdZdZddddeddfdededeed ed ed ed ee d eeedeeeffd Z ddZ deddfdZ de efdZxZS)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.rr?r/r0r1rrcstatesc t |||||||||||vrtd|| std|| x|jd<|_y)Nrz$Overlapping labels for Enum metric: z$No states provided for Enum metric: r7)rrr,r_states) rer.rr?r/r0r1rrcr7rs r3rz Enum.__init__sw '!%   : CD6JK KCD6JK K066 Xr5rJc0d|_t|_y)Nr)rrrrds r3rzEnum._metric_inits V r5statec|j|j5|jj||_dddy#1swYyxYw)zSet enum metric state.N)rirr9indexr)rer;s r3r;z Enum.states5 %%' ZZ,,,,U3DKZZs !AAc |j5t|jDcgc]1\}}td|j|i||j k(rdnddd3c}}cdddScc}}w#1swYyxYw)Nr%rr)rr#r9rrmr)rer$ss r3rzEnum._child_samplesso ZZT\\*+AqrDJJ?dkk1AAq$PTU*ZZsA/6A)A/)A//A8r)rrrrr^rrhr r rrrr;rrrrrs@r3r6r6s  E .0"$"$9A9=3777 #7&c]7 7  7  7$$567 ( 67"(3-07643444  0r5r6):rQ threadingrrrtypingrrrrrr r r r r rrrr%rcontext_managersrrr metrics_corerrrrrrrrrrrutilsrrr r#r4r:r@rIboolrVrYrZr\r!rrrrr*r6rUr5r3rFs  HH=<%' C*+ CxS)*  =aj$j !   oU oUdMM`D@ D@NCCL@!@F#D #DL: :r5