Skip to content

Commit

Permalink
Google Cloud Monitoring: Fix bucket bound for distributions (#56565)
Browse files Browse the repository at this point in the history
(cherry picked from commit 65e56c9)
  • Loading branch information
andresmgot authored and grafanabot committed Oct 10, 2022
1 parent b8aa314 commit 356883d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
7 changes: 6 additions & 1 deletion pkg/tsdb/cloudmonitoring/cloudmonitoring.go
Expand Up @@ -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
}
Expand Down
Expand Up @@ -103,7 +103,16 @@
"4",
"7",
"12",
"8"
"8",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0"
]
}
}
Expand Down Expand Up @@ -198,7 +207,16 @@
"5",
"7",
"11",
"8"
"8",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/tsdb/cloudmonitoring/time_series_filter_test.go
Expand Up @@ -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)
}
Expand Down

0 comments on commit 356883d

Please sign in to comment.