opentelemetry-cpp
opentelemetry-cpp copied to clipboard
[METRICS SDK] Duplicate metrics are not detected
Per:
https://opentelemetry.io/docs/reference/specification/metrics/data-model/#opentelemetry-protocol-data-model-producer-recommendations
Producers SHOULD prevent the presence of multiple Metric identities for a given name with the same Resource and Scope attributes. Producers are expected to aggregate data for identical Metric objects as a basic feature, so the appearance of multiple Metric, considered a “semantic error”, generally requires duplicate conflicting instrument registration to have occurred somewhere.
Producers MAY be able to remediate the problem, depending on whether they are an SDK or a downstream processor:
If the potential conflict involves a non-identifying property (i.e., description), the producer SHOULD choose the longer string. If the potential conflict involves similar but disagreeing units (e.g., “ms” and “s”), an implementation MAY convert units to avoid semantic errors; otherwise an implementation SHOULD inform the user of a semantic error and pass through conflicting data. If the potential conflict involves an AggregationTemporality property, an implementation MAY convert temporality using a Cumulative-to-Delta or a Delta-to-Cumulative transformation; otherwise, an implementation SHOULD inform the user of a semantic error and pass through conflicting data. Generally, for potential conflicts involving an identifying property (i.e., all properties except description), the producer SHOULD inform the user of a semantic error and pass through conflicting data.
When semantic errors such as these occur inside an implementation of the OpenTelemetry API, there is an presumption of a fixed Resource value. Consequently, SDKs implementing the OpenTelemetry API have complete information about the origin of duplicate instrument registration conflicts and are sometimes able to help users avoid semantic errors. See the SDK specification for specific details.
See in particular point 4:
Generally, for potential conflicts involving an identifying property (i.e., all properties except description), the producer SHOULD inform the user of a semantic error and pass through conflicting data.
Using opentelemetry-cpp 1.9.0
Trying to define two observable counters, named "my_metric_a", on the same meter, leads to no error.
Expected result is that, for the same meter:
- sync metric "X" + sync metric "X" is reported as a semantic error
- sync metric "X" + async metric "X" is reported as a semantic error
- async metric "X" + async metric "X" is reported as a semantic error
In other words, the identifying property scope + metric name should point to a unique metric.
This issue was marked as stale due to lack of activity.