From a6745e7af3c9a96ae7fd5377b8d17365bc665a66 Mon Sep 17 00:00:00 2001 From: Oblivion Date: Thu, 11 Aug 2022 15:50:41 +0000 Subject: [PATCH] remove throw check from metrics with noexcept --- api/test/metrics/noop_sync_instrument_test.cc | 32 ++--- sdk/test/metrics/aggregation_test.cc | 32 ++--- sdk/test/metrics/async_metric_storage_test.cc | 4 +- .../exemplar/no_exemplar_reservoir_test.cc | 9 +- sdk/test/metrics/meter_provider_sdk_test.cc | 6 +- sdk/test/metrics/metric_reader_test.cc | 4 +- sdk/test/metrics/multi_metric_storage_test.cc | 8 +- sdk/test/metrics/sync_instruments_test.cc | 126 +++++++++--------- sdk/test/metrics/sync_metric_storage_test.cc | 44 +++--- 9 files changed, 129 insertions(+), 136 deletions(-) diff --git a/api/test/metrics/noop_sync_instrument_test.cc b/api/test/metrics/noop_sync_instrument_test.cc index 62be4f34ab..9d7c1f2fe6 100644 --- a/api/test/metrics/noop_sync_instrument_test.cc +++ b/api/test/metrics/noop_sync_instrument_test.cc @@ -13,12 +13,12 @@ TEST(Counter, Add) new opentelemetry::metrics::NoopCounter("test", "none", "unitless")}; std::map labels = {{"k1", "v1"}}; - EXPECT_NO_THROW(counter->Add(10l, labels)); - EXPECT_NO_THROW(counter->Add(10l, labels, opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter->Add(2l)); - EXPECT_NO_THROW(counter->Add(2l, opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter->Add(10l, {{"k1", "1"}, {"k2", 2}})); - EXPECT_NO_THROW(counter->Add(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{})); + counter->Add(10l, labels); + counter->Add(10l, labels, opentelemetry::context::Context{}); + counter->Add(2l); + counter->Add(2l, opentelemetry::context::Context{}); + counter->Add(10l, {{"k1", "1"}, {"k2", 2}}); + counter->Add(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{}); } TEST(histogram, Record) @@ -27,10 +27,10 @@ TEST(histogram, Record) new opentelemetry::metrics::NoopHistogram("test", "none", "unitless")}; std::map labels = {{"k1", "v1"}}; - EXPECT_NO_THROW(counter->Record(10l, labels, opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter->Record(2l, opentelemetry::context::Context{})); - EXPECT_NO_THROW( - counter->Record(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{})); + counter->Record(10l, labels, opentelemetry::context::Context{}); + counter->Record(2l, opentelemetry::context::Context{}); + + counter->Record(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{}); } TEST(UpDownCountr, Record) @@ -39,12 +39,12 @@ TEST(UpDownCountr, Record) new opentelemetry::metrics::NoopUpDownCounter("test", "none", "unitless")}; std::map labels = {{"k1", "v1"}}; - EXPECT_NO_THROW(counter->Add(10l, labels)); - EXPECT_NO_THROW(counter->Add(10l, labels, opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter->Add(2l)); - EXPECT_NO_THROW(counter->Add(2l, opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter->Add(10l, {{"k1", "1"}, {"k2", 2}})); - EXPECT_NO_THROW(counter->Add(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{})); + counter->Add(10l, labels); + counter->Add(10l, labels, opentelemetry::context::Context{}); + counter->Add(2l); + counter->Add(2l, opentelemetry::context::Context{}); + counter->Add(10l, {{"k1", "1"}, {"k2", 2}}); + counter->Add(10l, {{"k1", "1"}, {"k2", 2}}, opentelemetry::context::Context{}); } #endif \ No newline at end of file diff --git a/sdk/test/metrics/aggregation_test.cc b/sdk/test/metrics/aggregation_test.cc index 9d84a95d81..c10ccae366 100644 --- a/sdk/test/metrics/aggregation_test.cc +++ b/sdk/test/metrics/aggregation_test.cc @@ -20,8 +20,8 @@ TEST(Aggregation, LongSumAggregation) auto sum_data = nostd::get(data); ASSERT_TRUE(nostd::holds_alternative(sum_data.value_)); EXPECT_EQ(nostd::get(sum_data.value_), 0l); - EXPECT_NO_THROW(aggr.Aggregate(12l, {})); - EXPECT_NO_THROW(aggr.Aggregate(0l, {})); + aggr.Aggregate(12l, {}); + aggr.Aggregate(0l, {}); sum_data = nostd::get(aggr.ToPoint()); EXPECT_EQ(nostd::get(sum_data.value_), 12l); } @@ -34,8 +34,8 @@ TEST(Aggregation, DoubleSumAggregation) auto sum_data = nostd::get(data); ASSERT_TRUE(nostd::holds_alternative(sum_data.value_)); EXPECT_EQ(nostd::get(sum_data.value_), 0); - EXPECT_NO_THROW(aggr.Aggregate(12.0, {})); - EXPECT_NO_THROW(aggr.Aggregate(1.0, {})); + aggr.Aggregate(12.0, {}); + aggr.Aggregate(1.0, {}); sum_data = nostd::get(aggr.ToPoint()); EXPECT_EQ(nostd::get(sum_data.value_), 13.0); } @@ -48,8 +48,8 @@ TEST(Aggregation, LongLastValueAggregation) auto lastvalue_data = nostd::get(data); ASSERT_TRUE(nostd::holds_alternative(lastvalue_data.value_)); EXPECT_EQ(lastvalue_data.is_lastvalue_valid_, false); - EXPECT_NO_THROW(aggr.Aggregate(12l, {})); - EXPECT_NO_THROW(aggr.Aggregate(1l, {})); + aggr.Aggregate(12l, {}); + aggr.Aggregate(1l, {}); lastvalue_data = nostd::get(aggr.ToPoint()); EXPECT_EQ(nostd::get(lastvalue_data.value_), 1.0); } @@ -62,8 +62,8 @@ TEST(Aggregation, DoubleLastValueAggregation) auto lastvalue_data = nostd::get(data); ASSERT_TRUE(nostd::holds_alternative(lastvalue_data.value_)); EXPECT_EQ(lastvalue_data.is_lastvalue_valid_, false); - EXPECT_NO_THROW(aggr.Aggregate(12.0, {})); - EXPECT_NO_THROW(aggr.Aggregate(1.0, {})); + aggr.Aggregate(12.0, {}); + aggr.Aggregate(1.0, {}); lastvalue_data = nostd::get(aggr.ToPoint()); EXPECT_EQ(nostd::get(lastvalue_data.value_), 1.0); } @@ -78,8 +78,8 @@ TEST(Aggregation, LongHistogramAggregation) ASSERT_TRUE(nostd::holds_alternative>(histogram_data.boundaries_)); EXPECT_EQ(nostd::get(histogram_data.sum_), 0); EXPECT_EQ(histogram_data.count_, 0); - EXPECT_NO_THROW(aggr.Aggregate(12l, {})); // lies in fourth bucket - EXPECT_NO_THROW(aggr.Aggregate(100l, {})); // lies in eight bucket + aggr.Aggregate(12l, {}); // lies in fourth bucket + aggr.Aggregate(100l, {}); // lies in eight bucket histogram_data = nostd::get(aggr.ToPoint()); EXPECT_EQ(nostd::get(histogram_data.min_), 12); EXPECT_EQ(nostd::get(histogram_data.max_), 100); @@ -87,8 +87,8 @@ TEST(Aggregation, LongHistogramAggregation) EXPECT_EQ(histogram_data.count_, 2); EXPECT_EQ(histogram_data.counts_[3], 1); EXPECT_EQ(histogram_data.counts_[7], 1); - EXPECT_NO_THROW(aggr.Aggregate(13l, {})); // lies in fourth bucket - EXPECT_NO_THROW(aggr.Aggregate(252l, {})); // lies in ninth bucket + aggr.Aggregate(13l, {}); // lies in fourth bucket + aggr.Aggregate(252l, {}); // lies in ninth bucket histogram_data = nostd::get(aggr.ToPoint()); EXPECT_EQ(histogram_data.count_, 4); EXPECT_EQ(histogram_data.counts_[3], 2); @@ -169,8 +169,8 @@ TEST(Aggregation, DoubleHistogramAggregation) ASSERT_TRUE(nostd::holds_alternative>(histogram_data.boundaries_)); EXPECT_EQ(nostd::get(histogram_data.sum_), 0); EXPECT_EQ(histogram_data.count_, 0); - EXPECT_NO_THROW(aggr.Aggregate(12.0, {})); // lies in fourth bucket - EXPECT_NO_THROW(aggr.Aggregate(100.0, {})); // lies in eight bucket + aggr.Aggregate(12.0, {}); // lies in fourth bucket + aggr.Aggregate(100.0, {}); // lies in eight bucket histogram_data = nostd::get(aggr.ToPoint()); EXPECT_EQ(nostd::get(histogram_data.sum_), 112); EXPECT_EQ(histogram_data.count_, 2); @@ -178,8 +178,8 @@ TEST(Aggregation, DoubleHistogramAggregation) EXPECT_EQ(histogram_data.counts_[7], 1); EXPECT_EQ(nostd::get(histogram_data.min_), 12); EXPECT_EQ(nostd::get(histogram_data.max_), 100); - EXPECT_NO_THROW(aggr.Aggregate(13.0, {})); // lies in fourth bucket - EXPECT_NO_THROW(aggr.Aggregate(252.0, {})); // lies in ninth bucket + aggr.Aggregate(13.0, {}); // lies in fourth bucket + aggr.Aggregate(252.0, {}); // lies in ninth bucket histogram_data = nostd::get(aggr.ToPoint()); EXPECT_EQ(histogram_data.count_, 4); EXPECT_EQ(histogram_data.counts_[3], 2); diff --git a/sdk/test/metrics/async_metric_storage_test.cc b/sdk/test/metrics/async_metric_storage_test.cc index 729a793163..5f4a611a9a 100644 --- a/sdk/test/metrics/async_metric_storage_test.cc +++ b/sdk/test/metrics/async_metric_storage_test.cc @@ -129,8 +129,8 @@ TEST_P(WritableMetricStorageTestFixture, TestAggregation) return true; }); // subsequent recording after collection shouldn't fail - EXPECT_NO_THROW(storage.RecordLong( - measurements, opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()))); + storage.RecordLong(measurements, + opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now())); EXPECT_EQ(MeasurementFetcher::number_of_attributes, attribute_count); } diff --git a/sdk/test/metrics/exemplar/no_exemplar_reservoir_test.cc b/sdk/test/metrics/exemplar/no_exemplar_reservoir_test.cc index 3e16940ff4..72341de9de 100644 --- a/sdk/test/metrics/exemplar/no_exemplar_reservoir_test.cc +++ b/sdk/test/metrics/exemplar/no_exemplar_reservoir_test.cc @@ -10,11 +10,10 @@ using namespace opentelemetry::sdk::metrics; TEST(NoExemplarReservoir, OfferMeasurement) { auto reservoir = opentelemetry::sdk::metrics::NoExemplarReservoir::GetNoExemplarReservoir(); - EXPECT_NO_THROW(reservoir->OfferMeasurement(1.0, MetricAttributes{}, - opentelemetry::context::Context{}, - std::chrono::system_clock::now())); - EXPECT_NO_THROW(reservoir->OfferMeasurement( - 1l, MetricAttributes{}, opentelemetry::context::Context{}, std::chrono::system_clock::now())); + reservoir->OfferMeasurement(1.0, MetricAttributes{}, opentelemetry::context::Context{}, + std::chrono::system_clock::now()); + reservoir->OfferMeasurement(1l, MetricAttributes{}, opentelemetry::context::Context{}, + std::chrono::system_clock::now()); auto exemplar_data = reservoir->CollectAndReset(MetricAttributes{}); ASSERT_TRUE(exemplar_data.empty()); } diff --git a/sdk/test/metrics/meter_provider_sdk_test.cc b/sdk/test/metrics/meter_provider_sdk_test.cc index 63db4bebf8..535384e0f4 100644 --- a/sdk/test/metrics/meter_provider_sdk_test.cc +++ b/sdk/test/metrics/meter_provider_sdk_test.cc @@ -90,13 +90,13 @@ TEST(MeterProvider, GetMeter) ASSERT_NE(nullptr, sdkMeter1); std::unique_ptr exporter(new MockMetricExporter()); std::unique_ptr reader{new MockMetricReader(std::move(exporter))}; - ASSERT_NO_THROW(mp1.AddMetricReader(std::move(reader))); + mp1.AddMetricReader(std::move(reader)); std::unique_ptr view{std::unique_ptr()}; std::unique_ptr instrument_selector{ new InstrumentSelector(InstrumentType::kCounter, "instru1")}; std::unique_ptr meter_selector{new MeterSelector("name1", "version1", "schema1")}; - ASSERT_NO_THROW( - mp1.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view))); + + mp1.AddView(std::move(instrument_selector), std::move(meter_selector), std::move(view)); } #endif diff --git a/sdk/test/metrics/metric_reader_test.cc b/sdk/test/metrics/metric_reader_test.cc index 9f15aa1cbe..9a6f31d61c 100644 --- a/sdk/test/metrics/metric_reader_test.cc +++ b/sdk/test/metrics/metric_reader_test.cc @@ -33,12 +33,12 @@ TEST(MetricReaderTest, BasicTests) AggregationTemporality::kCumulative); std::shared_ptr meter_context1(new MeterContext()); - EXPECT_NO_THROW(meter_context1->AddMetricReader(std::move(metric_reader1))); + meter_context1->AddMetricReader(std::move(metric_reader1)); std::unique_ptr metric_reader2(new MockMetricReader()); std::shared_ptr meter_context2(new MeterContext()); std::shared_ptr metric_producer{ new MetricCollector(meter_context2.get(), std::move(metric_reader2))}; - EXPECT_NO_THROW(metric_producer->Collect([](ResourceMetrics &metric_data) { return true; })); + metric_producer->Collect([](ResourceMetrics &metric_data) { return true; }); } #endif diff --git a/sdk/test/metrics/multi_metric_storage_test.cc b/sdk/test/metrics/multi_metric_storage_test.cc index 768949be8c..df027424d3 100644 --- a/sdk/test/metrics/multi_metric_storage_test.cc +++ b/sdk/test/metrics/multi_metric_storage_test.cc @@ -50,11 +50,11 @@ TEST(MultiMetricStorageTest, BasicTests) new TestMetricStorage()); SyncMultiMetricStorage storages{}; storages.AddStorage(storage); - EXPECT_NO_THROW(storages.RecordLong(10l, opentelemetry::context::Context{})); - EXPECT_NO_THROW(storages.RecordLong(20l, opentelemetry::context::Context{})); + storages.RecordLong(10l, opentelemetry::context::Context{}); + storages.RecordLong(20l, opentelemetry::context::Context{}); - EXPECT_NO_THROW(storages.RecordDouble(10.0, opentelemetry::context::Context{})); - EXPECT_NO_THROW(storages.RecordLong(30l, opentelemetry::context::Context{})); + storages.RecordDouble(10.0, opentelemetry::context::Context{}); + storages.RecordLong(30l, opentelemetry::context::Context{}); EXPECT_EQ(static_cast(storage.get())->num_calls_long, 3); EXPECT_EQ(static_cast(storage.get())->num_calls_double, 1); diff --git a/sdk/test/metrics/sync_instruments_test.cc b/sdk/test/metrics/sync_instruments_test.cc index 88996efd61..1c276c046f 100644 --- a/sdk/test/metrics/sync_instruments_test.cc +++ b/sdk/test/metrics/sync_instruments_test.cc @@ -26,17 +26,16 @@ TEST(SyncInstruments, LongCounter) "long_counter", "description", "1", InstrumentType::kCounter, InstrumentValueType::kLong}; std::unique_ptr metric_storage(new SyncMultiMetricStorage()); LongCounter counter(instrument_descriptor, std::move(metric_storage)); - EXPECT_NO_THROW(counter.Add(10l)); - EXPECT_NO_THROW(counter.Add(10l, opentelemetry::context::Context{})); - - EXPECT_NO_THROW(counter.Add( - 10l, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}))); - EXPECT_NO_THROW(counter.Add( - 10l, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), - opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Add(10l, opentelemetry::common::KeyValueIterableView({}))); - EXPECT_NO_THROW(counter.Add(10l, opentelemetry::common::KeyValueIterableView({}), - opentelemetry::context::Context{})); + counter.Add(10l); + counter.Add(10l, opentelemetry::context::Context{}); + + counter.Add(10l, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}})); + counter.Add(10l, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + counter.Add(10l, opentelemetry::common::KeyValueIterableView({})); + counter.Add(10l, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); } TEST(SyncInstruments, DoubleCounter) @@ -45,17 +44,17 @@ TEST(SyncInstruments, DoubleCounter) "double_counter", "description", "1", InstrumentType::kCounter, InstrumentValueType::kDouble}; std::unique_ptr metric_storage(new SyncMultiMetricStorage()); DoubleCounter counter(instrument_descriptor, std::move(metric_storage)); - EXPECT_NO_THROW(counter.Add(10.10)); - EXPECT_NO_THROW(counter.Add(10.10, opentelemetry::context::Context{})); - - EXPECT_NO_THROW(counter.Add( - 10.10, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}))); - EXPECT_NO_THROW(counter.Add( - 10.10, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), - opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Add(10.10, opentelemetry::common::KeyValueIterableView({}))); - EXPECT_NO_THROW(counter.Add(10.10, opentelemetry::common::KeyValueIterableView({}), - opentelemetry::context::Context{})); + counter.Add(10.10); + counter.Add(10.10, opentelemetry::context::Context{}); + + counter.Add(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}})); + counter.Add(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + counter.Add(10.10, opentelemetry::common::KeyValueIterableView({})); + counter.Add(10.10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); } TEST(SyncInstruments, LongUpDownCounter) @@ -65,17 +64,16 @@ TEST(SyncInstruments, LongUpDownCounter) InstrumentValueType::kLong}; std::unique_ptr metric_storage(new SyncMultiMetricStorage()); LongUpDownCounter counter(instrument_descriptor, std::move(metric_storage)); - EXPECT_NO_THROW(counter.Add(10l)); - EXPECT_NO_THROW(counter.Add(10l, opentelemetry::context::Context{})); - - EXPECT_NO_THROW(counter.Add( - 10l, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}))); - EXPECT_NO_THROW(counter.Add( - 10l, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), - opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Add(10l, opentelemetry::common::KeyValueIterableView({}))); - EXPECT_NO_THROW(counter.Add(10l, opentelemetry::common::KeyValueIterableView({}), - opentelemetry::context::Context{})); + counter.Add(10l); + counter.Add(10l, opentelemetry::context::Context{}); + + counter.Add(10l, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}})); + counter.Add(10l, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + counter.Add(10l, opentelemetry::common::KeyValueIterableView({})); + counter.Add(10l, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); } TEST(SyncInstruments, DoubleUpDownCounter) @@ -85,17 +83,17 @@ TEST(SyncInstruments, DoubleUpDownCounter) InstrumentValueType::kDouble}; std::unique_ptr metric_storage(new SyncMultiMetricStorage()); DoubleUpDownCounter counter(instrument_descriptor, std::move(metric_storage)); - EXPECT_NO_THROW(counter.Add(10.10)); - EXPECT_NO_THROW(counter.Add(10.10, opentelemetry::context::Context{})); - - EXPECT_NO_THROW(counter.Add( - 10.10, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), - opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Add( - 10.10, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}))); - EXPECT_NO_THROW(counter.Add(10.10, opentelemetry::common::KeyValueIterableView({}), - opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Add(10.10, opentelemetry::common::KeyValueIterableView({}))); + counter.Add(10.10); + counter.Add(10.10, opentelemetry::context::Context{}); + + counter.Add(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + counter.Add(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}})); + counter.Add(10.10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); + counter.Add(10.10, opentelemetry::common::KeyValueIterableView({})); } TEST(SyncInstruments, LongHistogram) @@ -104,14 +102,14 @@ TEST(SyncInstruments, LongHistogram) "long_histogram", "description", "1", InstrumentType::kHistogram, InstrumentValueType::kLong}; std::unique_ptr metric_storage(new SyncMultiMetricStorage()); LongHistogram counter(instrument_descriptor, std::move(metric_storage)); - EXPECT_NO_THROW(counter.Record(10l, opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Record(-10l, opentelemetry::context::Context{})); // This is ignored - - EXPECT_NO_THROW(counter.Record( - 10l, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), - opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Record(10l, opentelemetry::common::KeyValueIterableView({}), - opentelemetry::context::Context{})); + counter.Record(10l, opentelemetry::context::Context{}); + counter.Record(-10l, opentelemetry::context::Context{}); // This is ignored + + counter.Record(10l, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + counter.Record(10l, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); } TEST(SyncInstruments, DoubleHistogram) @@ -121,18 +119,18 @@ TEST(SyncInstruments, DoubleHistogram) InstrumentValueType::kDouble}; std::unique_ptr metric_storage(new SyncMultiMetricStorage()); DoubleHistogram counter(instrument_descriptor, std::move(metric_storage)); - EXPECT_NO_THROW(counter.Record(10.10, opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Record(-10.10, opentelemetry::context::Context{})); // This is ignored. - EXPECT_NO_THROW(counter.Record(std::numeric_limits::quiet_NaN(), - opentelemetry::context::Context{})); // This is ignored too - EXPECT_NO_THROW(counter.Record(std::numeric_limits::infinity(), - opentelemetry::context::Context{})); // This is ignored too - - EXPECT_NO_THROW(counter.Record( - 10.10, opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), - opentelemetry::context::Context{})); - EXPECT_NO_THROW(counter.Record(10.10, opentelemetry::common::KeyValueIterableView({}), - opentelemetry::context::Context{})); + counter.Record(10.10, opentelemetry::context::Context{}); + counter.Record(-10.10, opentelemetry::context::Context{}); // This is ignored. + counter.Record(std::numeric_limits::quiet_NaN(), + opentelemetry::context::Context{}); // This is ignored too + counter.Record(std::numeric_limits::infinity(), + opentelemetry::context::Context{}); // This is ignored too + + counter.Record(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + counter.Record(10.10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); } #endif \ No newline at end of file diff --git a/sdk/test/metrics/sync_metric_storage_test.cc b/sdk/test/metrics/sync_metric_storage_test.cc index c2123d805b..6c167c7a29 100644 --- a/sdk/test/metrics/sync_metric_storage_test.cc +++ b/sdk/test/metrics/sync_metric_storage_test.cc @@ -57,18 +57,16 @@ TEST_P(WritableMetricStorageTestFixture, LongSumAggregation) opentelemetry::context::Context{}); expected_total_get_requests += 10; - EXPECT_NO_THROW(storage.RecordLong( - 30l, KeyValueIterableView>(attributes_put), - opentelemetry::context::Context{})); + storage.RecordLong(30l, KeyValueIterableView>(attributes_put), + opentelemetry::context::Context{}); expected_total_put_requests += 30; storage.RecordLong(20l, KeyValueIterableView>(attributes_get), opentelemetry::context::Context{}); expected_total_get_requests += 20; - EXPECT_NO_THROW(storage.RecordLong( - 40l, KeyValueIterableView>(attributes_put), - opentelemetry::context::Context{})); + storage.RecordLong(40l, KeyValueIterableView>(attributes_put), + opentelemetry::context::Context{}); expected_total_put_requests += 40; std::shared_ptr collector(new MockCollectorHandle(temporality)); @@ -107,13 +105,11 @@ TEST_P(WritableMetricStorageTestFixture, LongSumAggregation) expected_total_put_requests = 0; } - EXPECT_NO_THROW(storage.RecordLong( - 50l, KeyValueIterableView>(attributes_get), - opentelemetry::context::Context{})); + storage.RecordLong(50l, KeyValueIterableView>(attributes_get), + opentelemetry::context::Context{}); expected_total_get_requests += 50; - EXPECT_NO_THROW(storage.RecordLong( - 40l, KeyValueIterableView>(attributes_put), - opentelemetry::context::Context{})); + storage.RecordLong(40l, KeyValueIterableView>(attributes_put), + opentelemetry::context::Context{}); expected_total_put_requests += 40; collection_ts = std::chrono::system_clock::now(); @@ -167,9 +163,9 @@ TEST_P(WritableMetricStorageTestFixture, DoubleSumAggregation) opentelemetry::context::Context{}); expected_total_get_requests += 10; - EXPECT_NO_THROW(storage.RecordDouble( - 30.0, KeyValueIterableView>(attributes_put), - opentelemetry::context::Context{})); + storage.RecordDouble(30.0, + KeyValueIterableView>(attributes_put), + opentelemetry::context::Context{}); expected_total_put_requests += 30; storage.RecordDouble(20.0, @@ -177,9 +173,9 @@ TEST_P(WritableMetricStorageTestFixture, DoubleSumAggregation) opentelemetry::context::Context{}); expected_total_get_requests += 20; - EXPECT_NO_THROW(storage.RecordDouble( - 40.0, KeyValueIterableView>(attributes_put), - opentelemetry::context::Context{})); + storage.RecordDouble(40.0, + KeyValueIterableView>(attributes_put), + opentelemetry::context::Context{}); expected_total_put_requests += 40; std::shared_ptr collector(new MockCollectorHandle(temporality)); @@ -218,13 +214,13 @@ TEST_P(WritableMetricStorageTestFixture, DoubleSumAggregation) expected_total_put_requests = 0; } - EXPECT_NO_THROW(storage.RecordDouble( - 50.0, KeyValueIterableView>(attributes_get), - opentelemetry::context::Context{})); + storage.RecordDouble(50.0, + KeyValueIterableView>(attributes_get), + opentelemetry::context::Context{}); expected_total_get_requests += 50; - EXPECT_NO_THROW(storage.RecordDouble( - 40.0, KeyValueIterableView>(attributes_put), - opentelemetry::context::Context{})); + storage.RecordDouble(40.0, + KeyValueIterableView>(attributes_put), + opentelemetry::context::Context{}); expected_total_put_requests += 40; collection_ts = std::chrono::system_clock::now();