metrics: add experimental view_matching_mode (composable metric views) support

Aberta
#5,894 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
30/100
Tipo de issue
Funcionalidade
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
observability

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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
Linguagem predominante
Python
Estrelas
2.7k
Forks
1.1k
Merge médio
3d 12h
PRs com merge (30d)
16

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de open-telemetry/opentelemetry-python

Todas as issues de open-telemetry/opentelemetry-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.