o
    tBh                     @   s  d dl mZmZ d dlmZmZ d dlmZmZm	Z	 d dl
Zd dlmZ d dlmZ d dlmZ edd	G d
d dZedd	G dd dZedd	G dd dZedd	G dd dZedd	G dd dZedd	G dd dZedd	G dd dZedd	G dd dZe	eeeef Ze	eeef Zedd	G dd dZedd	G dd dZedd	G dd dZedd	G d d! d!ZdS )"    )asdict	dataclass)dumpsloads)OptionalSequenceUnionN)Resource)InstrumentationScope)
AttributesT)frozenc                   @   sJ   e Zd ZU dZeed< eed< eed< eeef ed< dde	fdd	Z
d
S )NumberDataPointdSingle data point in a timeseries that describes the time-varying scalar
    value of a metric.
    
attributesstart_time_unix_nanotime_unix_nanovalue   returnc                 C      t t| |dS Nindentr   r   selfr    r   /var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/opentelemetry/sdk/metrics/_internal/point.pyto_json'      zNumberDataPoint.to_jsonNr   )__name__
__module____qualname____doc__r   __annotations__intr   floatstrr   r   r   r   r   r      s   
 r   c                   @   sz   e Zd ZU dZeed< eed< eed< eed< eeef ed< e	e ed< e	e ed< eed	< eed
< dde
fddZdS )HistogramDataPointr   r   r   r   countsumbucket_countsexplicit_boundsminmaxr   r   c                 C   r   r   r   r   r   r   r   r   ;   r   zHistogramDataPoint.to_jsonNr    )r!   r"   r#   r$   r   r%   r&   r   r'   r   r(   r   r   r   r   r   r)   +   s   
 r)   c                   @   s"   e Zd ZU eed< ee ed< dS )Bucketsoffsetr,   N)r!   r"   r#   r&   r%   r   r   r   r   r   r0   ?   s   
 r0   c                   @   s   e Zd ZU dZeed< eed< eed< eed< eeef ed< eed< eed< e	ed	< e	ed
< eed< eed< eed< dde
fddZdS )ExponentialHistogramDataPointzSingle data point in a timeseries whose boundaries are defined by an
    exponential function. This timeseries describes the time-varying scalar
    value of a metric.
    r   r   r   r*   r+   scale
zero_countpositivenegativeflagsr.   r/   r   r   c                 C   r   r   r   r   r   r   r   r   Y   r   z%ExponentialHistogramDataPoint.to_jsonNr    )r!   r"   r#   r$   r   r%   r&   r   r'   r0   r(   r   r   r   r   r   r2   E   s   
 r2   c                   @   6   e Zd ZU dZee ed< ded< d
defddZd	S )ExponentialHistogramzRepresents the type of a metric that is calculated by aggregating as an
    ExponentialHistogram of all reported measurements over a time interval.
    data_points7opentelemetry.sdk.metrics.export.AggregationTemporalityaggregation_temporalityr   r   c                    $   t  fdd| jD | jd dS )Nc                       g | ]
}t |j d qS r   r   r   .0
data_pointr   r   r   
<listcomp>k       z0ExponentialHistogram.to_json.<locals>.<listcomp>r:   r<   r   r   r:   r<   r   r   r   r   r   h      
zExponentialHistogram.to_jsonNr    )	r!   r"   r#   r$   r   r2   r%   r(   r   r   r   r   r   r9   ]   s   
 r9   c                   @   s>   e Zd ZU dZee ed< ded< eed< ddefdd	Z	d
S )SumzyRepresents the type of a scalar metric that is calculated as a sum of
    all reported measurements over a time interval.r:   r;   r<   is_monotonicr   r   c                    s(   t  fdd| jD | j| jd dS )Nc                    r>   r?   r@   rA   r   r   r   rD      rE   zSum.to_json.<locals>.<listcomp>)r:   r<   rJ   r   )r   r:   r<   rJ   r   r   r   r   r      s   
zSum.to_jsonNr    )
r!   r"   r#   r$   r   r   r%   boolr(   r   r   r   r   r   rI   u   s   
 rI   c                   @   .   e Zd ZU dZee ed< ddefddZdS )	GaugezRepresents the type of a scalar metric that always exports the current
    value for every data point. It should be used for an unknown
    aggregation.r:   r   r   c                        t d fdd| jD i dS )Nr:   c                    r>   r?   r@   rA   r   r   r   rD      rE   z!Gauge.to_json.<locals>.<listcomp>r   )r   r:   r   r   r   r   r         zGauge.to_jsonNr    )	r!   r"   r#   r$   r   r   r%   r(   r   r   r   r   r   rM      s   
 rM   c                   @   r8   )	HistogramzRepresents the type of a metric that is calculated by aggregating as a
    histogram of all reported measurements over a time interval.r:   r;   r<   r   r   c                    r=   )Nc                    r>   r?   r@   rA   r   r   r   rD      rE   z%Histogram.to_json.<locals>.<listcomp>rF   r   rG   r   r   r   r   r      rH   zHistogram.to_jsonNr    )	r!   r"   r#   r$   r   r)   r%   r(   r   r   r   r   r   rP      s   
 rP   c                   @   sJ   e Zd ZU dZeed< ee ed< ee ed< eed< ddefdd	Zd
S )MetriczMRepresents a metric point in the OpenTelemetry data model to be
    exported.namedescriptionunitdatar   r   c                 C   s2   t | j| jpd| jpdt| jj|dd|dS )N r   )rR   rS   rT   rU   )r   rR   rS   rT   r   rU   r   r   r   r   r   r      s   zMetric.to_jsonNr    )	r!   r"   r#   r$   r(   r%   r   DataTr   r   r   r   r   rQ      s   
 rQ   c                   @   >   e Zd ZU dZeed< ee ed< eed< d
defddZ	d	S )ScopeMetricsz+A collection of Metrics produced by a scopescopemetrics
schema_urlr   r   c                    4   t t| jj d fdd| jD | jd dS )Nr   c                    r>   r?   r@   )rB   metricr   r   r   rD      rE   z(ScopeMetrics.to_json.<locals>.<listcomp>)rZ   r[   r\   )r   r   rZ   r   r[   r\   r   r   r   r   r         
zScopeMetrics.to_jsonNr    )
r!   r"   r#   r$   r
   r%   r   rQ   r(   r   r   r   r   r   rY         
 rY   c                   @   rX   )ResourceMetricsz,A collection of ScopeMetrics from a Resourceresourcescope_metricsr\   r   r   c                    r]   )Nr   c                    r>   r?   r@   )rB   rc   r   r   r   rD      rE   z+ResourceMetrics.to_json.<locals>.<listcomp>)rb   rc   r\   )r   r   rb   r   rc   r\   r   r   r   r   r      r_   zResourceMetrics.to_jsonNr    )
r!   r"   r#   r$   r	   r%   r   rY   r(   r   r   r   r   r   ra      r`   ra   c                   @   rL   )	MetricsDatazAn array of ResourceMetricsresource_metricsr   r   c                    rN   )Nre   c                    r>   r?   r@   )rB   re   r   r   r   rD     rE   z'MetricsData.to_json.<locals>.<listcomp>r   )r   re   r   r   r   r   r     rO   zMetricsData.to_jsonNr    )	r!   r"   r#   r$   r   ra   r%   r(   r   r   r   r   r   rd     s   
 rd   ) dataclassesr   r   jsonr   r   typingr   r   r   #opentelemetry.sdk.metrics._internalopentelemetryopentelemetry.sdk.resourcesr	   &opentelemetry.sdk.util.instrumentationr
   opentelemetry.util.typesr   r   r)   r0   r2   r9   rI   rM   rP   rW   
DataPointTrQ   rY   ra   rd   r   r   r   r   <module>   sF   