Skip to content

Commit f816f09

Browse files
committed
feat(om2.0): allow float histograms
Fixes: prometheus/OpenMetrics#309 Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
1 parent cbea98f commit f816f09

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

docs/specs/om/open_metrics_spec_2_0.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,17 @@ Histograms measure distributions of discrete events. Common examples are the lat
250250

251251
A Histogram MetricPoint MUST contain Count and Sum values.
252252

253-
The Count value MUST be equal to the number of measurements taken by the Histogram. The Count is a counter semantically. The Count MUST be an integer and MUST NOT be NaN or negative.
253+
The Count value MUST be equal to the number of measurements taken by the Histogram. The Count is a counter semantically. The Count SHOULD be an integer. The Count MUST NOT be +Inf, NaN, or negative.
254+
255+
Float Count is allowed to make it possible to expose results of arithmetic operations on histograms, such as addition that may result in values beyond the range of integers.
254256

255257
The Sum value MUST be equal to the sum of all the measured event values. The Sum is only a counter semantically as long as there are no negative event values measured by the Histogram MetricPoint.
256258

257259
A Histogram MUST measure values that are not NaN in either [Classic Buckets](#classic-buckets) or [Native Buckets](#native-buckets) or both. Measuring NaN is different for Classic and Native Buckets, see in their respective sections.
258260

259-
Every Bucket MUST have well-defined boundaries and a value. The bucket value is called the bucket count colloquially. Boundaries of a Bucket MUST NOT be NaN. Bucket values MUST be integers. Semantically, bucket values are counters so MUST NOT be NaN or negative.
261+
Every Bucket MUST have well-defined boundaries and a value. The bucket value is called the bucket count colloquially. Boundaries of a Bucket MUST NOT be NaN. Bucket values SHOULD be integers. Semantically, bucket values are counters so MUST NOT be +Inf, NaN, or negative.
262+
263+
Float bucket values are allowed to make it possible to expose results of arithmetic operations on histograms, such as addition that may result in values beyond the range of integers.
260264

261265
A Histogram SHOULD NOT include NaN measurements as including NaN in the Sum will make the Sum equal to NaN and mask the sum of the real measurements for the lifetime of the time series. If a Histogram includes NaN measurements, then NaN measurements MUST be counted in the Count and the Sum MUST be NaN.
262266

@@ -337,15 +341,19 @@ GaugeHistograms measure current distributions. Common examples are how long item
337341

338342
A GaugeHistogram MetricPoint MUST contain Gcount, Gsum values.
339343

340-
The GCount value MUST be equal to the number of measurements currently in the GaugeHistogram. The GCount is a gauge semantically. The GCount MUST be and integer and MUST NOT be NaN or negative.
344+
The GCount value MUST be equal to the number of measurements currently in the GaugeHistogram. The GCount is a gauge semantically. The GCount SHOULD be and integer. The GCount MUST NOT be -Inf, +Inf, or NAN. The GCount SHOULD NOT be negative.
345+
346+
Float and negative GCount is allowed to make it possible to expose results of arithmetic operations on GaugeHistograms, such as the rate of change of a Histogram over time.
341347

342348
The Gsum value MUST be equal to the sum of all the measured values currently in the GaugeHistogram. The Gsum is a gauge semantically.
343349

344-
A GaugeHistogram MUST measure values that are not NaN in either [Classic Buckets](#classic-buckets) or [native buckets](#native-buckets) or both. Measuring NaN is different for Classic and Native Buckets, see in their respective sections.
350+
A GaugeHistogram MUST measure values that are not NaN in either [Classic Buckets](#classic-buckets) or [Native Buckets](#native-buckets) or both. Measuring NaN is different for Classic and Native Buckets, see in their respective sections.
345351

346-
If a GaugeHistogram stops measuring values in either Classic or Native buckets and keeps measuring values in the other, it MUST clear and not expose the buckets it stopped measuring into. This avoids exposing different distribution from the two kind of buckets at the same time.
352+
If a GaugeHistogram stops measuring values in either Classic or Native Buckets and keeps measuring values in the other, it MUST clear and not expose the buckets it stopped measuring into. This avoids exposing different distribution from the two kind of buckets at the same time.
347353

348-
Every bucket MUST have well-defined boundaries and a value. Boundaries of a bucket MUST NOT be NaN. Bucket values MUST be integers. Semantically, bucket values are gauges and MUST NOT be NaN or negative.
354+
Every Bucket MUST have well-defined boundaries and a value. Boundaries of a Bucket MUST NOT be NaN. Bucket values SHOULD be integers. Semantically, bucket values are gauges and SHOULD NOT be -Inf, +Inf, NaN, or negative.
355+
356+
Float and negative bucket values are allowed to make it possible to expose results of arithmetic operations on GaugeHistograms, such as the rate of change of a Histogram over time.
349357

350358
A GaugeHistogram SHOULD NOT include NaN measurements as including NaN in the Gsum will make the Gsum equal to NaN and mask the sum of the real measurements for the lifetime of the time series. If a GaugeHistogram includes NaN measurements, then NaN measurements MUST be counted in the Gcount and the Gsum MUST be NaN.
351359

@@ -503,15 +511,15 @@ complex-value = nativehistogram
503511
nativehistogram = nh-count "," nh-sum "," nh-schema "," nh-zero-threshold "," nh-zero-count [ "," nh-negative-spans "," nh-negative-buckets ] [ "," nh-positive-spans "," nh-positive-buckets ]
504512
505513
; count:x
506-
nh-count = %d99.111.117.110.116 ":" non-negative-integer
514+
nh-count = %d99.111.117.110.116 ":" realnumber
507515
; sum:f allows real numbers and +-Inf and NaN
508516
nh-sum = %d115.117.109 ":" number
509517
; schema:i
510518
nh-schema = %d115.99.104.101.109.97 ":" integer
511519
; zero_threshold:f
512520
nh-zero-threshold = %d122.101.114.111 "_" %d116.104.114.101.115.104.111.108.100 ":" realnumber
513521
; zero_count:x
514-
nh-zero-count = %d122.101.114.111 "_" %d99.111.117.110.116 ":" non-negative-integer
522+
nh-zero-count = %d122.101.114.111 "_" %d99.111.117.110.116 ":" realnumber
515523
; negative_spans:[1:2,3:4] and negative_spans:[]
516524
nh-negative-spans = %d110.101.103.97.116.105.118.101 "_" %d115.112.97.110.115 ":" "[" [nh-spans] "]"
517525
nh-positive-spans = %d112.111.115.105.116.105.118.101 "_" %d115.112.97.110.115 ":" "[" [nh-spans] "]"
@@ -525,7 +533,7 @@ nh-span = non-negative-integer ":" positive-integer
525533
nh-negative-buckets = %d110.101.103.97.116.105.118.101 "_" %d98.117.99.107.101.116.115 ":" "[" [nh-buckets] "]"
526534
nh-positive-buckets = %d112.111.115.105.116.105.118.101 "_" %d98.117.99.107.101.116.115 ":" "[" [nh-buckets] "]"
527535
528-
nh-buckets = non-negative-integer *("," non-negative-integer)
536+
nh-buckets = realnumber *("," realnumber)
529537
530538
integer = [SIGN] 1*"0" / [SIGN] positive-integer
531539
non-negative-integer = ["+"] 1*"0" / ["+"] positive-integer
@@ -572,6 +580,8 @@ acme_http_request_seconds_sum{path="/api/v1",method="GET"} 1.2e2 st@1605301325.0
572580
acme_http_request_seconds_buckets{path="/api/v1",method="GET",le="0.5"} 1 st@1605301325.0
573581
acme_http_request_seconds_buckets{path="/api/v1",method="GET",le="1"} 2 st@1605301325.0
574582
acme_http_request_seconds_buckets{path="/api/v1",method="GET",le="+Inf"} 2 st@1605301325.0
583+
# TYPE acme_http_request_seconds:5mrate gaguehistogram
584+
acme_http_request_seconds:5mrate{path="/api/v1",method="GET"} {count:0.01,sum:2.0,schema:0,zero_threshold:1e-4,zero_count:0.0,positive_spans:[1:2],positive_buckets:[0.005,0.005]} st@1605301325.0
575585
# TYPE "foodb.read.errors" counter
576586
# HELP "foodb.read.errors" The number of errors in the read path for fooDb.
577587
{"foodb.read.errors","service.name"="my_service"} 3482
@@ -999,8 +1009,6 @@ If there are no positive Native Buckets, then the fields `positive_spans` and `p
9991009

10001010
If there are negative (and/or positive) Native Buckets, then the fields `negative_spans`, `negative_buckets` (and/or `positive_spans`, `positive_buckets`) MUST be present in this order after the `zero_count` field.
10011011

1002-
With the exception of the `sum` and `zero_threshold` field, all numbers MUST be integers and MUST NOT include dot '.' or exponent 'e'.
1003-
10041012
Native Bucket values MUST be ordered by their index, and their values MUST be placed in the `negative_buckets` (and/or `positive_buckets`) fields.
10051013

10061014
Native Buckets that have a value of 0 SHOULD NOT be present.

0 commit comments

Comments
 (0)