prometheus: Remove unit suffix for unit 1#4131
Conversation
|
|
|
@dashpole PTAL |
|
For reference, related code in Collector: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/8f394d4ffea8d5f06a9019245746ff253be106fd/pkg/translator/prometheus/normalize_name.go#L155-L162: // Append _ratio for metrics with unit "1"
// Some Otel receivers improperly use unit "1" for counters of objects
// See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aissue+some+metric+units+don%27t+follow+otel+semantic+conventions
// Until these issues have been fixed, we're appending `_ratio` for gauges ONLY
// Theoretically, counters could be ratios as well, but it's absurd (for mathematical reasons)
if metric.Unit() == "1" && metric.Type() == pmetric.MetricTypeGauge {
nameTokens = append(removeItem(nameTokens, "ratio"), "ratio")
} |
Co-authored-by: Robert Pająk <pellared@hotmail.com>
wow, there comes more names normalization. but I also do not think Append _ratio (for gauges only) is a good choice. as the docs https://prometheus.io/docs/practices/naming/#base-units (which the commit open-telemetry/opentelemetry-collector-contrib@b828db4#diff-9f77c9a72be0a6feb89132d5c34b7cd4b4edbcd4e6c1845714d30a840c507d8e ref it to)
a gauge can be any value, for example but as open-telemetry/opentelemetry-collector-contrib#10554 said clearly:
(do we have spec for this? Unit maybe we should document that. so users won't set unit |
|
The OpenTelemetry Specification seems to go against this change.
|
the problem is, lot of people using unit under current otel metric code: so, maybe we should make more clear (maybe in the
|
|
and there's a second issue, if the otel metric name is |
|
I think making things clearer in the spec would be the first step. |
|
not everyone can read the full spec. and sometimes it is even hard to find the right part from the spec. add a simple comment in the is this OK @dmathieu |
|
Sure. |
The I agree with @dmathieu that if this is truly undesired behavior it should be addressed at the specification level. However, I'm not sure it is.As is pointed out in the mentioned issue, counters and gauges that measure non-ratio values should be annotating the unit with descriptions of what they measure. |
|
Closing per #4131 (comment) |
this feature introduced by #3352
according to https://prometheus.io/docs/instrumenting/writing_exporters/#naming
there's no
_ratiorelated specand we use
requests_totalfor a long long time, notrequests_ratio_total(if use unit "1" for a counter now, we got this mixed metric name)like do in https://github.com/labstack/echo-contrib/blob/1b74ff73cb919adf80a67dadf44dc6434324782b/echoprometheus/prometheus.go#LL172C4-L172C4
or https://github.com/labstack/echo-contrib/blob/1b74ff73cb919adf80a67dadf44dc6434324782b/prometheus/prometheus.go#L73
requests_totalis simple and clear. it is an counter, it count user requests, not related to ratio.https://prometheus.io/docs/practices/naming/#metric-names