Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Signed-off-by: SpiritZhou <[email protected]>
  • Loading branch information
SpiritZhou committed Apr 19, 2024
1 parent a6cdff9 commit e3fc448
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions pkg/metricscollector/opentelemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,32 @@ func TestContinuousMetrics(t *testing.T) {
dataPoints := activeMetric.Data.(metricdata.Gauge[float64]).DataPoints
assert.Len(t, dataPoints, 2)

scaledObjectMetric := dataPoints[0]
attribute, _ := scaledObjectMetric.Attributes.Value("namespace")
assert.Equal(t, attribute.AsString(), "testnamespace")
attribute, _ = scaledObjectMetric.Attributes.Value("scaledObject")
var scaledObjectMetric metricdata.DataPoint[float64]
for _, v := range dataPoints {
attribute, _ := v.Attributes.Value("namespace")
if attribute.AsString() == "testnamespace" {
scaledObjectMetric = v
}
}

assert.NotEqual(t, scaledObjectMetric, metricdata.DataPoint[float64]{})
attribute, _ := scaledObjectMetric.Attributes.Value("scaledObject")
assert.Equal(t, attribute.AsString(), "testresource")
attribute, _ = scaledObjectMetric.Attributes.Value("scaler")
assert.Equal(t, attribute.AsString(), "testscaler")
attribute, _ = scaledObjectMetric.Attributes.Value("metric")
assert.Equal(t, attribute.AsString(), "testmetric")
assert.Equal(t, scaledObjectMetric.Value, 1.0)

scaledJobMetric := dataPoints[1]
var scaledJobMetric metricdata.DataPoint[float64]
for _, v := range dataPoints {
attribute, _ := v.Attributes.Value("namespace")
if attribute.AsString() == "testnamespace2" {
scaledJobMetric = v
}
}

assert.NotEqual(t, scaledJobMetric, metricdata.DataPoint[float64]{})
attribute, _ = scaledJobMetric.Attributes.Value("namespace")
assert.Equal(t, attribute.AsString(), "testnamespace2")
attribute, _ = scaledJobMetric.Attributes.Value("scaledJob")
Expand Down

0 comments on commit e3fc448

Please sign in to comment.