Skip to content

Commit f3ea8f0

Browse files
committed
Address feedback
1 parent c7b4a64 commit f3ea8f0

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

sdk/test/metrics/async_metric_storage_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ TEST_P(WritableMetricStorageTestUpDownFixture, TestAggregation)
194194
}
195195
return true;
196196
});
197-
// subsequent recording after collection shouldn't fail
198-
// monotonic increasing values;
197+
// Note: When the cardinality limit is set to n, the attributes hashmap emits n-1 distinct attribute sets,
198+
// plus an overflow bucket for additional attributes. The test logic below is made generic to succeed for either
199+
// n or n-1 total cardinality. If this behavior is unexpected, please investigate and file an issue.
199200
int64_t get_count2 = -50;
200201
int64_t put_count2 = -70;
201202

sdk/test/metrics/sum_aggregation_test.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TEST(HistogramToSum, Double)
4545
MeterProvider mp;
4646
auto m = mp.GetMeter("meter1", "version1", "schema1");
4747
std::string instrument_unit = "ms";
48-
std::string instrument_name = "historgram1";
48+
std::string instrument_name = "histogram1";
4949
std::string instrument_desc = "histogram metrics";
5050

5151
std::unique_ptr<MockMetricExporter> exporter(new MockMetricExporter());
@@ -97,7 +97,7 @@ TEST(HistogramToSumFilterAttributes, Double)
9797
MeterProvider mp;
9898
auto m = mp.GetMeter("meter1", "version1", "schema1");
9999
std::string instrument_unit = "ms";
100-
std::string instrument_name = "historgram1";
100+
std::string instrument_name = "histogram1";
101101
std::string instrument_desc = "histogram metrics";
102102

103103
std::unordered_map<std::string, bool> allowedattr;
@@ -150,7 +150,7 @@ TEST(HistogramToSumFilterAttributesWithCardinaityLimit, Double)
150150
MeterProvider mp;
151151
auto m = mp.GetMeter("meter1", "version1", "schema1");
152152
std::string instrument_unit = "ms";
153-
std::string instrument_name = "historgram1";
153+
std::string instrument_name = "histogram1";
154154
std::string instrument_desc = "histogram metrics";
155155
size_t cardinality_limit = 10000;
156156

@@ -375,9 +375,10 @@ TEST(CounterToSumFilterAttributesWithCardinalityLimit, Double)
375375
{
376376
for (const MetricData &md : smd.metric_data_)
377377
{
378-
// Something weird about attributes hashmap. If cardinality is setup to n, it emits n-1
379-
// including overflow. Just making the logic generic here to succeed for n or n-1 total
380-
// cardinality.
378+
// When the number of unique attribute sets exceeds the cardinality limit, the implementation
379+
// emits up to (cardinality_limit - 1) unique sets and one overflow set, resulting in a total
380+
// of cardinality_limit sets. This test checks that the number of emitted attribute sets is
381+
// within the expected range, accounting for the overflow behavior.
381382
EXPECT_GE(cardinality_limit, md.point_data_attr_.size());
382383
EXPECT_LT(cardinality_limit / 2, md.point_data_attr_.size());
383384
for (size_t i = 0; i < md.point_data_attr_.size(); i++)

0 commit comments

Comments
 (0)