opentelemetry-python icon indicating copy to clipboard operation
opentelemetry-python copied to clipboard

Creating named `View` with only `instrument_type` does not raise error

Open pichlermarc opened this issue 2 years ago • 0 comments

Describe your problem

This might not be a bug, but not consistent with the specification. :slightly_smiling_face:

Creating a named View with only instrument_type does not raise an Error, even though it implicitly selects multiple instruments on the same meter.

From the Specification:

In order to avoid conflicts, views which specify a name SHOULD have an instrument selector that selects at most one instrument. For the registration mechanism described above, where selection is provided via configuration, the SDK SHOULD NOT allow Views with a specified name to be declared with instrument selectors that may select more than one instrument (e.g. wild card instrument name) in the same Meter.

Here, only providing the instrument_type without providing an instrument_name has the same effect as providing a wildcard instrument_name, therefore it may be selecting multiple instruments.

Describe your environment

Python version: any Metrics SDK version: v0.32b0

Steps to reproduce

Run:

from opentelemetry.sdk.metrics import MeterProvider, Counter
from opentelemetry.sdk.metrics.view import View

MeterProvider(views=[View(name="name", instrument_type=Counter)])

What is the expected behavior?

An Error similar to when only a wildcard is provided.

What is the actual behavior?

No Error is raised.

Additional context

When running

MeterProvider(views=[View(name="name", instrument_name="*", instrument_type=Counter)])

an error is thrown, even though it is semantically the same as the example provided in the "Steps to reproduce"-section above.

pichlermarc avatar Jul 12 '22 15:07 pichlermarc