o
    i+                     @   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f Z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   j/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/mysql/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   Z   r   z%ExponentialHistogramDataPoint.to_jsonNr    )r!   r"   r#   r$   r   r%   r&   r   r'   r0   r(   r   r   r   r   r   r2   F   s   
 r2   c                   @   s&   e Zd ZU dZee ed< ded< 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_points=mysql.opentelemetry.sdk.metrics.export.AggregationTemporalityaggregation_temporalityN)r!   r"   r#   r$   r   r2   r%   r   r   r   r   r8   ^   s
   
 
r8   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.r9   r:   r;   is_monotonicr   r   c                    s(   t  fdd| jD | j| jd dS )Nc                       g | ]
}t |j d qS r   r   r   .0
data_pointr   r   r   
<listcomp>x       zSum.to_json.<locals>.<listcomp>)r9   r;   r=   r   )r   r9   r;   r=   r   r   r   r   r   u   s   
zSum.to_jsonNr    )
r!   r"   r#   r$   r   r   r%   boolr(   r   r   r   r   r   r<   j   s   
 r<   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.r9   r   r   c                        t d fdd| jD i dS )Nr9   c                    r>   r?   r@   rA   r   r   r   rD      rE   z!Gauge.to_json.<locals>.<listcomp>r   )r   r9   r   r   r   r   r         zGauge.to_jsonNr    )	r!   r"   r#   r$   r   r   r%   r(   r   r   r   r   r   rH      s   
 rH   c                   @   s6   e Zd ZU dZee ed< ded< d
defddZd	S )	HistogramzRepresents the type of a metric that is calculated by aggregating as a
    histogram of all reported measurements over a time interval.r9   r:   r;   r   r   c                    s$   t  fdd| jD | jd dS )Nc                    r>   r?   r@   rA   r   r   r   rD      rE   z%Histogram.to_json.<locals>.<listcomp>)r9   r;   r   )r   r9   r;   r   r   r   r   r      s   
zHistogram.to_jsonNr    )	r!   r"   r#   r$   r   r)   r%   r(   r   r   r   r   r   rK      s   
 rK   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   )rM   rN   rO   rP   )r   rM   rN   rO   r   rP   r   r   r   r   r   r      s   zMetric.to_jsonNr    )	r!   r"   r#   r$   r(   r%   r   DataTr   r   r   r   r   rL      s   
 rL   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      s    z(ScopeMetrics.to_json.<locals>.<listcomp>)rU   rV   rW   )r   r   rU   r   rV   rW   r   r   r   r   r      s   
zScopeMetrics.to_jsonNr    )
r!   r"   r#   r$   r
   r%   r   rL   r(   r   r   r   r   r   rT         
 rT   c                   @   rS   )ResourceMetricsz,A collection of ScopeMetrics from a Resourceresourcescope_metricsrW   r   r   c                    rX   )Nr   c                    r>   r?   r@   )rB   r]   r   r   r   rD      rE   z+ResourceMetrics.to_json.<locals>.<listcomp>)r\   r]   rW   )r   r   r\   r   r]   rW   r   r   r   r   r      s   
zResourceMetrics.to_jsonNr    )
r!   r"   r#   r$   r	   r%   r   rT   r(   r   r   r   r   r   r[      rZ   r[   c                   @   rG   )	MetricsDatazAn array of ResourceMetricsresource_metricsr   r   c                    rI   )Nr_   c                    r>   r?   r@   )rB   r_   r   r   r   rD      rE   z'MetricsData.to_json.<locals>.<listcomp>r   )r   r_   r   r   r   r   r      rJ   zMetricsData.to_jsonNr    )	r!   r"   r#   r$   r   r[   r%   r(   r   r   r   r   r   r^      s   
 r^   ) dataclassesr   r   jsonr   r   typingr   r   r   )mysql.opentelemetry.sdk.metrics._internalmysql!mysql.opentelemetry.sdk.resourcesr	   ,mysql.opentelemetry.sdk.util.instrumentationr
   mysql.opentelemetry.util.typesr   r   r)   r0   r2   r8   r<   rH   rK   rR   
DataPointTrL   rT   r[   r^   r   r   r   r   <module>   sB   