diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index a5f5121e38..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::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::make_shared(), state); + std::unique_ptr sampler(new AlwaysOffSampler()); + BenchmarkSpanCreation(std::move(sampler), state); } BENCHMARK(BM_NoopSpanCreation);