U
    4Je+                     @   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e	d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   s   t t| |dS Nindentr   r   selfr    r   S/tmp/pip-unpacked-wheel-7_167w8m/mysql/opentelemetry/sdk/metrics/_internal/point.pyto_json(   s    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e
dddZdS )HistogramDataPointr   r   r   r   countsumbucket_countsZexplicit_boundsminmaxr   r   c                 C   s   t t| |dS r   r   r   r   r   r   r   <   s    zHistogramDataPoint.to_jsonN)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offsetr*   N)r   r    r!   r$   r#   r   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d< eed< e	ed	< e	ed
< eed< eed< eed< de
d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)   ZscaleZ
zero_countZpositivenegativeflagsr+   r,   r   r   c                 C   s   t t| |dS r   r   r   r   r   r   r   Z   s    z%ExponentialHistogramDataPoint.to_jsonN)r   )r   r    r!   r"   r   r#   r$   r   r%   r-   r&   r   r   r   r   r   r/   F   s   
r/   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   r/   r#   r   r   r   r   r2   ^   s   
r2   c                   @   s>   e Zd ZU dZee ed< ded< eed< ded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.r3   r4   r5   is_monotonicr   r   c                    s(   t  fdd| jD | j| jd dS )Nc                    s   g | ]}t |j d qS r   r   r   .0Z
data_pointr   r   r   
<listcomp>x   s   zSum.to_json.<locals>.<listcomp>)r3   r5   r7   r   )r   r3   r5   r7   r   r   r   r   r   u   s    
zSum.to_jsonN)r   )
r   r    r!   r"   r   r   r#   boolr&   r   r   r   r   r   r6   j   s   
r6   c                   @   s.   e Zd ZU dZee ed< ded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.r3   r   r   c                    s    t d fdd| jD i dS )Nr3   c                    s   g | ]}t |j d qS r8   r9   r:   r   r   r   r<      s   z!Gauge.to_json.<locals>.<listcomp>r   )r   r3   r   r   r   r   r      s     
zGauge.to_jsonN)r   )	r   r    r!   r"   r   r   r#   r&   r   r   r   r   r   r>      s   
r>   c                   @   s6   e Zd ZU dZee ed< ded< d
ed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.r3   r4   r5   r   r   c                    s$   t  fdd| jD | jd dS )Nc                    s   g | ]}t |j d qS r8   r9   r:   r   r   r   r<      s   z%Histogram.to_json.<locals>.<listcomp>)r3   r5   r   )r   r3   r5   r   r   r   r   r      s    
zHistogram.to_jsonN)r   )	r   r    r!   r"   r   r'   r#   r&   r   r   r   r   r   r?      s
   
r?   c                   @   sJ   e Zd ZU dZeed< ee ed< ee ed< eed< ded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   )rA   rB   rC   rD   )r   rA   rB   rC   r   rD   r   r   r   r   r   r      s    zMetric.to_jsonN)r   )	r   r    r!   r"   r&   r#   r   DataTr   r   r   r   r   r@      s   
r@   c                   @   s>   e Zd ZU dZeed< ee ed< eed< d
edddZ	d	S )ScopeMetricsz+A collection of Metrics produced by a scopescopemetrics
schema_urlr   r   c                    s4   t t| jj d fdd| jD | jd dS )Nr   c                    s   g | ]}t |j d qS r8   r9   )r;   Zmetricr   r   r   r<      s    z(ScopeMetrics.to_json.<locals>.<listcomp>)rH   rI   rJ   )r   r   rH   r   rI   rJ   r   r   r   r   r      s    
zScopeMetrics.to_jsonN)r   )
r   r    r!   r"   r
   r#   r   r@   r&   r   r   r   r   r   rG      s
   
rG   c                   @   s>   e Zd ZU dZeed< ee ed< eed< d
edddZ	d	S )ResourceMetricsz,A collection of ScopeMetrics from a Resourceresourcescope_metricsrJ   r   r   c                    s4   t t| jj d fdd| jD | jd dS )Nr   c                    s   g | ]}t |j d qS r8   r9   )r;   rM   r   r   r   r<      s   z+ResourceMetrics.to_json.<locals>.<listcomp>)rL   rM   rJ   )r   r   rL   r   rM   rJ   r   r   r   r   r      s    
zResourceMetrics.to_jsonN)r   )
r   r    r!   r"   r	   r#   r   rG   r&   r   r   r   r   r   rK      s
   
rK   c                   @   s.   e Zd ZU dZee ed< dedddZdS )	MetricsDatazAn array of ResourceMetricsresource_metricsr   r   c                    s    t d fdd| jD i dS )NrO   c                    s   g | ]}t |j d qS r8   r9   )r;   rO   r   r   r   r<      s   z'MetricsData.to_json.<locals>.<listcomp>r   )r   rO   r   r   r   r   r      s     
zMetricsData.to_jsonN)r   )	r   r    r!   r"   r   rK   r#   r&   r   r   r   r   r   rN      s   
rN   ) Zdataclassesr   r   jsonr   r   typingr   r   r   Z)mysql.opentelemetry.sdk.metrics._internalZmysqlZ!mysql.opentelemetry.sdk.resourcesr	   Z,mysql.opentelemetry.sdk.util.instrumentationr
   Zmysql.opentelemetry.util.typesr   r   r'   r-   r/   r2   r6   r>   r?   rF   Z
DataPointTr@   rG   rK   rN   r   r   r   r   <module>   s@   