1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-12 02:28:07 +02:00

promtheus exporter will sum hist buckets (#3281) (#3282)

Signed-off-by: albertlockett <albert.lockett@gmail.com>
This commit is contained in:
Albert 2022-10-14 10:13:35 -04:00 committed by GitHub
parent 84e28fd3bd
commit 1e72af45a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 19 deletions

View File

@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed ### Fixed
- Slice attributes of `attribute` package are now comparable based on their value, not instance. (#3108 #3252) - Slice attributes of `attribute` package are now comparable based on their value, not instance. (#3108 #3252)
- Prometheus exporter will now cumulatively sum histogram buckets. (#3281)
## [1.11.0/0.32.3] 2022-10-12 ## [1.11.0/0.32.3] 2022-10-12

View File

@ -145,8 +145,11 @@ func getHistogramMetricData(histogram metricdata.Histogram, m metricdata.Metrics
keys, values := getAttrs(dp.Attributes) keys, values := getAttrs(dp.Attributes)
desc := prometheus.NewDesc(sanitizeName(m.Name), m.Description, keys, nil) desc := prometheus.NewDesc(sanitizeName(m.Name), m.Description, keys, nil)
buckets := make(map[float64]uint64, len(dp.Bounds)) buckets := make(map[float64]uint64, len(dp.Bounds))
cumulativeCount := uint64(0)
for i, bound := range dp.Bounds { for i, bound := range dp.Bounds {
buckets[bound] = dp.BucketCounts[i] cumulativeCount += dp.BucketCounts[i]
buckets[bound] = cumulativeCount
} }
md := &metricData{ md := &metricData{
name: m.Name, name: m.Name,

View File

@ -3,13 +3,13 @@
histogram_baz_bucket{A="B",C="D",le="0"} 0 histogram_baz_bucket{A="B",C="D",le="0"} 0
histogram_baz_bucket{A="B",C="D",le="5"} 0 histogram_baz_bucket{A="B",C="D",le="5"} 0
histogram_baz_bucket{A="B",C="D",le="10"} 1 histogram_baz_bucket{A="B",C="D",le="10"} 1
histogram_baz_bucket{A="B",C="D",le="25"} 1 histogram_baz_bucket{A="B",C="D",le="25"} 2
histogram_baz_bucket{A="B",C="D",le="50"} 0 histogram_baz_bucket{A="B",C="D",le="50"} 2
histogram_baz_bucket{A="B",C="D",le="75"} 0 histogram_baz_bucket{A="B",C="D",le="75"} 2
histogram_baz_bucket{A="B",C="D",le="100"} 0 histogram_baz_bucket{A="B",C="D",le="100"} 2
histogram_baz_bucket{A="B",C="D",le="250"} 2 histogram_baz_bucket{A="B",C="D",le="250"} 4
histogram_baz_bucket{A="B",C="D",le="500"} 0 histogram_baz_bucket{A="B",C="D",le="500"} 4
histogram_baz_bucket{A="B",C="D",le="1000"} 0 histogram_baz_bucket{A="B",C="D",le="1000"} 4
histogram_baz_bucket{A="B",C="D",le="+Inf"} 4 histogram_baz_bucket{A="B",C="D",le="+Inf"} 4
histogram_baz_sum{A="B",C="D"} 236 histogram_baz_sum{A="B",C="D"} 236
histogram_baz_count{A="B",C="D"} 4 histogram_baz_count{A="B",C="D"} 4

View File

@ -13,17 +13,17 @@ invalid_hist_name_bucket{A="B",C="D",le="0"} 0
invalid_hist_name_bucket{A="B",C="D",le="5"} 0 invalid_hist_name_bucket{A="B",C="D",le="5"} 0
invalid_hist_name_bucket{A="B",C="D",le="10"} 0 invalid_hist_name_bucket{A="B",C="D",le="10"} 0
invalid_hist_name_bucket{A="B",C="D",le="25"} 1 invalid_hist_name_bucket{A="B",C="D",le="25"} 1
invalid_hist_name_bucket{A="B",C="D",le="50"} 0 invalid_hist_name_bucket{A="B",C="D",le="50"} 1
invalid_hist_name_bucket{A="B",C="D",le="75"} 0 invalid_hist_name_bucket{A="B",C="D",le="75"} 1
invalid_hist_name_bucket{A="B",C="D",le="100"} 0 invalid_hist_name_bucket{A="B",C="D",le="100"} 1
invalid_hist_name_bucket{A="B",C="D",le="250"} 0 invalid_hist_name_bucket{A="B",C="D",le="250"} 1
invalid_hist_name_bucket{A="B",C="D",le="500"} 0 invalid_hist_name_bucket{A="B",C="D",le="500"} 1
invalid_hist_name_bucket{A="B",C="D",le="750"} 0 invalid_hist_name_bucket{A="B",C="D",le="750"} 1
invalid_hist_name_bucket{A="B",C="D",le="1000"} 0 invalid_hist_name_bucket{A="B",C="D",le="1000"} 1
invalid_hist_name_bucket{A="B",C="D",le="2500"} 0 invalid_hist_name_bucket{A="B",C="D",le="2500"} 1
invalid_hist_name_bucket{A="B",C="D",le="5000"} 0 invalid_hist_name_bucket{A="B",C="D",le="5000"} 1
invalid_hist_name_bucket{A="B",C="D",le="7500"} 0 invalid_hist_name_bucket{A="B",C="D",le="7500"} 1
invalid_hist_name_bucket{A="B",C="D",le="10000"} 0 invalid_hist_name_bucket{A="B",C="D",le="10000"} 1
invalid_hist_name_bucket{A="B",C="D",le="+Inf"} 1 invalid_hist_name_bucket{A="B",C="D",le="+Inf"} 1
invalid_hist_name_sum{A="B",C="D"} 23 invalid_hist_name_sum{A="B",C="D"} 23
invalid_hist_name_count{A="B",C="D"} 1 invalid_hist_name_count{A="B",C="D"} 1