o
    g                     @   s  d dl mZ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 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field)dumpsloads)OptionalSequenceUnionN)Exemplar)Resource)InstrumentationScope)
AttributesT)frozenc                   @   s`   e Zd ZU dZeed< eed< eed< eeef ed< e	e
dZee 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default_factory	exemplars   returnc                 C      t t| |dS Nindentr   r   selfr    r!   `/var/www/visachat/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	   floatr   listr   r   r
   strr#   r!   r!   r!   r"   r      s   
 r   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 ed< e	e ed< eed	< eed
< e
edZe	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   r   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!   r!   r!   r"   r/   -   s   
 r/   c                   @   s"   e Zd ZU eed< ee ed< dS )Bucketsoffsetr2   N)r&   r'   r(   r+   r*   r   r!   r!   r!   r"   r6   B   s   
 r6   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< e
edZe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   r0   r1   scale
zero_countpositivenegativeflagsr4   r5   r   r   r   r   c                 C   r   r   r   r   r!   r!   r"   r#   ]   r$   z%ExponentialHistogramDataPoint.to_jsonNr%   )r&   r'   r(   r)   r   r*   r+   r	   r,   r6   r   r-   r   r   r
   r.   r#   r!   r!   r!   r"   r8   H   s    
 r8   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>o       z0ExponentialHistogram.to_json.<locals>.<listcomp>r@   rB   r   r   r@   rB   r   r!   r   r"   r#   l      
zExponentialHistogram.to_jsonNr%   )	r&   r'   r(   r)   r   r8   r*   r.   r#   r!   r!   r!   r"   r?   a   s   
 r?   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@   rA   rB   is_monotonicr   r   c                    s(   t  fdd| jD | j| jd dS )Nc                    rD   rE   rF   rG   r   r!   r"   rJ      rK   zSum.to_json.<locals>.<listcomp>)r@   rB   rP   r   )r   r@   rB   rP   r   r!   r   r"   r#      s   
zSum.to_jsonNr%   )
r&   r'   r(   r)   r   r   r*   boolr.   r#   r!   r!   r!   r"   rO   y   s   
 rO   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                    rD   rE   rF   rG   r   r!   r"   rJ      rK   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"   rS      s   
 rS   c                   @   r>   )	HistogramzRepresents the type of a metric that is calculated by aggregating as a
    histogram of all reported measurements over a time interval.r@   rA   rB   r   r   c                    rC   )Nc                    rD   rE   rF   rG   r   r!   r"   rJ      rK   z%Histogram.to_json.<locals>.<listcomp>rL   r   rM   r   r!   r   r"   r#      rN   zHistogram.to_jsonNr%   )	r&   r'   r(   r)   r   r/   r*   r.   r#   r!   r!   r!   r"   rV      s   
 rV   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   )rX   rY   rZ   r[   )r   rX   rY   rZ   r   r[   r#   r   r!   r!   r"   r#      s   zMetric.to_jsonNr%   )	r&   r'   r(   r)   r.   r*   r   DataTr#   r!   r!   r!   r"   rW      s   
 rW   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                    rD   rE   rF   )rH   metricr   r!   r"   rJ      rK   z(ScopeMetrics.to_json.<locals>.<listcomp>)r`   ra   rb   )r   r   r`   r#   ra   rb   r   r!   r   r"   r#         
zScopeMetrics.to_jsonNr%   )
r&   r'   r(   r)   r   r*   r   rW   r.   r#   r!   r!   r!   r"   r_         
 r_   c                   @   r^   )ResourceMetricsz,A collection of ScopeMetrics from a Resourceresourcescope_metricsrb   r   r   c                    rc   )Nr   c                    rD   rE   rF   )rH   ri   r   r!   r"   rJ      rK   z+ResourceMetrics.to_json.<locals>.<listcomp>)rh   ri   rb   )r   r   rh   r#   ri   rb   r   r!   r   r"   r#      re   zResourceMetrics.to_jsonNr%   )
r&   r'   r(   r)   r   r*   r   r_   r.   r#   r!   r!   r!   r"   rg      rf   rg   c                   @   rR   )	MetricsDatazAn array of ResourceMetricsresource_metricsr   r   c                    rT   )Nrk   c                    rD   rE   rF   )rH   rk   r   r!   r"   rJ     rK   z'MetricsData.to_json.<locals>.<listcomp>r   )r   rk   r   r!   r   r"   r#     rU   zMetricsData.to_jsonNr%   )	r&   r'   r(   r)   r   rg   r*   r.   r#   r!   r!   r!   r"   rj     s   
 rj   )#dataclassesr   r   r   jsonr   r   typingr   r   r	   #opentelemetry.sdk.metrics._internalopentelemetry,opentelemetry.sdk.metrics._internal.exemplarr
   opentelemetry.sdk.resourcesr   &opentelemetry.sdk.util.instrumentationr   opentelemetry.util.typesr   r   r/   r6   r8   r?   rO   rS   rV   r]   
DataPointTrW   r_   rg   rj   r!   r!   r!   r"   <module>   sH   