Cloudwatch: Use generic null-insertion mechanism (#43507)
* Cloudwatch: Fix nil values for a period gap in metrics * Use fields periods for intervals
This commit is contained in:
@@ -162,13 +162,6 @@ func buildDataFrames(startTime time.Time, endTime time.Time, aggregatedResponse
|
||||
timestamps := []*time.Time{}
|
||||
points := []*float64{}
|
||||
for j, t := range metric.Timestamps {
|
||||
if j > 0 {
|
||||
expectedTimestamp := metric.Timestamps[j-1].Add(time.Duration(query.Period) * time.Second)
|
||||
if expectedTimestamp.Before(*t) {
|
||||
timestamps = append(timestamps, &expectedTimestamp)
|
||||
points = append(points, nil)
|
||||
}
|
||||
}
|
||||
val := metric.Values[j]
|
||||
timestamps = append(timestamps, t)
|
||||
points = append(points, val)
|
||||
|
||||
@@ -422,8 +422,7 @@ func TestCloudWatchResponseParser(t *testing.T) {
|
||||
assert.Equal(t, "lb", frame.Fields[1].Labels["LoadBalancer"])
|
||||
assert.Equal(t, 10.0, *frame.Fields[1].At(0).(*float64))
|
||||
assert.Equal(t, 20.0, *frame.Fields[1].At(1).(*float64))
|
||||
assert.Nil(t, frame.Fields[1].At(2))
|
||||
assert.Equal(t, 30.0, *frame.Fields[1].At(3).(*float64))
|
||||
assert.Equal(t, 30.0, *frame.Fields[1].At(2).(*float64))
|
||||
assert.Equal(t, "Value", frame.Fields[1].Name)
|
||||
assert.Equal(t, "", frame.Fields[1].Config.DisplayName)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user