Skip to content

Standardization of Units needed #705

@MrAlias

Description

@MrAlias

Looking across language implementation the unit field for the metric instrument definition is implemented differently.

In some cases it is implemented as a definite type, restricting it to well defined values:

But, in most cases it is an unconstrained string:

I wasn't able to find a part of the specification that specifies a unit. Given the metric SDK is still a work in progress, I'm guessing that it would eventually at least be referenced there.

However, the proto does give some specification on what values a unit can have: https://github.com/open-telemetry/opentelemetry-proto/blob/b54688569186e0b862bf7462a983ccf2c50c0547/opentelemetry/proto/metrics/v1/metrics.proto#L117-L119

This uses the Unified Code For Units of Measure.

Questions

  1. Should implementation of units be standardized similar to semantic conventions and be supported as canonical strings? Or, should they be specified as distinct types? Could they be specified so that either implementation would suffice, meaning that languages that support a strong type system could used a dedicated type, and weaker typing systems could have a more flexible implementation?
  2. Should we stick with this UCUM standards body like in the proto to specify the unit structure we expect? What about IEEE, or SI? Should we specify our own and have a subset of these standards?
  3. Should the prefix be decoupled from the unit? If the unit is to be it's own type, should the prefix just be a dedicated field?
  4. How should the extensibility of the unit system be handled? Does it need to be specified?
  5. Should things like count, total, or sum be included in the unit specification?

Additional context.

This is all motivated by a need for interoperability between instrumentation and exporters. An exporter needs to know how instrumentation will define its units so it can identify, display, and possibly convert values correctly.

For example, if instrumentation sends time data and the exporter wants all time data in milliseconds. If the unit of time is unspecified and instrumentation sends data as microseconds, micro-sec, us, and μs the will have an insurmountable problem to solve doing this interpretation and conversion.

Additionally, if instrumentation records in one unit (say mmhg) but the exporter exports in another (i.e. kPa) the end user will not have their data interpreted appropriately.

Metadata

Metadata

Labels

area:semantic-conventionsRelated to semantic conventionspriority:p1Highest priority levelrelease:required-for-gaMust be resolved before GA release, or nice to have before GAspec:metricsRelated to the specification/metrics directory

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions