From 3a59317ad1bf257b881df06c1a405cf7b7eeeabd Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 6 Dec 2023 13:18:11 -0800 Subject: [PATCH] Test limit for last value --- .../internal/aggregate/lastvalue_test.go | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) 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, + }, + }, + }, + }, }, }) }