Skip to content

Commit

Permalink
workload: fix quantile values in openmetrics exporter
Browse files Browse the repository at this point in the history
`hdrHistogram` library has quantiles in percentages rather than absolute
values. Openmetrics standard forces the quantiles values in `summary`
metric to be absolute values b/w 0 and 1 inclusive.

Earlier the exporter would export the percentage value, this change
intends to make it absolute to adhere to openmetrics standard

Epic: none

Release note: None
  • Loading branch information
sambhav-jain-16 committed Nov 15, 2024
1 parent 7d943e9 commit d103706
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/workload/histogram/exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func TestOpenMetricsFileWithJson(t *testing.T) {
return errors.Errorf("invalid summary count: %f", countValue)
}
}

quantile *= 100
if int64(countValue) != hist.ValueAtQuantile(quantile) {
return errors.Errorf("invalid summary quantile: %f", quantile)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/workload/histogram/exporter/testdata/kv
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ echo
{"Name":"write","Hist":{"LowestTrackableValue":100000,"HighestTrackableValue":100000000000,"SignificantFigures":1,"Counts":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,9,20,41,42,54,83,92,103,141,400,586,828,913,982,1127,1223,1236,1123,1009,976,850,713,706,590,483,793,438,277,154,84,52,52,29,19,22,14,9,5,3,1,5,4,4,10,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"Elapsed":5031363856,"Now":"2024-06-24T13:38:53.446733522Z"}
----
# TYPE write summary
write{quantile="50.0"} 3.276799e+06 1.719236333446e+09
write{quantile="95.0"} 4.718591e+06 1.719236333446e+09
write{quantile="99.0"} 6.291455e+06 1.719236333446e+09
write{quantile="100.0"} 4.294967295e+09 1.719236333446e+09
write{quantile="0.5"} 3.276799e+06 1.719236333446e+09
write{quantile="0.95"} 4.718591e+06 1.719236333446e+09
write{quantile="0.99"} 6.291455e+06 1.719236333446e+09
write{quantile="1.0"} 4.294967295e+09 1.719236333446e+09
write_sum 0.0 1.719236333446e+09
write_count 16379 1.719236333446e+09
# TYPE write_elapsed gauge
Expand Down
8 changes: 4 additions & 4 deletions pkg/workload/histogram/exporter/testdata/tpcc_delivery
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ echo
{"Name":"delivery","Hist":{"LowestTrackableValue":100000,"HighestTrackableValue":100000000000,"SignificantFigures":1,"Counts":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,1,2,4,2,4,5,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"Elapsed":992259494,"Now":"2024-06-24T15:47:43.790887915Z"}
----
# TYPE delivery summary
delivery{quantile="50.0"} 3.7748735e+07 1.71924406379e+09
delivery{quantile="95.0"} 4.4040191e+07 1.71924406379e+09
delivery{quantile="99.0"} 4.6137343e+07 1.71924406379e+09
delivery{quantile="100.0"} 4.6137343e+07 1.71924406379e+09
delivery{quantile="0.5"} 3.7748735e+07 1.71924406379e+09
delivery{quantile="0.95"} 4.4040191e+07 1.71924406379e+09
delivery{quantile="0.99"} 4.6137343e+07 1.71924406379e+09
delivery{quantile="1.0"} 4.6137343e+07 1.71924406379e+09
delivery_sum 0.0 1.71924406379e+09
delivery_count 24 1.71924406379e+09
# TYPE delivery_elapsed gauge
Expand Down
8 changes: 4 additions & 4 deletions pkg/workload/histogram/exporter/testdata/ycsb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ echo

----
# TYPE read summary
read{quantile="50.0"} 1.048575e+06 1.719230907083e+09
read{quantile="95.0"} 1.835007e+06 1.719230907083e+09
read{quantile="99.0"} 3.276799e+06 1.719230907083e+09
read{quantile="100.0"} 1.3631487e+07 1.719230907083e+09
read{quantile="0.5"} 1.048575e+06 1.719230907083e+09
read{quantile="0.95"} 1.835007e+06 1.719230907083e+09
read{quantile="0.99"} 3.276799e+06 1.719230907083e+09
read{quantile="1.0"} 1.3631487e+07 1.719230907083e+09
read_sum 0.0 1.719230907083e+09
read_count 34540 1.719230907083e+09
# TYPE read_elapsed gauge
Expand Down
7 changes: 6 additions & 1 deletion pkg/workload/histogram/exporter/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ func ConvertHdrHistogramToPrometheusMetricFamily(
if value == 0 {
continue
}

// Openmetrics standard mandates that quantile should be b/w 0 to 1.
// https://github.com/prometheus/OpenMetrics/blob/main/specification/OpenMetrics.md#summary
// Since hdrHistogram has quantiles in percentage, we need to convert it
openMetricsQuantile := quantile / 100
valueQuantile := prom.Quantile{
Quantile: &quantile,
Quantile: &openMetricsQuantile,
Value: &value,
}

Expand Down

0 comments on commit d103706

Please sign in to comment.