
    /
is                         d dl mZmZ d dlmZmZmZ 	  G d de          Z G d de          Zdee	         fdZ
dee	         fd	Z G d
 d          ZdS )    )IntFlagauto)ListOptionalSequencec                       e Zd ZdZ e            Z e            Z e            Z e            Z e            Z	 e            Z
 e            ZdS )MetricGroupz+Metric groups that can be enabled/disabled.N)__name__
__module____qualname____doc__r   
RESILIENCYCONNECTION_BASICCONNECTION_ADVANCEDCOMMANDCSC	STREAMINGPUBSUB     C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\redis/observability/config.pyr	   r	      sc        55Jtvv$&&dffG
$&&CITVVFFFr   r	   c                   &    e Zd ZdZ e            ZdS )TelemetryOptionzTelemetry options to export.N)r
   r   r   r   r   METRICSr   r   r   r   r      s        &&dffGGGr   r   returnc                  
    g dS )N)-C6?gMb0?Mb@?MbP?g{Gzd?{Gzt?{Gz?g?皙?皙?g      ?      ?   g      @r   r   r   r   "default_operation_duration_bucketsr&      s       r   c                  
    g dS )N)r   r   r   r    r!   r"   r#   r$   r%      
   r   r   r   r   default_histogram_bucketsr*   1   s    IIIIr   c                   |   e Zd ZdZej        Zej        ej	        z  Z
dddddd e             e             e             e            f
deee                  deee                  deee                  deee                  ded	ed
ee         dee         dee         dee         fdZdefdZdedefdZdefdZdS )
OTelConfiga  
    Configuration for OpenTelemetry observability in redis-py.

    This class manages all OTel-related settings including metrics, traces (future),
    and logs (future). Configuration can be provided via constructor parameters or
    environment variables (OTEL_* spec).

    Constructor parameters take precedence over environment variables.

    Args:
        enabled_telemetry: Enabled telemetry options to export (default: metrics). Traces and logs will be added
                           in future phases.
        metric_groups: Group of metrics that should be exported.
        include_commands: Explicit allowlist of commands to track
        exclude_commands: Blocklist of commands to track
        hide_pubsub_channel_names: If True, hide PubSub channel names in metrics (default: False)
        hide_stream_names: If True, hide stream names in streaming metrics (default: False)

    Note:
        Redis-py uses the global MeterProvider set by your application.
        Set it up before initializing observability:

            from opentelemetry import metrics
            from opentelemetry.sdk.metrics import MeterProvider
            from opentelemetry.sdk.metrics._internal.view import View
            from opentelemetry.sdk.metrics._internal.aggregation import ExplicitBucketHistogramAggregation

            # Configure histogram bucket boundaries via Views
            views = [
                View(
                    instrument_name="db.client.operation.duration",
                    aggregation=ExplicitBucketHistogramAggregation(
                        boundaries=[0.0001, 0.00025, 0.0005, 0.001, 0.0025, 0.005,
                                    0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5]
                    ),
                ),
                # Add more views for other histograms...
            ]

            provider = MeterProvider(views=views, metric_readers=[reader])
            metrics.set_meter_provider(provider)

            # Then initialize redis-py observability
            from redis.observability import get_observability_instance, OTelConfig
            otel = get_observability_instance()
            otel.init(OTelConfig())
    NFenabled_telemetrymetric_groupsinclude_commandsexclude_commandshide_pubsub_channel_nameshide_stream_namesbuckets_operation_duration"buckets_stream_processing_durationbuckets_connection_create_timebuckets_connection_wait_timec                    || j         | _        n)t          d          | _        |D ]}| xj        |z  c_        || j        | _        n)t          d          | _        |D ]}| xj        |z  c_        |rt          |          nd | _        |rt          |          nt                      | _        || _	        || _
        || _        || _        |	| _        |
| _        d S )Nr   )DEFAULT_TELEMETRYr-   r   DEFAULT_METRIC_GROUPSr.   r	   setr/   r0   r1   r2   r3   r4   r5   r6   )selfr-   r.   r/   r0   r1   r2   r3   r4   r5   r6   optionmetric_groups                r   __init__zOTelConfig.__init__i   s   . $%)%;D""%4Q%7%7D"+ 1 1&&&0&&&  !%!;D!,QD - 3 3""l2""" :J S$4 5 5 5t9I T$4 5 5 5suu *C&!2 +E'2T/.L+,H)))r   r   c                 *    t          | j                  S )z.Check if any observability feature is enabled.)boolr-   r;   s    r   
is_enabledzOTelConfig.is_enabled   s    D*+++r   command_namec                 \    |                                 }| j        	|| j        v S || j        vS )a  
        Determine if a command should be tracked based on include/exclude lists.

        Args:
            command_name: The Redis command name (e.g., 'GET', 'SET')

        Returns:
            True if the command should be tracked, False otherwise
        )upperr/   r0   )r;   rC   command_uppers      r   should_track_commandzOTelConfig.should_track_command   s>     %**,,  , D$999 D$999r   c                     d| j          S )NzOTelConfig(enabled_telemetry=)r-   rA   s    r   __repr__zOTelConfig.__repr__   s    Gt/EGGGr   )r
   r   r   r   r   r   r8   r	   r   r   r9   r&   r*   r   r   strr@   r   floatr>   rB   rG   rI   r   r   r   r,   r,   5   s       . .` (/'8;;QQ
 >B590404*/"' /.00 &%'':S:S:U:U8Q8Q8S8S)2I 2I $D$9:2I
  [ 122I #49-2I #49-2I $(2I  2I %-%
2I  -5-
!2I& )1'2I( '/uo)2I 2I 2I 2Ih,D , , , ,: : : : : :&H# H H H H H Hr   r,   N)enumr   r   typingr   r   r   r	   r   rK   r&   r*   r,   r   r   r   <module>rN      s           + + + + + + + + + +	 	 	 	 	' 	 	 	    g   HUO    &J8E? J J J J@H @H @H @H @H @H @H @H @H @Hr   