o
    i.                     @  s   d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZ ddlmZ ddlZ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G dd deZdS )zlTelemetry for SDK Core. (unstable)

Nothing in this module should be considered stable. The API may change.
    )annotations)	dataclass)AnyCallableDictMappingOptionalSequenceType)ProtocolNc                   @  sF   e Zd ZdZeddd	ZdddZdddZdddZdddZ	dS )RuntimezRuntime for SDK Core.	thread_idintexc_typeType[BaseException]returnboolc                 C  s   t jj| |S )z3Internal helper for raising an exception in thread.)
temporaliobridgetemporal_sdk_bridgeraise_in_thread)r   r    r   _/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/temporalio/bridge/runtime.py_raise_in_thread   s   zRuntime._raise_in_thread	telemetryTelemetryConfigNonec                C  s   t jj|| _dS )zCreate SDK Core runtime.N)r   r   r   init_runtime_ref)selfr   r   r   r   __init__   s   zRuntime.__init__durations_as_secondsSequence[Any]c                 C  s   | j |S )zGet buffered metrics.)r   retrieve_buffered_metrics)r   r!   r   r   r   r#      s   z!Runtime.retrieve_buffered_metricsmessagestr
extra_datac                 C     | j || dS )z$Write a test core log at INFO level.N)r   write_test_info_logr   r$   r&   r   r   r   r(   "      zRuntime.write_test_info_logc                 C  r'   )z%Write a test core log at DEBUG level.N)r   write_test_debug_logr)   r   r   r   r+   &   r*   zRuntime.write_test_debug_logN)r   r   r   r   r   r   )r   r   r   r   )r!   r   r   r"   )r$   r%   r&   r%   r   r   )
__name__
__module____qualname____doc__staticmethodr   r    r#   r(   r+   r   r   r   r   r      s    


r   T)frozenc                   @  "   e Zd ZU dZded< ded< dS )LoggingConfigz<Python representation of the Rust struct for logging config.r%   filterz6Optional[Callable[[Sequence[BufferedLogEntry]], None]]
forward_toNr,   r-   r.   r/   __annotations__r   r   r   r   r3   +      
 r3   c                   @  sB   e Zd ZU dZded< ded< ded< ded	< d
ed< ded< dS )MetricsConfigz<Python representation of the Rust struct for metrics config.zOptional[OpenTelemetryConfig]opentelemetryzOptional[PrometheusConfig]
prometheusr   buffered_with_sizer   attach_service_namezOptional[Mapping[str, str]]global_tagszOptional[str]metric_prefixNr6   r   r   r   r   r9   3      
 r9   c                   @  sB   e Zd ZU dZded< ded< ded< ded	< ded
< ded< dS )OpenTelemetryConfigzBPython representation of the Rust struct for OpenTelemetry config.r%   urlzMapping[str, str]headerszOptional[int]metric_periodicity_millisr   metric_temporality_deltar!   httpNr6   r   r   r   r   rA   ?   r@   rA   c                   @  s>   e Zd ZU dZded< ded< ded< ded< dZd	ed
< dS )PrometheusConfigz?Python representation of the Rust struct for Prometheus config.r%   bind_addressr   counters_total_suffixunit_suffixr!   Nz'Optional[Mapping[str, Sequence[float]]]histogram_bucket_overrides)r,   r-   r.   r/   r7   rK   r   r   r   r   rG   K   s   
 rG   c                   @  r2   )r   z>Python representation of the Rust struct for telemetry config.zOptional[LoggingConfig]loggingzOptional[MetricsConfig]metricsNr6   r   r   r   r   r   V   r8   r   c                   @  sV   e Zd ZdZedddZedddZedd	d
ZedddZedddZ	dS )BufferedLogEntryzA buffered log entry.r   r%   c                 C     dS )z"Target category for the log entry.Nr   r   r   r   r   targetb      zBufferedLogEntry.targetc                 C  rO   )zLog message.Nr   rP   r   r   r   r$   g   rR   zBufferedLogEntry.messagefloatc                 C  rO   )z,Time as from ``time.time`` since Unix epoch.Nr   rP   r   r   r   timel   rR   zBufferedLogEntry.timer   c                 C  rO   )z"Python log level, with trace as 9.Nr   rP   r   r   r   levelq   rR   zBufferedLogEntry.levelDict[str, Any]c                 C  rO   )a  Additional log entry fields.
        Requesting this property performs a conversion from the internal
        representation to the Python representation on every request. Therefore
        callers should store the result instead of repeatedly calling.

        Raises:
            Exception: If the internal representation cannot be converted. This
                should not happen and if it does it is considered a bug in the
                SDK and should be reported.
        Nr   rP   r   r   r   fieldsv   s   zBufferedLogEntry.fieldsN)r   r%   )r   rS   )r   r   )r   rV   )
r,   r-   r.   r/   propertyrQ   r$   rT   rU   rW   r   r   r   r   rN   _   s    rN   )r/   
__future__r   dataclassesr   typingr   r   r   r   r   r	   r
   typing_extensionsr   %temporalio.bridge.temporal_sdk_bridger   r   r3   r9   rA   rG   r   rN   r   r   r   r   <module>   s$    $
