diff --git a/sdk/test/metrics/sync_instruments_test.cc b/sdk/test/metrics/sync_instruments_test.cc index 0747115bab..a1ff2325e2 100644 --- a/sdk/test/metrics/sync_instruments_test.cc +++ b/sdk/test/metrics/sync_instruments_test.cc @@ -98,15 +98,15 @@ TEST(SyncInstruments, LongHistogram) InstrumentDescriptor instrument_descriptor = { "long_histogram", "description", "1", InstrumentType::kHistogram, InstrumentValueType::kLong}; std::unique_ptr metric_storage(new SyncMultiMetricStorage()); - LongHistogram counter(instrument_descriptor, std::move(metric_storage)); - counter.Record(10, opentelemetry::context::Context{}); - counter.Record(-10, opentelemetry::context::Context{}); // This is ignored - - counter.Record(10, - opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), - opentelemetry::context::Context{}); - counter.Record(10, opentelemetry::common::KeyValueIterableView({}), - opentelemetry::context::Context{}); + LongHistogram histogram(instrument_descriptor, std::move(metric_storage)); + histogram.Record(10, opentelemetry::context::Context{}); + histogram.Record(-10, opentelemetry::context::Context{}); // This is ignored + + histogram.Record(10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + histogram.Record(10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); } TEST(SyncInstruments, DoubleHistogram) @@ -115,17 +115,17 @@ TEST(SyncInstruments, DoubleHistogram) InstrumentType::kHistogram, InstrumentValueType::kDouble}; std::unique_ptr metric_storage(new SyncMultiMetricStorage()); - DoubleHistogram counter(instrument_descriptor, std::move(metric_storage)); - 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{}); + DoubleHistogram histogram(instrument_descriptor, std::move(metric_storage)); + histogram.Record(10.10, opentelemetry::context::Context{}); + histogram.Record(-10.10, opentelemetry::context::Context{}); // This is ignored. + histogram.Record(std::numeric_limits::quiet_NaN(), + opentelemetry::context::Context{}); // This is ignored too + histogram.Record(std::numeric_limits::infinity(), + opentelemetry::context::Context{}); // This is ignored too + + histogram.Record(10.10, + opentelemetry::common::KeyValueIterableView({{"abc", "123"}, {"xyz", "456"}}), + opentelemetry::context::Context{}); + histogram.Record(10.10, opentelemetry::common::KeyValueIterableView({}), + opentelemetry::context::Context{}); }