Skip to content

Commit

Permalink
Fixed code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Oct 15, 2022
1 parent 531104b commit 97ad7ae
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 62 deletions.
5 changes: 0 additions & 5 deletions api/test/nostd/unique_ptr_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ TEST(UniquePtrTest, Reset)
{
bool was_destructed1;
unique_ptr<A> ptr{new A{was_destructed1}};
/*
MSVC reports:
warning C4701: potentially uninitialized local variable 'was_destructed2' used
so initializing explicitly.
*/
bool was_destructed2 = true;
ptr.reset(new A{was_destructed2});
EXPECT_TRUE(was_destructed1);
Expand Down
42 changes: 21 additions & 21 deletions sdk/test/metrics/async_metric_storage_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ TEST_P(WritableMetricStorageTestFixture, TestAggregation)
storage.RecordLong(measurements1,
opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()));

storage.Collect(collector.get(), collectors, sdk_start_ts, collection_ts,
[&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
EXPECT_EQ(opentelemetry::nostd::get<long>(data.value_), get_count1);
}
else if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "PUT")
{
EXPECT_EQ(opentelemetry::nostd::get<long>(data.value_), put_count1);
}
}
return true;
});
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
EXPECT_EQ(opentelemetry::nostd::get<long>(data.value_), get_count1);
}
else if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "PUT")
{
EXPECT_EQ(opentelemetry::nostd::get<long>(data.value_), put_count1);
}
}
return true;
});
// subsequent recording after collection shouldn't fail
// monotonic increasing values;
long get_count2 = 50l;
Expand All @@ -105,10 +105,10 @@ TEST_P(WritableMetricStorageTestFixture, TestAggregation)
storage.RecordLong(measurements2,
opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()));
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down
36 changes: 18 additions & 18 deletions sdk/test/metrics/sync_metric_storage_counter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ TEST_P(WritableMetricStorageTestFixture, LongSumAggregation)
auto collection_ts = std::chrono::system_clock::now();
size_t count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -112,10 +112,10 @@ TEST_P(WritableMetricStorageTestFixture, LongSumAggregation)
collection_ts = std::chrono::system_clock::now();
count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -146,10 +146,10 @@ TEST_P(WritableMetricStorageTestFixture, LongSumAggregation)
collection_ts = std::chrono::system_clock::now();
count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -219,10 +219,10 @@ TEST_P(WritableMetricStorageTestFixture, DoubleSumAggregation)
auto collection_ts = std::chrono::system_clock::now();
size_t count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -252,10 +252,10 @@ TEST_P(WritableMetricStorageTestFixture, DoubleSumAggregation)
collection_ts = std::chrono::system_clock::now();
count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -288,10 +288,10 @@ TEST_P(WritableMetricStorageTestFixture, DoubleSumAggregation)
collection_ts = std::chrono::system_clock::now();
count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<SumPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down
36 changes: 18 additions & 18 deletions sdk/test/metrics/sync_metric_storage_histogram_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ TEST_P(WritableMetricStorageHistogramTestFixture, LongHistogram)
auto collection_ts = std::chrono::system_clock::now();
size_t count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -113,10 +113,10 @@ TEST_P(WritableMetricStorageHistogramTestFixture, LongHistogram)
collection_ts = std::chrono::system_clock::now();
count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -147,10 +147,10 @@ TEST_P(WritableMetricStorageHistogramTestFixture, LongHistogram)
collection_ts = std::chrono::system_clock::now();
count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -220,10 +220,10 @@ TEST_P(WritableMetricStorageHistogramTestFixture, DoubleHistogram)
auto collection_ts = std::chrono::system_clock::now();
size_t count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -253,10 +253,10 @@ TEST_P(WritableMetricStorageHistogramTestFixture, DoubleHistogram)
collection_ts = std::chrono::system_clock::now();
count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down Expand Up @@ -289,10 +289,10 @@ TEST_P(WritableMetricStorageHistogramTestFixture, DoubleHistogram)
collection_ts = std::chrono::system_clock::now();
count_attributes = 0;
storage.Collect(
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData metric_data) {
for (auto data_attr : metric_data.point_data_attr_)
collector.get(), collectors, sdk_start_ts, collection_ts, [&](const MetricData &metric_data) {
for (const auto &data_attr : metric_data.point_data_attr_)
{
auto data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
const auto &data = opentelemetry::nostd::get<HistogramPointData>(data_attr.point_data);
if (opentelemetry::nostd::get<std::string>(
data_attr.attributes.find("RequestType")->second) == "GET")
{
Expand Down

0 comments on commit 97ad7ae

Please sign in to comment.