metrics: add experimental view_matching_mode (composable metric views) support

Abierto
#5,894 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start with opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/metric_reader_storage.py and metrics/_internal/__init__.py, then read the matching logic in _handle_view_instrument_match and the MeterProvider configuration path. Review the linked specification sections and the related View implementation before deciding how to cover matching, precedence, attribute filters, and advisory parameters. Done means opt-in composable matching is implemented with the specified fallback and error behavior, while independent mode remains the default.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

The OpenTelemetry Metrics SDK specification defines an experimental (Development) view_matching_mode configuration parameter (independent vs. composable) on MeterProvider to compose multiple matching Views (for example, combining a wildcard View that filters attribute_keys with an instrument-specific View that customizes aggregation) into merged metric streams rather than emitting duplicate/conflicting streams (specification/metrics/sdk.md#L519-L543, introduced in https://github.com/open-telemetry/opentelemetry-specification/pull/5173).

Currently in opentelemetry-sdk, MetricReaderStorage._handle_view_instrument_match(...) always evaluates matching Views independently, creating a separate _ViewInstrumentMatch stream for each matching View:

Proposal

Implement experimental support for view_matching_mode ("independent" default, "composable" opt-in) in opentelemetry-sdk:

  • Accept an experimental keyword-only _view_matching_mode parameter on MeterProvider.__init__(...) (following _meter_configurator in metrics/_internal/__init__.py#L440-L441) and thread it into SdkConfiguration / MetricReaderStorage, handling unsupported values per sdk.md#L179-L182 (either raising ValueError during initialization or warning and falling back to "independent").
  • When composable mode is configured:
    • Form a stream group for each distinct configured View name containing matching Views with that name plus all matching Views with name=None (or a single default-named group if no matching View sets name).
    • Apply atomic last-wins precedence in registration order across explicitly specified non-attribute_keys View settings (name, description, aggregation, exemplar_reservoir_factory, aggregation_cardinality_limit, and enabled from https://github.com/open-telemetry/opentelemetry-python/pull/5847 — distinguishing omitted None arguments for aggregation and exemplar_reservoir_factory in view.py#L165-L166 from explicit defaults such as DefaultAggregation()), falling back per-aspect to the preceding valid View in the group (or default) with a warning on semantic errors rather than discarding the entire View.
    • Combine specified attribute_keys filters via logical AND (set intersection across non-None allow-lists on main; exclude-lists tracked in https://github.com/open-telemetry/opentelemetry-python/issues/5446), and override instrument advisory parameters only for aspects configured by matching Views in the group (falling back to instrument advisory parameters otherwise).
Additional Context
Lenguaje dominante
Python
Estrellas
2.7k
Forks
1.1k
Merge medio
3 d 12 h
PR fusionados (30 d)
16

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de open-telemetry/opentelemetry-python

Todos los issues de open-telemetry/opentelemetry-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.