o
    i9                     @  s   d Z ddlmZ ddlmZmZmZ ddlZddl	ZG dd dZ
G dd dZG d	d
 d
ZG dd dZG dd dZG dd dZG dd dZG dd dZdS )zlMetrics using SDK Core. (unstable)

Nothing in this module should be considered stable. The API may change.
    )annotations)MappingOptionalUnionNc                   @  s6   e Zd ZdZedddZdddZedddZdS )MetricMeterzMetric meter using SDK Core.runtime!temporalio.bridge.runtime.RuntimereturnOptional[MetricMeter]c                 C  s    t jj| j}|sdS t|S )zCreate optional metric meter.N)
temporaliobridgetemporal_sdk_bridgenew_metric_meter_refr   )r   ref r   ^/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/temporalio/bridge/metric.pycreate   s   zMetricMeter.creater   4temporalio.bridge.temporal_sdk_bridge.MetricMeterRefNonec                 C  s   || _ t| |j| _dS )zInitialize metric meter.N)r   MetricAttributesdefault_attributes_default_attributes)selfr   r   r   r   __init__   s   zMetricMeter.__init__r   c                 C  s   | j S )z(Default attributes for the metric meter.)r   )r   r   r   r   r       s   zMetricMeter.default_attributesN)r   r   r	   r
   )r   r   r	   r   )r	   r   )	__name__
__module____qualname____doc__staticmethodr   r   propertyr   r   r   r   r   r      s    
r   c                   @  $   e Zd ZdZdddZdddZdS )MetricCounterzMetric counter using SDK Core.meterr   namestrdescriptionOptional[str]unitr	   r   c                 C     |j |||| _ dS )zInitialize counter metric.N)r   new_counterr   r#   r$   r&   r(   r   r   r   r   )      zMetricCounter.__init__valueintattrsr   c                 C  $   |dk rt d| j||j dS )zAdd value to counter.r   'Metric value must be non-negative valueN)
ValueErrorr   addr   r-   r/   r   r   r   r3   3      zMetricCounter.addN
r#   r   r$   r%   r&   r'   r(   r'   r	   r   r-   r.   r/   r   r	   r   )r   r   r   r   r   r3   r   r   r   r   r"   &       

r"   c                   @  r!   )MetricHistogram Metric histogram using SDK Core.r#   r   r$   r%   r&   r'   r(   r	   r   c                 C  r)   zInitialize histogram.N)r   new_histogramr+   r   r   r   r   =   r,   zMetricHistogram.__init__r-   r.   r/   r   c                 C  r0   zRecord value on histogram.r   r1   Nr2   r   recordr4   r   r   r   r?   G   r5   zMetricHistogram.recordNr6   r7   r   r   r   r   r   r?   r   r   r   r   r9   :   r8   r9   c                   @  r!   )MetricHistogramFloatr:   r#   r   r$   r%   r&   r'   r(   r	   r   c                 C  r)   r;   )r   new_histogram_floatr+   r   r   r   r   Q   r,   zMetricHistogramFloat.__init__r-   floatr/   r   c                 C  r0   r=   r>   r4   r   r   r   r?   [   r5   zMetricHistogramFloat.recordNr6   r-   rC   r/   r   r	   r   r@   r   r   r   r   rA   N   r8   rA   c                   @  r!   )MetricHistogramDurationr:   r#   r   r$   r%   r&   r'   r(   r	   r   c                 C  r)   r;   )r   new_histogram_durationr+   r   r   r   r   e   r,   z MetricHistogramDuration.__init__value_msr.   r/   r   c                 C  r0   r=   r>   )r   rG   r/   r   r   r   r?   o   r5   zMetricHistogramDuration.recordNr6   )rG   r.   r/   r   r	   r   r@   r   r   r   r   rE   b   r8   rE   c                   @  r!   )MetricGaugeMetric gauge using SDK Core.r#   r   r$   r%   r&   r'   r(   r	   r   c                 C  r)   zInitialize gauge.N)r   	new_gauger+   r   r   r   r   y   r,   zMetricGauge.__init__r-   r.   r/   r   c                 C  r0   zSet value on gauge.r   r1   Nr2   r   setr4   r   r   r   rN      r5   zMetricGauge.setNr6   r7   r   r   r   r   r   rN   r   r   r   r   rH   v   r8   rH   c                   @  r!   )MetricGaugeFloatrI   r#   r   r$   r%   r&   r'   r(   r	   r   c                 C  r)   rJ   )r   new_gauge_floatr+   r   r   r   r      r,   zMetricGaugeFloat.__init__r-   rC   r/   r   c                 C  r0   rL   rM   r4   r   r   r   rN      r5   zMetricGaugeFloat.setNr6   rD   rO   r   r   r   r   rP      r8   rP   c                   @  s$   e Zd ZdZddd	ZdddZdS )r   z!Metric attributes using SDK Core.r#   r   r   9temporalio.bridge.temporal_sdk_bridge.MetricAttributesRefr	   r   c                 C  s   || _ || _dS )zInitialize attributes.N)_meterr   )r   r#   r   r   r   r   r      s   
zMetricAttributes.__init__	new_attrs*Mapping[str, Union[str, int, float, bool]]c                 C  s   t | j| j| jj|S )z3Create new attributes with new attributes appended.)r   rS   r   with_additional_attributes)r   rT   r   r   r   rV      s   z+MetricAttributes.with_additional_attributesN)r#   r   r   rR   r	   r   )rT   rU   r	   r   )r   r   r   r   r   rV   r   r   r   r   r      s    
	r   )r   
__future__r   typingr   r   r   temporalio.bridge.runtimer   %temporalio.bridge.temporal_sdk_bridger   r"   r9   rA   rE   rH   rP   r   r   r   r   r   <module>   s    