mirror of
https://github.com/grafana/grafana.git
synced 2026-08-13 06:34:55 -05:00
Google Cloud Monitoring: Fix bucket bound for distributions (#56565)
This commit is contained in:
@@ -596,7 +596,12 @@ func calcBucketBound(bucketOptions cloudMonitoringBucketOptions, n int) string {
|
||||
case bucketOptions.ExponentialBuckets != nil:
|
||||
bucketBound = strconv.FormatInt(int64(bucketOptions.ExponentialBuckets.Scale*math.Pow(bucketOptions.ExponentialBuckets.GrowthFactor, float64(n-1))), 10)
|
||||
case bucketOptions.ExplicitBuckets != nil:
|
||||
bucketBound = fmt.Sprintf("%g", bucketOptions.ExplicitBuckets.Bounds[n])
|
||||
if n < len(bucketOptions.ExplicitBuckets.Bounds) {
|
||||
bucketBound = fmt.Sprintf("%g", bucketOptions.ExplicitBuckets.Bounds[n])
|
||||
} else {
|
||||
lastBound := bucketOptions.ExplicitBuckets.Bounds[len(bucketOptions.ExplicitBuckets.Bounds)-1]
|
||||
bucketBound = fmt.Sprintf("%g+", lastBound)
|
||||
}
|
||||
}
|
||||
return bucketBound
|
||||
}
|
||||
|
||||
@@ -103,7 +103,16 @@
|
||||
"4",
|
||||
"7",
|
||||
"12",
|
||||
"8"
|
||||
"8",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -198,7 +207,16 @@
|
||||
"5",
|
||||
"7",
|
||||
"11",
|
||||
"8"
|
||||
"8",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,8 +185,8 @@ func TestTimeSeriesFilter(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
frames := res.Frames
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 33, len(frames))
|
||||
for i := 0; i < 33; i++ {
|
||||
assert.Equal(t, 42, len(frames))
|
||||
for i := 0; i < 42; i++ {
|
||||
if i == 0 {
|
||||
assert.Equal(t, "0", frames[i].Fields[1].Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user