Skip to content

Commit

Permalink
[BUILD] Remove std::make_unique (#3098)
Browse files Browse the repository at this point in the history
  • Loading branch information
owent authored Oct 16, 2024
1 parent f69963f commit 70ed9bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions exporters/memory/src/in_memory_metric_exporter_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResourceMetrics>(data));
data_->Add(std::unique_ptr<ResourceMetrics>(new ResourceMetrics{data}));
return ExportResult::kSuccess;
}

Expand Down Expand Up @@ -85,7 +85,7 @@ std::unique_ptr<PushMetricExporter> InMemoryMetricExporterFactory::Create(
const std::shared_ptr<InMemoryMetricData> &data,
const AggregationTemporalitySelector &temporality)
{
return std::make_unique<InMemoryMetricExporter>(data, temporality);
return std::unique_ptr<InMemoryMetricExporter>(new InMemoryMetricExporter{data, temporality});
}

} // namespace memory
Expand Down
8 changes: 4 additions & 4 deletions exporters/memory/test/in_memory_metric_data_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ TEST(InMemoryMetricDataTest, CircularBuffer)
{
CircularBufferInMemoryMetricData buf(10);
Resource resource = Resource::GetEmpty();
buf.Add(std::make_unique<ResourceMetrics>(
&resource, std::vector<ScopeMetrics>{{nullptr, std::vector<MetricData>{}}}));
buf.Add(std::unique_ptr<ResourceMetrics>(new ResourceMetrics{
&resource, std::vector<ScopeMetrics>{{nullptr, std::vector<MetricData>{}}}}));
EXPECT_EQ((*buf.Get().begin())->resource_, &resource);
}

Expand All @@ -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<ResourceMetrics>(
&resource, std::vector<ScopeMetrics>{{scope.get(), std::vector<MetricData>{md}}}));
agg.Add(std::unique_ptr<ResourceMetrics>(new ResourceMetrics{
&resource, std::vector<ScopeMetrics>{{scope.get(), std::vector<MetricData>{md}}}}));
auto it = agg.Get("my-scope", "my-metric").begin();

auto saved_point = opentelemetry::nostd::get<SumPointData>(it->second);
Expand Down

1 comment on commit 70ed9bc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp api Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 70ed9bc Previous: f69963f Ratio
BM_SpinLockThrashing/2/process_time/real_time 0.3815373525362824 ms/iter 0.17002592941173342 ms/iter 2.24
BM_SpinLockThrashing/4/process_time/real_time 1.6223771231515067 ms/iter 0.6469004225022722 ms/iter 2.51
BM_ProcYieldSpinLockThrashing/2/process_time/real_time 0.45858356022155866 ms/iter 0.1700145682108771 ms/iter 2.70
BM_ProcYieldSpinLockThrashing/4/process_time/real_time 1.4384677729655786 ms/iter 0.7172716726170908 ms/iter 2.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.