metrics: add experimental view_matching_mode (composable metric views) support

Offen
#5,894 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
30/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
observability

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
Vorherrschende Sprache
Python
Sterne
2.7k
Forks
1.1k
Ø Merge
3 T. 12 Std.
Gemergte PRs (30 T.)
16

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus open-telemetry/opentelemetry-python

Alle Issues in open-telemetry/opentelemetry-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.