Skip to content

Commit 7880f71

Browse files
committed
fix(om2): histograms and negative observed values
OM1.0 required that the Sum of Histograms is not represented when there are negative observations in a histogram. This PR is removing this requirement. Due to: The requirement was never implemented by the Go and Java instrumentation libraries. Enforcing it now would be breaking. The requirement makes it impossible to implement the use case where the user wants to measure the Sum anyway. The PromQL engine does not take the Sum into account when doing counter reset detection, thus it does not matter that it can decrease. Note: this PR does not make Sum mandatory, that is a different question. Signed-off-by: György Krajcsovits <[email protected]>
1 parent cbe12c5 commit 7880f71

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

content/docs/specs/om/open_metrics_spec_2_0.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,16 @@ Histograms measure distributions of discrete events. Common examples are the lat
220220

221221
A Histogram MetricPoint MUST contain at least one bucket, and SHOULD contain Sum, and Created values. Every bucket MUST have a threshold and a value.
222222

223-
Histogram MetricPoints MUST have one bucket with an +Inf threshold. Buckets MUST be cumulative. As an example for a metric representing request latency in seconds its values for buckets with thresholds 1, 2, 3, and +Inf MUST follow value_1 <= value_2 <= value_3 <= value_+Inf. If ten requests took 1 second each, the values of the 1, 2, 3, and +Inf buckets MUST equal 10.
223+
Histogram MetricPoints MUST have one bucket with threshold equal to +Inf. Buckets MUST be cumulative.
224+
As an example: for a metric representing request latency in seconds that has the following bucket thresholds: 1, 2, 3, and +Inf,
225+
it MUST follow that value_1 <= value_2 <= value_3 <= value_+Inf. If ten requests took 1 second each, the values of the 1, 2, 3, and +Inf buckets MUST equal 10.
226+
Or in other words, the count of measured event values that are >1 and <=2 is equal to value_2 - value_1.
224227

225-
The +Inf bucket counts all requests. If present, the Sum value MUST equal the Sum of all the measured event values. Bucket thresholds within a MetricPoint MUST be unique.
228+
The +Inf bucket counts all requests. Bucket thresholds within a MetricPoint MUST be unique. Negative threshold buckets MAY be used. Bucket thresholds MUST NOT equal NaN.
226229

227-
Semantically, Sum, and buckets values are counters so MUST NOT be NaN or negative.
228-
Negative threshold buckets MAY be used, but then the Histogram MetricPoint MUST NOT contain a sum value as it would no longer be a counter semantically. Bucket thresholds MUST NOT equal NaN. Count and bucket values MUST be integers.
230+
Semantically, buckets values are counters so MUST NOT be NaN or negative. Bucket values MUST be integers.
231+
232+
If present, the Sum value MUST equal the Sum of all the measured event values. The histogram MAY count negative event values, which means that the Sum may decrease.
229233

230234
A Histogram MetricPoint SHOULD have a Timestamp value called Created. This can help ingestors discern between new metrics and long-running ones it did not see before.
231235

0 commit comments

Comments
 (0)