diff --git a/sdk/metric/internal/aggregate/lastvalue_test.go b/sdk/metric/internal/aggregate/lastvalue_test.go index c758eb370c7..479232ad435 100644 --- a/sdk/metric/internal/aggregate/lastvalue_test.go +++ b/sdk/metric/internal/aggregate/lastvalue_test.go @@ -29,7 +29,10 @@ func TestLastValue(t *testing.T) { } func testLastValue[N int64 | float64]() func(*testing.T) { - in, out := Builder[N]{Filter: attrFltr}.LastValue() + in, out := Builder[N]{ + Filter: attrFltr, + AggregationLimit: 3, + }.LastValue() ctx := context.Background() return test[N](in, out, []teststep[N]{ { @@ -87,6 +90,36 @@ func testLastValue[N int64 | float64]() func(*testing.T) { }, }, }, + }, { + input: []arg[N]{ + {ctx, 1, alice}, + {ctx, 1, bob}, + // These will exceed cardinality limit. + {ctx, 1, carol}, + {ctx, 1, dave}, + }, + expect: output{ + n: 3, + agg: metricdata.Gauge[N]{ + DataPoints: []metricdata.DataPoint[N]{ + { + Attributes: fltrAlice, + Time: staticTime, + Value: 1, + }, + { + Attributes: fltrBob, + Time: staticTime, + Value: 1, + }, + { + Attributes: overflowSet, + Time: staticTime, + Value: 1, + }, + }, + }, + }, }, }) }