Skip to content

Commit 804fa54

Browse files
Copilotlalitb
andcommitted
Fix cardinality limit test expectation to match OpenTelemetry specification
Co-authored-by: lalitb <[email protected]>
1 parent b26221c commit 804fa54

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sdk/test/metrics/cardinality_limit_test.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ TEST(CardinalityLimit, SyncMetricStorageWithViewCardinalityLimit)
205205

206206
int64_t record_value = 100;
207207
// Add 5 unique metric points (should all fit within limit)
208+
// With cardinality limit 5: first 4 get individual metric points
208209
for (auto i = 0; i < 5; i++)
209210
{
210211
std::map<std::string, std::string> attributes = {{"key", std::to_string(i)}};
@@ -214,6 +215,7 @@ TEST(CardinalityLimit, SyncMetricStorageWithViewCardinalityLimit)
214215
}
215216

216217
// Add 3 more unique metric points (should trigger overflow behavior)
218+
// These will be aggregated with the 5th metric point into overflow bucket
217219
for (auto i = 5; i < 8; i++)
218220
{
219221
std::map<std::string, std::string> attributes = {{"key", std::to_string(i)}};
@@ -237,9 +239,10 @@ TEST(CardinalityLimit, SyncMetricStorageWithViewCardinalityLimit)
237239
count_attributes++;
238240
if (data_attr.attributes.begin()->first == kAttributesLimitOverflowKey)
239241
{
240-
// The overflow attribute should contain the aggregated values from the 3 excess metrics
242+
// The overflow attribute should contain the aggregated values from the 4 excess metrics
243+
// With cardinality limit 5: first 4 get individual points, remaining 4 go to overflow
241244
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
242-
EXPECT_EQ(nostd::get<int64_t>(data.value_), record_value * 3);
245+
EXPECT_EQ(nostd::get<int64_t>(data.value_), record_value * 4);
243246
overflow_present = true;
244247
}
245248
}

0 commit comments

Comments
 (0)