HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib64/python3.7/site-packages/grpc/__pycache__/_observability.cpython-37.pyc
B

��fF(�@s(UddlmZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZddl
mZe�e�ZeZed�Zed�Ze��Zded<dad	ed
<ddgZd
ed<Gdd�de	eefejd�Zejdd�dd��Zddd�dd�Zddd�dd�Z dd�dd�Z!ddd �d!d"�Z"d#dd$�d%d&�Z#dS)'�)�annotationsN)�Any�	Generator�Generic�List�Optional�TypeVar)�cygrpc�ClientCallTracerCapsule�ServerCallTracerFactoryCapsulezthreading.RLock�_plugin_lockzOptional['ObservabilityPlugin']�_OBSERVABILITY_PLUGINs"google.monitoring.v3.MetricServices*google.devtools.cloudtrace.v2.TraceServicezList[bytes]�_SERVICES_TO_EXCLUDEc@s�eZdZUdZdZded<dZded<ejdddd�d	d
��Z	ejddd�d
d��Z
ejddddd�dd��Zejdd�dd��Zejdddddd�dd��Z
ddd�dd�Zddd�dd �Zedd�d!d"��Zedd�d#d$��Zedd�d%d&��Zd'S)(�ObservabilityPluginanAbstract base class for observability plugin.

    *This is a semi-private class that was intended for the exclusive use of
     the gRPC team.*

    The ClientCallTracerCapsule and ClientCallTracerCapsule created by this
    plugin should be inject to gRPC core using observability_init at the
    start of a program, before any channels/servers are built.

    Any future methods added to this interface cannot have the
    @abc.abstractmethod annotation.

    Attributes:
      _stats_enabled: A bool indicates whether tracing is enabled.
      _tracing_enabled: A bool indicates whether stats(metrics) is enabled.
    F�bool�_tracing_enabled�_stats_enabled�bytesr
)�method_name�target�returncCs
t��dS)a�Creates a ClientCallTracerCapsule.

        After register the plugin, if tracing or stats is enabled, this method
        will be called after a call was created, the ClientCallTracer created
        by this method will be saved to call context.

        The ClientCallTracer is an object which implements `grpc_core::ClientCallTracer`
        interface and wrapped in a PyCapsule using `client_call_tracer` as name.

        Args:
          method_name: The method name of the call in byte format.
          target: The channel target of the call in byte format.

        Returns:
          A PyCapsule which stores a ClientCallTracer object.
        N)�NotImplementedError)�selfrr�r�F/opt/alt/python37/lib64/python3.7/site-packages/grpc/_observability.py�create_client_call_tracer?sz-ObservabilityPlugin.create_client_call_tracer�None)�client_call_tracerrcCs
t��dS)a�Deletes the ClientCallTracer stored in ClientCallTracerCapsule.

        After register the plugin, if tracing or stats is enabled, this method
        will be called at the end of the call to destroy the ClientCallTracer.

        The ClientCallTracer is an object which implements `grpc_core::ClientCallTracer`
        interface and wrapped in a PyCapsule using `client_call_tracer` as name.

        Args:
          client_call_tracer: A PyCapsule which stores a ClientCallTracer object.
        N)r)rrrrr�delete_client_call_tracerUsz-ObservabilityPlugin.delete_client_call_tracer�str)�trace_id�span_id�
is_sampledrcCs
t��dS)a�Saves the trace_id and span_id related to the current span.

        After register the plugin, if tracing is enabled, this method will be
        called after the server finished sending response.

        This method can be used to propagate census context.

        Args:
          trace_id: The identifier for the trace associated with the span as a
            32-character hexadecimal encoded string,
            e.g. 26ed0036f2eff2b7317bccce3e28d01f
          span_id: The identifier for the span as a 16-character hexadecimal encoded
            string. e.g. 113ec879e62583bc
          is_sampled: A bool indicates whether the span is sampled.
        N)r)rr r!r"rrr�save_trace_contextfsz&ObservabilityPlugin.save_trace_contextr)rcCs
t��dS)a4Creates a ServerCallTracerFactoryCapsule.

        After register the plugin, if tracing or stats is enabled, this method
        will be called by calling observability_init, the ServerCallTracerFactory
        created by this method will be registered to gRPC core.

        The ServerCallTracerFactory is an object which implements
        `grpc_core::ServerCallTracerFactory` interface and wrapped in a PyCapsule
        using `server_call_tracer_factory` as name.

        Returns:
          A PyCapsule which stores a ServerCallTracerFactory object.
        N)r)rrrr�!create_server_call_tracer_factory{sz5ObservabilityPlugin.create_server_call_tracer_factory�floatr)�methodr�rpc_latency�status_codercCs
t��dS)aaRecord the latency of the RPC.

        After register the plugin, if stats is enabled, this method will be
        called at the end of each RPC.

        Args:
          method: The fully-qualified name of the RPC method being invoked.
          target: The target name of the RPC method being invoked.
          rpc_latency: The latency for the RPC in seconds, equals to the time between
            when the client invokes the RPC and when the client receives the status.
          status_code: An element of grpc.StatusCode in string format representing the
            final status for the RPC.
        N)r)rr&rr'r(rrr�record_rpc_latency�sz&ObservabilityPlugin.record_rpc_latency)�enablercCs
||_dS)zxEnable or disable tracing.

        Args:
          enable: A bool indicates whether tracing should be enabled.
        N)r)rr*rrr�set_tracing�szObservabilityPlugin.set_tracingcCs
||_dS)z}Enable or disable stats(metrics).

        Args:
          enable: A bool indicates whether stats should be enabled.
        N)r)rr*rrr�	set_stats�szObservabilityPlugin.set_statscCs|jS)N)r)rrrr�tracing_enabled�sz#ObservabilityPlugin.tracing_enabledcCs|jS)N)r)rrrr�
stats_enabled�sz!ObservabilityPlugin.stats_enabledcCs|jp
|jS)N)r-r.)rrrr�observability_enabled�sz)ObservabilityPlugin.observability_enabledN)�__name__�
__module__�__qualname__�__doc__r�__annotations__r�abc�abstractmethodrrr#r$r)r+r,�propertyr-r.r/rrrrr's
r)�	metaclassz4Generator[Optional[ObservabilityPlugin], None, None])rc	cst�tVWdQRXdS)z�Get the ObservabilityPlugin in _observability module.

    Returns:
      The ObservabilityPlugin currently registered with the _observability
    module. Or None if no plugin exists at the time of calling this method.
    N)rr
rrrr�
get_plugin�sr9zOptional[ObservabilityPlugin]r)�observability_pluginrc	Cs(t�|rtrtd��|aWdQRXdS)z�Save ObservabilityPlugin to _observability module.

    Args:
      observability_plugin: The ObservabilityPlugin to save.

    Raises:
      ValueError: If an ObservabilityPlugin was already registered at the
        time of calling this method.
    z%observability_plugin was already set!N)rr
�
ValueError)r:rrr�
set_plugin�sr<cCs:t|�yt�|�Wntk
r4t�d�YnXdS)alInitialize observability with provided ObservabilityPlugin.

    This method have to be called at the start of a program, before any
    channels/servers are built.

    Args:
      observability_plugin: The ObservabilityPlugin to use.

    Raises:
      ValueError: If an ObservabilityPlugin was already registered at the
        time of calling this method.
    z)Failed to set server call tracer factory!N)r<�_cygrpcZset_server_call_tracer_factory�	Exception�_LOGGER�	exception)r:rrr�observability_init�s

rAcCstd�t��dS)z�Clear the observability context, including ObservabilityPlugin and
    ServerCallTracerFactory

    This method have to be called after exit observability context so that
    it's possible to re-initialize again.
    N)r<r=Z clear_server_call_tracer_factoryrrrr�observability_deinit�srBr)�client_call_tracer_capsulerc	Cs.t��}|r|jsdS|�|�WdQRXdS)a�Deletes the ClientCallTracer stored in ClientCallTracerCapsule.

    This method will be called at the end of the call to destroy the ClientCallTracer.

    The ClientCallTracer is an object which implements `grpc_core::ClientCallTracer`
    interface and wrapped in a PyCapsule using `client_call_tracer` as the name.

    Args:
      client_call_tracer_capsule: A PyCapsule which stores a ClientCallTracer object.
    N)r9r/r)rC�pluginrrr�delete_call_tracer�s
rEz'_channel._RPCState')�staterc	Cspx tD]}||j�d�krdSqWt��>}|r4|js8dS|j|j}|d}|�|j|j||j	�WdQRXdS)z�Record the latency of the RPC, if the plugin is registered and stats is enabled.

    This method will be called at the end of each RPC.

    Args:
      state: a grpc._channel._RPCState object which contains the stats related to the
        RPC.
    �utf8Ni�)
rr&�encoder9r.Zrpc_end_timeZrpc_start_timer)r�code)rFZexclude_prefixrDZ
rpc_latency_sZrpc_latency_msrrr�maybe_record_rpc_latencys


rJ)$�
__future__rr5�
contextlib�logging�	threading�typingrrrrrrZgrpc._cythonr	r=�	getLoggerr0r?Z_channelr
r�RLockrr4r
r�ABCMetar�contextmanagerr9r<rArBrErJrrrr�<module>s2