From d97e16493ffac6dbb05cac87e6640ea0c812e2b8 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 9 Oct 2023 16:06:04 +0200 Subject: [PATCH 1/3] Fixes #2343 --- sdk/test/trace/sampler_benchmark.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index 42de190980..ec188b84a1 100644 --- a/sdk/test/trace/sampler_benchmark.cc +++ b/sdk/test/trace/sampler_benchmark.cc @@ -42,6 +42,11 @@ void BM_AlwaysOnSamplerConstruction(benchmark::State &state) } BENCHMARK(BM_AlwaysOnSamplerConstruction); +/* + Fails to build with GCC. + See upstream bug: https://github.com/google/benchmark/issues/1675 +*/ +#if 0 void BM_ParentBasedSamplerConstruction(benchmark::State &state) { while (state.KeepRunning()) @@ -59,6 +64,7 @@ void BM_TraceIdRatioBasedSamplerConstruction(benchmark::State &state) } } BENCHMARK(BM_TraceIdRatioBasedSamplerConstruction); +#endif // Sampler Helper Function void BenchmarkShouldSampler(Sampler &sampler, benchmark::State &state) From ae1fdad633412f9cdf9bf0cb603cb607386a6218 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 9 Oct 2023 17:31:41 +0200 Subject: [PATCH 2/3] Fixed root cause instead. --- sdk/include/opentelemetry/sdk/trace/samplers/parent.h | 4 ++-- .../opentelemetry/sdk/trace/samplers/trace_id_ratio.h | 2 +- sdk/test/trace/sampler_benchmark.cc | 6 ------ 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h index 59dd314589..0561364625 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h @@ -52,8 +52,8 @@ class ParentBasedSampler : public Sampler nostd::string_view GetDescription() const noexcept override; private: - const std::shared_ptr delegate_sampler_; - const std::string description_; + std::shared_ptr delegate_sampler_; + std::string description_; }; } // namespace trace } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h index b5df576091..a6e2983fac 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h @@ -64,7 +64,7 @@ class TraceIdRatioBasedSampler : public Sampler private: std::string description_; - const uint64_t threshold_; + uint64_t threshold_; }; } // namespace trace } // namespace sdk diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index ec188b84a1..42de190980 100644 --- a/sdk/test/trace/sampler_benchmark.cc +++ b/sdk/test/trace/sampler_benchmark.cc @@ -42,11 +42,6 @@ void BM_AlwaysOnSamplerConstruction(benchmark::State &state) } BENCHMARK(BM_AlwaysOnSamplerConstruction); -/* - Fails to build with GCC. - See upstream bug: https://github.com/google/benchmark/issues/1675 -*/ -#if 0 void BM_ParentBasedSamplerConstruction(benchmark::State &state) { while (state.KeepRunning()) @@ -64,7 +59,6 @@ void BM_TraceIdRatioBasedSamplerConstruction(benchmark::State &state) } } BENCHMARK(BM_TraceIdRatioBasedSamplerConstruction); -#endif // Sampler Helper Function void BenchmarkShouldSampler(Sampler &sampler, benchmark::State &state) From ed663528b81ba5c29e4fd28a15e505dfe23a0d30 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 9 Oct 2023 21:32:26 +0200 Subject: [PATCH 3/3] Revert, back to solution 1. --- sdk/include/opentelemetry/sdk/trace/samplers/parent.h | 4 ++-- .../opentelemetry/sdk/trace/samplers/trace_id_ratio.h | 2 +- sdk/test/trace/sampler_benchmark.cc | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h index 0561364625..59dd314589 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h @@ -52,8 +52,8 @@ class ParentBasedSampler : public Sampler nostd::string_view GetDescription() const noexcept override; private: - std::shared_ptr delegate_sampler_; - std::string description_; + const std::shared_ptr delegate_sampler_; + const std::string description_; }; } // namespace trace } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h index a6e2983fac..b5df576091 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h @@ -64,7 +64,7 @@ class TraceIdRatioBasedSampler : public Sampler private: std::string description_; - uint64_t threshold_; + const uint64_t threshold_; }; } // namespace trace } // namespace sdk diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index 42de190980..ec188b84a1 100644 --- a/sdk/test/trace/sampler_benchmark.cc +++ b/sdk/test/trace/sampler_benchmark.cc @@ -42,6 +42,11 @@ void BM_AlwaysOnSamplerConstruction(benchmark::State &state) } BENCHMARK(BM_AlwaysOnSamplerConstruction); +/* + Fails to build with GCC. + See upstream bug: https://github.com/google/benchmark/issues/1675 +*/ +#if 0 void BM_ParentBasedSamplerConstruction(benchmark::State &state) { while (state.KeepRunning()) @@ -59,6 +64,7 @@ void BM_TraceIdRatioBasedSamplerConstruction(benchmark::State &state) } } BENCHMARK(BM_TraceIdRatioBasedSamplerConstruction); +#endif // Sampler Helper Function void BenchmarkShouldSampler(Sampler &sampler, benchmark::State &state)