open-telemetry / opentelemetry-specification

Specifications for OpenTelemetry
https://opentelemetry.io
Apache License 2.0
3.64k stars 870 forks source link

[Prometheus Compatibility] Reconsider 1 to ratio unit conversion #4058

Open dashpole opened 1 month ago

dashpole commented 1 month ago

Context

Found as part of https://github.com/open-telemetry/opentelemetry-python/pull/3924.

The semantic conventions for instrument unit recommend using annotations, rather than the unity:

Instruments that measure an integer count of something SHOULD only use annotations with curly braces to give additional meaning without the leading default unit (1). For example, use {packet}, {error}, {fault}, etc.

The linked UCUM section says that annotations (e.g. {RBC}) and 1 are equivalent:

For example one can write “%{vol}”, “ kg{total}”, or “{RBC}” (for “red blood cells”) as pseudo-units. However, these annotations do not have any effect on the semantics, which is why these example expressions are equivalent to “ %”, “kg”, and “ 1” respectively.

The current Prometheus Compatibility specification converts 1 to ratio:

Special case: Converting "1" to "ratio".

Problem

While 1 can be a ratio, it can also be a count of something, since it is equivalent to {RBC}. Our spec discourages the use of 1 as a count of something, but that still doesn't make it correct to automatically convert 1 to ratio for Prometheus conversion.

Proposal

Remove the special case for changing 1 to ratio in prometheus conversion.

@bertysentry @open-telemetry/wg-prometheus @aabmass