
     <i9                        d dl mZmZ d dlmZ d dlmZ d dlmZ	 d dl
mZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ  ee          Z e	d
          Z e	d          Z ed           G d d                      Z  ed           G d d                      Z! edd          Z"eee!gee         f         eee         e!df         f         Z# G d de          Z$ G d deee"                   Z% G d de%e"                   Z& G d de$          Z' G d de$          Z( G d d e'          Z) G d! d"e)          Z* G d# d$e%e)         e)          Z+ G d% d&e'          Z, G d' d(e,          Z- G d) d*e%e,         e,          Z. G d+ d,e(          Z/ G d- d.e/          Z0 G d/ d0e&e/         e/          Z1 G d1 d2e(          Z2 G d3 d4e2          Z3 G d5 d6e&e2         e2          Z4 G d7 d8e'          Z5 G d9 d:e5          Z6 G d; d<e%e5         e5          Z7 G d= d>e(          Z8 G d? d@e8          Z9 G dA dBe&e8         e8          Z: G dC dDe'          Z; G dE dFe;          Z< G dG dHe%e;         e;          Z=dS )I    )ABCabstractmethod)	dataclass)	getLogger)compile)	CallableDict	GeneratorGenericIterableOptionalSequenceTypeVarUnion)metrics)Context)Observation)
Attributesz[a-zA-Z][-_./a-zA-Z0-9]{0,254}z[\x00-\x7F]{0,63}T)frozenc                   6    e Zd ZU dZeee                  ed<   dS )_MetricsHistogramAdvisoryNexplicit_bucket_boundaries)__name__
__module____qualname__r   r   r   float__annotations__     /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/opentelemetry/metrics/_internal/instrument.pyr   r   0   s,         <@% 9@@@@@r   r   c                   "    e Zd ZU dZdZeed<   dS )CallbackOptionszOptions for the callback

    Args:
        timeout_millis: Timeout for the callback's execution. If the callback does asynchronous
            work (e.g. HTTP requests), it should respect this timeout.
    i'  timeout_millisN)r   r   r   __doc__r#   r   r   r   r   r    r"   r"   5   s.           #NE"""""r   r"   InstrumentT
Instrument)boundNc                       e Zd ZdZe	 	 d
dedededdfd            Zededededeee	e         f         fd	            Z
dS )r&   z7Abstract class that serves as base for all instruments. nameunitdescriptionreturnNc                     d S Nr   selfr*   r+   r,   s       r    __init__zInstrument.__init__L   	     	r   c                     i }t                               |           | |d<   nd|d<   |d}t                              |          ||d<   nd|d<   |d|d<   n||d<   |S )as  
        Checks the following instrument name, unit and description for
        compliance with the spec.

        Returns a dict with keys "name", "unit" and "description", the
        corresponding values will be the checked strings or `None` if the value
        is invalid. If valid, the checked strings should be used instead of the
        original values.
        Nr*   r)   r+   r,   )_name_regex	fullmatch_unit_regex)r*   r+   r,   results       r    _check_name_unit_descriptionz'Instrument._check_name_unit_descriptionU   s     ,.  &&2!F6NN!F6N<D  &&2!F6NN!F6N$&F=!!$/F=!r   r)   r)   )r   r   r   r$   r   strr2   staticmethodr	   r   r9   r   r   r    r&   r&   I   s        AA 	   	
 
   ^    +. 	c8C= 	!      \     r   c            	       T    e Zd Z	 	 ddedededdfdZdd
Zedd	defd            ZdS )_ProxyInstrumentr)   r*   r+   r,   r-   Nc                 >    || _         || _        || _        d | _        d S r/   )_name_unit_description_real_instrumentr0   s       r    r2   z_ProxyInstrument.__init__z   s(     

'7;r   metermetrics.Meterc                 :    |                      |          | _        dS )z;Called when a real meter is set on the creating _ProxyMeterN)_create_real_instrumentrC   r1   rD   s     r    on_meter_setz_ProxyInstrument.on_meter_set   s      !% < <U C Cr   c                     dS )z:Create an instance of the real instrument. Implement this.Nr   rH   s     r    rG   z(_ProxyInstrument._create_real_instrument   s      r   r:   )rD   rE   r-   N)	r   r   r   r;   r2   rI   r   r%   rG   r   r   r    r>   r>   y   s         		< 	<	< 	< 		<
 
	< 	< 	< 	<D D D D I_ I I I I ^I I Ir   r>   c                   T     e Zd Z	 	 	 d	dedeee                  dededdf
 fdZ xZS )
_ProxyAsynchronousInstrumentNr)   r*   	callbacksr+   r,   r-   c                 \    t                                          |||           || _        d S r/   )superr2   
_callbacksr1   r*   rM   r+   r,   	__class__s        r    r2   z%_ProxyAsynchronousInstrument.__init__   s,     	t[111#r   Nr)   r)   )	r   r   r   r;   r   r   	CallbackTr2   __classcell__rR   s   @r    rL   rL      s         48$ $$ HY/0$ 	$
 $ 
$ $ $ $ $ $ $ $ $ $r   rL   c                       e Zd ZdZdS )Synchronousz*Base class for all synchronous instrumentsNr   r   r   r$   r   r   r    rX   rX      s        4444r   rX   c                   h     e Zd ZdZe	 	 	 d
dedeee                  dededdf
 fd	            Z	 xZ
S )Asynchronousz+Base class for all asynchronous instrumentsNr)   r*   rM   r+   r,   r-   c                 P    t                                          |||           d S N)r+   r,   rO   r2   rQ   s        r    r2   zAsynchronous.__init__   s*     	DkBBBBBr   rS   )r   r   r   r$   r   r;   r   r   rT   r2   rU   rV   s   @r    r[   r[      s        55 48C CC HY/0C 	C
 C 
C C C C C ^C C C C Cr   r[   c            
       h    e Zd ZdZe	 	 ddeeef         dee	         dee
         ddfd            ZdS )	CounterzOA Counter is a synchronous `Instrument` which supports non-negative increments.Namount
attributescontextr-   c                     d S r/   r   r1   ra   rb   rc   s       r    addzCounter.add   r3   r   NNr   r   r   r$   r   r   intr   r   r   r   rf   r   r   r    r`   r`      s~        YY ,0%)	 c5j! Z( '"	
 
   ^  r   r`   c            	            e Zd ZdZ	 	 ddedededdf fdZ	 	 dd	eeef         d
e	e
         de	e         ddf fdZ xZS )NoOpCounterz"No-op implementation of `Counter`.r)   r*   r+   r,   r-   Nc                 P    t                                          |||           d S r]   r^   r1   r*   r+   r,   rR   s       r    r2   zNoOpCounter.__init__   *     	DkBBBBBr   ra   rb   rc   c                 L    t                                          |||          S N)rb   rc   rO   rf   r1   ra   rb   rc   rR   s       r    rf   zNoOpCounter.add   !     ww{{6j'{JJJr   r:   rg   r   r   r   r$   r;   r2   r   ri   r   r   r   r   rf   rU   rV   s   @r    rk   rk              ,,
 	C CC C 	C
 
C C C C C C ,0%)	K Kc5j!K Z(K '"	K
 
K K K K K K K K K Kr   rk   c            	       d    e Zd Z	 	 d
deeef         dee         dee         ddfdZ	ddde
fd	ZdS )_ProxyCounterNra   rb   rc   r-   c                 P    | j         r| j                             |||           d S d S r/   rC   rf   re   s       r    rf   z_ProxyCounter.add   =       	C!%%fj'BBBBB	C 	Cr   rD   rE   c                 N    |                     | j        | j        | j                  S r/   )create_counterr@   rA   rB   rH   s     r    rG   z%_ProxyCounter._create_real_instrument   s*    ##JJ
 
 	
r   rg   )r   r   r   r   ri   r   r   r   r   rf   r`   rG   r   r   r    rw   rw      s         ,0%)	C Cc5j!C Z(C '"	C
 
C C C C
_ 
 
 
 
 
 
 
r   rw   c            
       h    e Zd ZdZe	 	 ddeeef         dee	         dee
         ddfd            ZdS )	UpDownCounterzXAn UpDownCounter is a synchronous `Instrument` which supports increments and decrements.Nra   rb   rc   r-   c                     d S r/   r   re   s       r    rf   zUpDownCounter.add   r3   r   rg   rh   r   r   r    r~   r~      s~        bb ,0%)	 c5j! Z( '"	
 
   ^  r   r~   c            	            e Zd ZdZ	 	 ddedededdf fdZ	 	 dd	eeef         d
e	e
         de	e         ddf fdZ xZS )NoOpUpDownCounterz(No-op implementation of `UpDownCounter`.r)   r*   r+   r,   r-   Nc                 P    t                                          |||           d S r]   r^   rm   s       r    r2   zNoOpUpDownCounter.__init__   rn   r   ra   rb   rc   c                 L    t                                          |||          S rp   rq   rr   s       r    rf   zNoOpUpDownCounter.add   rs   r   r:   rg   rt   rV   s   @r    r   r      s        22
 	C CC C 	C
 
C C C C C C ,0%)	K Kc5j!K Z(K '"	K
 
K K K K K K K K K Kr   r   c            	       d    e Zd Z	 	 d
deeef         dee         dee         ddfdZ	ddde
fd	ZdS )_ProxyUpDownCounterNra   rb   rc   r-   c                 P    | j         r| j                             |||           d S d S r/   ry   re   s       r    rf   z_ProxyUpDownCounter.add  rz   r   rD   rE   c                 N    |                     | j        | j        | j                  S r/   )create_up_down_counterr@   rA   rB   rH   s     r    rG   z+_ProxyUpDownCounter._create_real_instrument  s*    ++JJ
 
 	
r   rg   )r   r   r   r   ri   r   r   r   r   rf   r~   rG   r   r   r    r   r     s         ,0%)	C Cc5j!C Z(C '"	C
 
C C C C
_ 
 
 
 
 
 
 
r   r   c                       e Zd ZdZdS )ObservableCounterzAn ObservableCounter is an asynchronous `Instrument` which reports monotonically
    increasing value(s) when the instrument is being observed.
    NrY   r   r   r    r   r     s           r   r   c                   X     e Zd ZdZ	 	 	 d
dedeee                  dededdf
 fd	Z xZ	S )NoOpObservableCounterz,No-op implementation of `ObservableCounter`.Nr)   r*   rM   r+   r,   r-   c                 R    t                                          ||||           d S r]   r^   rQ   s        r    r2   zNoOpObservableCounter.__init__  <     	#	 	 	
 	
 	
 	
 	
r   rS   
r   r   r   r$   r;   r   r   rT   r2   rU   rV   s   @r    r   r     s        66
 48
 

 HY/0
 	

 
 

 
 
 
 
 
 
 
 
 
r   r   c                       e Zd ZdddefdZdS )_ProxyObservableCounterrD   rE   r-   c                 Z    |                     | j        | j        | j        | j                  S r/   )create_observable_counterr@   rP   rA   rB   rH   s     r    rG   z/_ProxyObservableCounter._create_real_instrument1  s1     ..JOJ	
 
 	
r   N)r   r   r   r   rG   r   r   r    r   r   .  s8        
$
	
 
 
 
 
 
r   r   c                       e Zd ZdZdS )ObservableUpDownCountera  An ObservableUpDownCounter is an asynchronous `Instrument` which reports additive value(s) (e.g.
    the process heap size - it makes sense to report the heap size from multiple processes and sum them
    up, so we get the total heap usage) when the instrument is being observed.
    NrY   r   r   r    r   r   <             r   r   c                   X     e Zd ZdZ	 	 	 d
dedeee                  dededdf
 fd	Z xZ	S )NoOpObservableUpDownCounterz2No-op implementation of `ObservableUpDownCounter`.Nr)   r*   rM   r+   r,   r-   c                 R    t                                          ||||           d S r]   r^   rQ   s        r    r2   z$NoOpObservableUpDownCounter.__init__F  r   r   rS   r   rV   s   @r    r   r   C  s        <<
 48
 

 HY/0
 	

 
 

 
 
 
 
 
 
 
 
 
r   r   c                       e Zd ZdddefdZdS )_ProxyObservableUpDownCounterrD   rE   r-   c                 Z    |                     | j        | j        | j        | j                  S r/   )!create_observable_up_down_counterr@   rP   rA   rB   rH   s     r    rG   z5_ProxyObservableUpDownCounter._create_real_instrumentY  s1     66JOJ	
 
 	
r   N)r   r   r   r   rG   r   r   r    r   r   U  s8        
$
	 
 
 
 
 
 
r   r   c                       e Zd ZdZe	 	 	 ddedededeee                  ddf
d	            Z	e	 	 dd
e
eef         dee         dee         ddfd            ZdS )	HistogramzHistogram is a synchronous `Instrument` which can be used to report arbitrary values
    that are likely to be statistically meaningful. It is intended for statistics such as
    histograms, summaries, and percentile.
    r)   Nr*   r+   r,   #explicit_bucket_boundaries_advisoryr-   c                     d S r/   r   )r1   r*   r+   r,   r   s        r    r2   zHistogram.__init__j  s	     	r   ra   rb   rc   c                     d S r/   r   re   s       r    recordzHistogram.recordt  r3   r   r)   r)   Nrg   )r   r   r   r$   r   r;   r   r   r   r2   r   ri   r   r   r   r   r   r    r   r   d  s         
  IM   	
 .6huo-F 
   ^  ,0%)	 c5j! Z( '"	
 
   ^  r   r   c                        e Zd ZdZ	 	 	 ddedededeee                  ddf
 fd	Z	 	 dd
e	e
ef         dee         dee         ddf fdZ xZS )NoOpHistogramz$No-op implementation of `Histogram`.r)   Nr*   r+   r,   r   r-   c                 R    t                                          ||||           d S )N)r+   r,   r   r^   r1   r*   r+   r,   r   rR   s        r    r2   zNoOpHistogram.__init__  s<     	#0S	 	 	
 	
 	
 	
 	
r   ra   rb   rc   c                 L    t                                          |||          S rp   )rO   r   rr   s       r    r   zNoOpHistogram.record  s!     ww~~fW~MMMr   r   rg   )r   r   r   r$   r;   r   r   r   r2   r   ri   r   r   r   rU   rV   s   @r    r   r   ~  s        ..
 IM
 

 
 	

 .6huo-F
 

 
 
 
 
 
" ,0%)	N Nc5j!N Z(N '"	N
 
N N N N N N N N N Nr   r   c                        e Zd Z	 	 	 ddedededeee                  ddf
 fdZ	 	 dd	ee	ef         d
ee
         dee         ddfdZdddefdZ xZS )_ProxyHistogramr)   Nr*   r+   r,   r   r-   c                 ^    t                                          |||           || _        d S r]   )rO   r2   $_explicit_bucket_boundaries_advisoryr   s        r    r2   z_ProxyHistogram.__init__  s5     	DkBBB/ 	111r   ra   rb   rc   c                 P    | j         r| j                             |||           d S d S r/   )rC   r   re   s       r    r   z_ProxyHistogram.record  s=       	F!((WEEEEE	F 	Fr   rD   rE   c                 \    |                     | j        | j        | j        | j                  S )N)r   )create_histogramr@   rA   rB   r   rH   s     r    rG   z'_ProxyHistogram._create_real_instrument  s5    %%JJ040Y	 & 
 
 	
r   r   rg   )r   r   r   r;   r   r   r   r2   r   ri   r   r   r   r   rG   rU   rV   s   @r    r   r     s        IM

 



 

 	


 .6huo-F

 


 

 

 

 

 

 ,0%)	F Fc5j!F Z(F '"	F
 
F F F F
_ 
 
 
 
 
 
 
 
 
r   r   c                       e Zd ZdZdS )ObservableGaugezAsynchronous Gauge is an asynchronous `Instrument` which reports non-additive value(s) (e.g.
    the room temperature - it makes no sense to report the temperature value from multiple rooms
    and sum them up) when the instrument is being observed.
    NrY   r   r   r    r   r     r   r   r   c                   X     e Zd ZdZ	 	 	 d
dedeee                  dededdf
 fd	Z xZ	S )NoOpObservableGaugez*No-op implementation of `ObservableGauge`.Nr)   r*   rM   r+   r,   r-   c                 R    t                                          ||||           d S r]   r^   rQ   s        r    r2   zNoOpObservableGauge.__init__  r   r   rS   r   rV   s   @r    r   r     s        44
 48
 

 HY/0
 	

 
 

 
 
 
 
 
 
 
 
 
r   r   c                       e Zd ZdddefdZdS )_ProxyObservableGaugerD   rE   r-   c                 Z    |                     | j        | j        | j        | j                  S r/   )create_observable_gauger@   rP   rA   rB   rH   s     r    rG   z-_ProxyObservableGauge._create_real_instrument  s1     ,,JOJ	
 
 	
r   N)r   r   r   r   rG   r   r   r    r   r     s8        
$
	
 
 
 
 
 
r   r   c            
       h    e Zd ZdZe	 	 ddeeef         dee	         dee
         ddfd            ZdS )	GaugezdA Gauge is a synchronous `Instrument` which can be used to record non-additive values as they occur.Nra   rb   rc   r-   c                     d S r/   r   re   s       r    setz	Gauge.set  r3   r   rg   )r   r   r   r$   r   r   ri   r   r   r   r   r   r   r   r    r   r     s~        nn ,0%)	 c5j! Z( '"	
 
   ^  r   r   c            	            e Zd ZdZ	 	 ddedededdf fdZ	 	 dd	eeef         d
e	e
         de	e         ddf fdZ xZS )	NoOpGaugez"No-op implementation of ``Gauge``.r)   r*   r+   r,   r-   Nc                 P    t                                          |||           d S r]   r^   rm   s       r    r2   zNoOpGauge.__init__  rn   r   ra   rb   rc   c                 L    t                                          |||          S rp   )rO   r   rr   s       r    r   zNoOpGauge.set  rs   r   r:   rg   )r   r   r   r$   r;   r2   r   ri   r   r   r   r   r   rU   rV   s   @r    r   r     ru   r   r   c            	       d    e Zd Z	 	 d
deeef         dee         dee         ddfdZ	ddde
fd	ZdS )_ProxyGaugeNra   rb   rc   r-   c                 P    | j         r| j                             |||           d S d S r/   )rC   r   re   s       r    r   z_ProxyGauge.set  rz   r   rD   rE   c                 N    |                     | j        | j        | j                  S r/   )create_gauger@   rA   rB   rH   s     r    rG   z#_ProxyGauge._create_real_instrument  s*    !!JJ
 
 	
r   rg   )r   r   r   r   ri   r   r   r   r   r   r   rG   r   r   r    r   r      s         ,0%)	C Cc5j!C Z(C '"	C
 
C C C C
_ 
 
 
 
 
 
 
r   r   )>abcr   r   dataclassesr   loggingr   rer   
re_compiletypingr   r	   r
   r   r   r   r   r   r   opentelemetryr   opentelemetry.contextr   +opentelemetry.metrics._internal.observationr   opentelemetry.util.typesr   r   _loggerr5   r7   r   r"   r%   rT   r&   r>   rL   rX   r[   r`   rk   rw   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    <module>r      s  $ $ # # # # # # # ! ! ! ! ! !       $ $ $ $ $ $
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 " ! ! ! ! ! ) ) ) ) ) ) C C C C C C      )H

j:;;j-.. $A A A A A A A A $# # # # # # # # gm<888o 556h{#_d:;=	- - - - - - - -`I I I I IsGK0 I I I2	$ 	$ 	$ 	$ 	$#3K#@ 	$ 	$ 	$5 5 5 5 5* 5 5 5C C C C C: C C C
 
 
 
 
k 
 
 
K K K K K' K K K(
 
 
 
 
$W-w 
 
 
$
 
 
 
 
K 
 
 
K K K K K K K K(
 
 
 
 
*=9= 
 
 
$       
 
 
 
 
- 
 
 
$
 
 
 
 
 !235F
 
 
    l   
 
 
 
 
"9 
 
 
$
 
 
 
 
 !89
 
 
       4N N N N NI N N N4
 
 
 
 
&y19 
 
 
>    l   
 
 
 
 
/ 
 
 
$
 
 
 
 
 1
 
 

 
 
 
 
K 
 
 
K K K K K K K K(
 
 
 
 
U	
 
 
 
 
r   