Skip to content

Commit

Permalink
Test histogram limit
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Dec 6, 2023
1 parent 3a59317 commit 0354e68
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions sdk/metric/internal/aggregate/histogram_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ type conf[N int64 | float64] struct {

func testDeltaHist[N int64 | float64](c conf[N]) func(t *testing.T) {
in, out := Builder[N]{
Temporality: metricdata.DeltaTemporality,
Filter: attrFltr,
Temporality: metricdata.DeltaTemporality,
Filter: attrFltr,
AggregationLimit: 3,
}.ExplicitBucketHistogram(bounds, noMinMax, c.noSum)
ctx := context.Background()
return test[N](in, out, []teststep[N]{
Expand Down Expand Up @@ -114,13 +115,34 @@ func testDeltaHist[N int64 | float64](c conf[N]) func(t *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.Histogram[N]{
Temporality: metricdata.DeltaTemporality,
DataPoints: []metricdata.HistogramDataPoint[N]{
c.hPt(fltrAlice, 1, 1),
c.hPt(fltrBob, 1, 1),
c.hPt(overflowSet, 1, 2),
},
},
},
},
})
}

func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
in, out := Builder[N]{
Temporality: metricdata.CumulativeTemporality,
Filter: attrFltr,
Temporality: metricdata.CumulativeTemporality,
Filter: attrFltr,
AggregationLimit: 3,
}.ExplicitBucketHistogram(bounds, noMinMax, c.noSum)
ctx := context.Background()
return test[N](in, out, []teststep[N]{
Expand Down Expand Up @@ -182,6 +204,24 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
},
},
},
{
input: []arg[N]{
// These will exceed cardinality limit.
{ctx, 1, carol},
{ctx, 1, dave},
},
expect: output{
n: 3,
agg: metricdata.Histogram[N]{
Temporality: metricdata.CumulativeTemporality,
DataPoints: []metricdata.HistogramDataPoint[N]{
c.hPt(fltrAlice, 2, 4),
c.hPt(fltrBob, 10, 3),
c.hPt(overflowSet, 1, 2),
},
},
},
},
})
}

Expand Down

0 comments on commit 0354e68

Please sign in to comment.