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

Append unit to prometheus metric names

Open jack-berg opened this issue 2 years ago • 1 comments

The spec requires that unit be appended to the metric name as a suffix. We don't do that anywhere today. I believe that would represent a breaking behavior change for prometheus users as their metric names would change when unit is present.

Still, would be good to do that soon to minimize the impact.

Originally posted by @jack-berg in https://github.com/open-telemetry/opentelemetry-java/pull/4386#discussion_r852442963

jack-berg avatar Apr 18 '22 21:04 jack-berg

Related spec issue.

jack-berg avatar Apr 19 '22 15:04 jack-berg

I would like to take this up, if that's ok. @jack-berg could you assign this to me ?

psx95 avatar Dec 07 '22 23:12 psx95

Just to confirm, since the link in the original description is broken, Prometheus and OpenMetrics Compatibility is the portion of the spec that needs to be followed to address this issue, correct ?

psx95 avatar Dec 16 '22 18:12 psx95

That is correct. See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#metric-metadata-1 for unit guidance.

dashpole avatar Dec 16 '22 18:12 dashpole

Based on the semantic conventions in the spec document, I just wanted to confirm as to what should be the approach if user has a unit named {packets}, we cannot append this to the metric name, since it would violate the regex defined in the spec.

So in this case, we do drop the unit altogether, meaning no-op, is this correct ?

psx95 avatar Dec 22 '22 20:12 psx95

That is considered unitless in prometheus, so we should drop units (at the portion within the brackets) with {}. I'll update the spec to more fully describe the mapping.

dashpole avatar Jan 03 '23 16:01 dashpole