From 740034919cc76f0e1ec11bec5b90c25548d35e3f Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Tue, 20 Sep 2022 21:33:17 +0200 Subject: [PATCH] Fixes issue #1612. --- sdk/test/trace/sampler_benchmark.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index 39bebe03fd..17999dcf26 100644 --- a/sdk/test/trace/sampler_benchmark.cc +++ b/sdk/test/trace/sampler_benchmark.cc @@ -118,16 +118,16 @@ void BM_TraceIdRatioBasedSamplerShouldSample(benchmark::State &state) BENCHMARK(BM_TraceIdRatioBasedSamplerShouldSample); // Sampler Helper Function -void BenchmarkSpanCreation(std::shared_ptr /* TODO: fix issue #1612 sampler */, - benchmark::State &state) +void BenchmarkSpanCreation(std::unique_ptr &&sampler, benchmark::State &state) { std::unique_ptr exporter(new InMemorySpanExporter()); std::unique_ptr processor(new SimpleSpanProcessor(std::move(exporter))); std::vector> processors; processors.push_back(std::move(processor)); - auto context = std::make_shared(std::move(processors)); auto resource = opentelemetry::sdk::resource::Resource::Create({}); - auto tracer = std::shared_ptr(new Tracer(context)); + auto context = + std::make_shared(std::move(processors), resource, std::move(sampler)); + auto tracer = std::shared_ptr(new Tracer(context)); while (state.KeepRunning()) { @@ -142,14 +142,16 @@ void BenchmarkSpanCreation(std::shared_ptr /* TODO: fix issue #1612 sam // Test to measure performance for span creation void BM_SpanCreation(benchmark::State &state) { - BenchmarkSpanCreation(std::move(std::make_shared()), state); + std::unique_ptr sampler(new AlwaysOnSampler()); + BenchmarkSpanCreation(std::move(sampler), state); } BENCHMARK(BM_SpanCreation); // Test to measure performance overhead for no-op span creation void BM_NoopSpanCreation(benchmark::State &state) { - BenchmarkSpanCreation(std::move(std::make_shared()), state); + std::unique_ptr sampler(new AlwaysOffSampler()); + BenchmarkSpanCreation(std::move(sampler), state); } BENCHMARK(BM_NoopSpanCreation);