From fd07a0fcf2235dced172c32408ffc0ca26293b00 Mon Sep 17 00:00:00 2001 From: owent Date: Wed, 16 Oct 2024 16:09:55 +0800 Subject: [PATCH] Fixes 3096 --- exporters/memory/src/in_memory_metric_exporter_factory.cc | 4 ++-- exporters/memory/test/in_memory_metric_data_test.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/exporters/memory/src/in_memory_metric_exporter_factory.cc b/exporters/memory/src/in_memory_metric_exporter_factory.cc index f2577c4e9b..7f6ab83346 100644 --- a/exporters/memory/src/in_memory_metric_exporter_factory.cc +++ b/exporters/memory/src/in_memory_metric_exporter_factory.cc @@ -49,7 +49,7 @@ class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter OTEL_INTERNAL_LOG_ERROR("[In Memory Metric Exporter] Exporting failed, exporter is shutdown"); return ExportResult::kFailure; } - data_->Add(std::make_unique(data)); + data_->Add(std::unique_ptr(new ResourceMetrics{data})); return ExportResult::kSuccess; } @@ -85,7 +85,7 @@ std::unique_ptr InMemoryMetricExporterFactory::Create( const std::shared_ptr &data, const AggregationTemporalitySelector &temporality) { - return std::make_unique(data, temporality); + return std::unique_ptr(new InMemoryMetricExporter{data, temporality}); } } // namespace memory diff --git a/exporters/memory/test/in_memory_metric_data_test.cc b/exporters/memory/test/in_memory_metric_data_test.cc index ffaba2cfb9..3f2d661759 100644 --- a/exporters/memory/test/in_memory_metric_data_test.cc +++ b/exporters/memory/test/in_memory_metric_data_test.cc @@ -23,8 +23,8 @@ TEST(InMemoryMetricDataTest, CircularBuffer) { CircularBufferInMemoryMetricData buf(10); Resource resource = Resource::GetEmpty(); - buf.Add(std::make_unique( - &resource, std::vector{{nullptr, std::vector{}}})); + buf.Add(std::unique_ptr(new ResourceMetrics{ + &resource, std::vector{{nullptr, std::vector{}}}})); EXPECT_EQ((*buf.Get().begin())->resource_, &resource); } @@ -45,8 +45,8 @@ TEST(InMemoryMetricDataTest, SimpleAggregate) md.instrument_descriptor.name_ = "my-metric"; md.point_data_attr_.push_back(pda); - agg.Add(std::make_unique( - &resource, std::vector{{scope.get(), std::vector{md}}})); + agg.Add(std::unique_ptr(new ResourceMetrics{ + &resource, std::vector{{scope.get(), std::vector{md}}}})); auto it = agg.Get("my-scope", "my-metric").begin(); auto saved_point = opentelemetry::nostd::get(it->second);