
    ng\js                         S SK JrJr  S SKJrJrJr    " S S\5      r " S S\5      rS\\	   4S jr
S\\	   4S	 jr " S
 S5      rg)    )IntFlagauto)ListOptionalSequencec                   z    \ rS rSrSr\" 5       r\" 5       r\" 5       r\" 5       r	\" 5       r
\" 5       r\" 5       rSrg)MetricGroup   z+Metric groups that can be enabled/disabled. N)__name__
__module____qualname____firstlineno____doc__r   
RESILIENCYCONNECTION_BASICCONNECTION_ADVANCEDCOMMANDCSC	STREAMINGPUBSUB__static_attributes__r       U/home/edenadmin/noVNC/venv/lib/python3.13/site-packages/redis/observability/config.pyr	   r	      s8    5Jv&fG
&CIVFr   r	   c                   &    \ rS rSrSr\" 5       rSrg)TelemetryOption   zTelemetry options to export.r   N)r   r   r   r   r   r   METRICSr   r   r   r   r   r      s    &fGr   r   returnc                  
    / SQ$ )N)-C6?gMb0?Mb@?MbP?g{Gzd?{Gzt?{Gz?g?皙?皙?g      ?      ?   g      @r   r   r   r   "default_operation_duration_bucketsr*      s     r   c                  
    / SQ$ )N)r!   r"   r#   r$   r%   r&   r'   r(   r)      
   r   r   r   r   default_histogram_bucketsr.   1   s    IIr   c                   J   \ rS rSrSr\R                  r\R                  \R                  -  rSSSSSS\" 5       \" 5       \" 5       \" 5       4
S\\\      S\\\      S\\\      S\\\      S	\S
\S\\   S\\   S\\   S\\   4S jjrS\4S jrS\S\4S jrS\4S jrSrg)
OTelConfig5   a  
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                    Uc  U R                   U l        O.[        S5      U l        U H  nU =R                  U-  sl        M     Uc  U R                  U l        O.[        S5      U l        U H  nU =R                  U-  sl        M     U(       a  [        U5      OS U l        U(       a  [        U5      O	[        5       U l        XPl	        X`l
        Xpl        Xl        Xl        Xl        g )Nr   )DEFAULT_TELEMETRYr2   r   DEFAULT_METRIC_GROUPSr3   r	   setr4   r5   r6   r7   r8   r9   r:   r;   )selfr2   r3   r4   r5   r6   r7   r8   r9   r:   r;   optionmetric_groups                r   __init__OTelConfig.__init__i   s    . $%)%;%;D"%4Q%7D"+&&&0& ,  !%!;!;D!,QD -""l2" !. :J$4 5t9I$4 5su *C&!2 +E'2T/.L+,H)r   r   c                 ,    [        U R                  5      $ )z.Check if any observability feature is enabled.)boolr2   r@   s    r   
is_enabledOTelConfig.is_enabled   s    D**++r   command_namec                 t    UR                  5       nU R                  b  X R                  ;   $ X R                  ;  $ )z
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
)upperr4   r5   )r@   rJ   command_uppers      r   should_track_commandOTelConfig.should_track_command   s@     %**,   , $9$999 $9$999r   c                      SU R                    3$ )NzOTelConfig(enabled_telemetry=)r2   rG   s    r   __repr__OTelConfig.__repr__   s    .t/E/E.FGGr   )
r:   r;   r8   r9   r2   r5   r6   r7   r4   r3   )r   r   r   r   r   r   r   r=   r	   r   r   r>   r*   r.   r   r   strrF   r   floatrC   rH   rN   rQ   r   r   r   r   r0   r0   5   s>   .` (//'88;;Q;QQ
 >B590404*/"' /0 &':S:U8Q8S)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h,D ,: : :&H# Hr   r0   N)enumr   r   typingr   r   r   r	   r   rT   r*   r.   r0   r   r   r   <module>rW      s[     + +	' 	g HUO &J8E? J@H @Hr   