From a0e98fb506b1aa4c1a8dc9e903f28646e37f3d22 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 23 Nov 2022 15:46:59 +0100 Subject: [PATCH 1/5] Fix clang-format in CI (#1796) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0dd231c190..208753313e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -413,7 +413,7 @@ jobs: format: name: Format - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - name: setup From 0dc22681f286174e405d4fd851f0782e4d8b9d3a Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 23 Nov 2022 17:52:09 +0100 Subject: [PATCH 2/5] Fix CI build (#1798) --- .github/workflows/ci.yml | 34 +++++++++++++-------------- .github/workflows/codeql-analysis.yml | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 208753313e..580dc10c50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,12 +16,12 @@ jobs: submodules: 'recursive' - name: setup run: | - sudo ./ci/setup_cmake.sh - sudo ./ci/setup_ci_environment.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_cmake.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_ci_environment.sh - name: run cmake tests (without otlp-exporter) run: | - sudo ./ci/setup_thrift.sh - ./ci/do_ci.sh cmake.test + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_thrift.sh + CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/do_ci.sh cmake.test cmake_gcc_maintainer_test: name: CMake gcc (maintainer mode) @@ -78,16 +78,16 @@ jobs: submodules: 'recursive' - name: setup run: | - sudo ./ci/setup_cmake.sh - sudo ./ci/setup_ci_environment.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_cmake.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_ci_environment.sh - name: run cmake tests (without otlp-exporter) run: | - sudo ./ci/setup_thrift.sh - ./ci/do_ci.sh cmake.with_async_export.test + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_thrift.sh + CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/do_ci.sh cmake.with_async_export.test cmake_absel_stl_test: name: CMake test (with abseil) - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 with: @@ -162,7 +162,7 @@ jobs: cmake_otprotocol_test: name: CMake test (with otlp-exporter) - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 with: @@ -185,10 +185,10 @@ jobs: submodules: 'recursive' - name: setup run: | - sudo ./ci/setup_cmake.sh - sudo ./ci/setup_ci_environment.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_cmake.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_ci_environment.sh - name: run tests - run: ./ci/do_ci.sh cmake.test_example_plugin + run: CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/do_ci.sh cmake.test_example_plugin bazel_test: name: Bazel @@ -346,7 +346,7 @@ jobs: bazel_tsan: name: Bazel tsan config - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 with: @@ -493,10 +493,10 @@ jobs: submodules: 'recursive' - name: setup run: | - sudo ./ci/setup_cmake.sh - sudo ./ci/setup_ci_environment.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_cmake.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_ci_environment.sh - name: run tests and generate report - run: ./ci/do_ci.sh code.coverage + run: CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/do_ci.sh code.coverage - name: upload report uses: codecov/codecov-action@v3 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 000a0eb0d0..d86e1d55d2 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -20,8 +20,8 @@ jobs: rm -rf third_party - name: Setup run: | - sudo ./ci/setup_cmake.sh - sudo ./ci/setup_ci_environment.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_cmake.sh + sudo CC=/usr/bin/gcc-10 CXX=/usr/bin/g++-10 ./ci/setup_ci_environment.sh - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: From 6ba1f73b046813e4c993a8414041830bad829d40 Mon Sep 17 00:00:00 2001 From: Ehsan Saei <71217171+esigo@users.noreply.github.com> Date: Wed, 23 Nov 2022 18:50:11 +0100 Subject: [PATCH 3/5] bump to gRPC v1.48.1 for bazel CIs (#1786) --- bazel/repository.bzl | 16 +++++++++++++--- ci/do_ci.sh | 11 ++++++++--- .../otlp/test/otlp_grpc_exporter_benchmark.cc | 5 +++++ exporters/otlp/test/otlp_http_exporter_test.cc | 2 ++ .../test/otlp_http_log_record_exporter_test.cc | 2 ++ .../otlp/test/otlp_http_metric_exporter_test.cc | 2 ++ 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/bazel/repository.bzl b/bazel/repository.bzl index 9900f249fd..81c9b3f470 100644 --- a/bazel/repository.bzl +++ b/bazel/repository.bzl @@ -72,13 +72,23 @@ def opentelemetry_cpp_deps(): ], ) + maybe( + http_archive, + name = "com_github_grpc_grpc_latest11", + sha256 = "e266aa0d9d9cddb876484a370b94f468248594a96ca0b6f87c21f969db2b8c5b", + strip_prefix = "grpc-1.46.4", + urls = [ + "https://github.com/grpc/grpc/archive/v1.46.4.tar.gz", + ], + ) + maybe( http_archive, name = "com_github_grpc_grpc", - sha256 = "b74ce7d26fe187970d1d8e2c06a5d3391122f7bc1fdce569aff5e435fb8fe780", - strip_prefix = "grpc-1.43.2", + sha256 = "320366665d19027cda87b2368c03939006a37e0388bfd1091c8d2a96fbc93bd8", + strip_prefix = "grpc-1.48.1", urls = [ - "https://github.com/grpc/grpc/archive/v1.43.2.tar.gz", + "https://github.com/grpc/grpc/archive/v1.48.1.tar.gz", ], ) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index d457495032..97f5b2b98b 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -25,7 +25,7 @@ function run_benchmarks [ -z "${BENCHMARK_DIR}" ] && export BENCHMARK_DIR=$HOME/benchmark mkdir -p $BENCHMARK_DIR - bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC -c opt -- \ + bazel $BAZEL_STARTUP_OPTIONS build --cxxopt=-std=c++14 $BAZEL_OPTIONS_ASYNC -c opt -- \ $(bazel query 'attr("tags", "benchmark_result", ...)') echo "" echo "Benchmark results in $BENCHMARK_DIR:" @@ -59,7 +59,8 @@ mkdir -p "${BUILD_DIR}" [ -z "${PLUGIN_DIR}" ] && export PLUGIN_DIR=$HOME/plugin mkdir -p "${PLUGIN_DIR}" -BAZEL_OPTIONS="--copt=-DENABLE_LOGS_PREVIEW --copt=-DENABLE_TEST --copt=-DENABLE_METRICS_EXEMPLAR_PREVIEW" +BAZEL_OPTIONS_DEFAULT="--copt=-DENABLE_LOGS_PREVIEW --copt=-DENABLE_TEST --copt=-DENABLE_METRICS_EXEMPLAR_PREVIEW" +BAZEL_OPTIONS="--cxxopt=-std=c++14 $BAZEL_OPTIONS_DEFAULT" BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors" @@ -298,9 +299,13 @@ elif [[ "$1" == "bazel.valgrind" ]]; then bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC //... bazel $BAZEL_STARTUP_OPTIONS test --run_under="/usr/bin/valgrind --leak-check=full --error-exitcode=1 --suppressions=\"${SRC_DIR}/ci/valgrind-suppressions\"" $BAZEL_TEST_OPTIONS_ASYNC //... exit 0 +elif [[ "$1" == "bazel.e2e" ]]; then + cd examples/e2e + bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_DEFAULT //... + exit 0 elif [[ "$1" == "benchmark" ]]; then [ -z "${BENCHMARK_DIR}" ] && export BENCHMARK_DIR=$HOME/benchmark - bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC -c opt -- \ + bazel $BAZEL_STARTUP_OPTIONS build --cxxopt=-std=c++14 $BAZEL_OPTIONS_ASYNC -c opt -- \ $(bazel query 'attr("tags", "benchmark_result", ...)') echo "" echo "Benchmark results in $BENCHMARK_DIR:" diff --git a/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc b/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc index c86f5e53ba..b4a23c04a5 100644 --- a/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc +++ b/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc @@ -187,6 +187,10 @@ BENCHMARK(BM_OtlpExporterDenseSpans); } // namespace exporter OPENTELEMETRY_END_NAMESPACE +#ifdef NDEBUG +// disabled as valgrind reports a memroy leak at absl::lts_20220623::random_internal::(anonymous +// namespace)::PoolAlignedAlloc() +// see PR #1737 namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; @@ -212,5 +216,6 @@ void BM_otlp_grpc_with_collector(benchmark::State &state) } BENCHMARK(BM_otlp_grpc_with_collector); } // namespace +#endif BENCHMARK_MAIN(); diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index 35ae5f50d7..fe2dd37e07 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -21,6 +21,7 @@ # include "opentelemetry/sdk/trace/tracer_provider.h" # include "opentelemetry/trace/provider.h" +# include # include # include "gmock/gmock.h" @@ -466,6 +467,7 @@ TEST_F(OtlpHttpExporterTestPeer, ExportJsonIntegrationTestSync) TEST_F(OtlpHttpExporterTestPeer, ExportJsonIntegrationTestAsync) { ExportJsonIntegrationTestAsync(); + google::protobuf::ShutdownProtobufLibrary(); } # endif diff --git a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc index ca23fb7fe5..e1ab896083 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -26,6 +26,7 @@ # include "opentelemetry/sdk/logs/logger_provider.h" # include "opentelemetry/sdk/resource/resource.h" +# include # include # include "gmock/gmock.h" @@ -507,6 +508,7 @@ TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportJsonIntegrationTestSync) TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportJsonIntegrationTestAsync) { ExportJsonIntegrationTestAsync(); + google::protobuf::ShutdownProtobufLibrary(); } # endif diff --git a/exporters/otlp/test/otlp_http_metric_exporter_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_test.cc index c8ccb8cc8f..7d4f2a1ebd 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_test.cc @@ -23,6 +23,7 @@ #include "opentelemetry/sdk/metrics/instruments.h" #include "opentelemetry/sdk/resource/resource.h" +#include #include #include "gmock/gmock.h" @@ -845,6 +846,7 @@ TEST_F(OtlpHttpMetricExporterTestPeer, ConfigJsonBytesMappingTest) opts.json_bytes_mapping = JsonBytesMappingKind::kHex; std::unique_ptr exporter(new OtlpHttpMetricExporter(opts)); EXPECT_EQ(GetOptions(exporter).json_bytes_mapping, JsonBytesMappingKind::kHex); + google::protobuf::ShutdownProtobufLibrary(); } #ifndef NO_GETENV From c1aa0b80fb8576caff10595a18d2b738976fe811 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 23 Nov 2022 23:28:51 +0100 Subject: [PATCH 4/5] Fix CI benchmark (#1799) --- .github/workflows/benchmark.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 9b5edc2df5..8cebaeaa2a 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -11,7 +11,7 @@ permissions: jobs: benchmark: name: Run OpenTelemetry-cpp benchmarks - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 with: @@ -45,7 +45,7 @@ jobs: matrix: components: ["api", "sdk", "exporters"] name: Store benchmark result - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@master From 3f0eee6b9143d018f907e45d7035e36882f1ecb3 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Wed, 23 Nov 2022 17:01:33 -0800 Subject: [PATCH 5/5] Add option WITH_BENCHMARK to disable building benchmarks (#1794) --- CMakeLists.txt | 8 ++++++-- api/test/baggage/BUILD | 1 + api/test/baggage/CMakeLists.txt | 9 ++++++--- api/test/common/BUILD | 1 + api/test/common/CMakeLists.txt | 8 +++++--- api/test/trace/BUILD | 2 ++ api/test/trace/CMakeLists.txt | 14 ++++++++------ exporters/etw/CMakeLists.txt | 11 ++++++----- exporters/otlp/BUILD | 1 + sdk/test/common/BUILD | 15 ++++++++++++--- sdk/test/common/CMakeLists.txt | 20 +++++++++++--------- sdk/test/instrumentationscope/BUILD | 2 -- sdk/test/metrics/BUILD | 2 ++ sdk/test/metrics/CMakeLists.txt | 15 +++++++++------ sdk/test/trace/BUILD | 1 + sdk/test/trace/CMakeLists.txt | 11 +++++++---- 16 files changed, 78 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e3e0d5dd6..1050ede90e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,8 @@ option(WITH_NO_GETENV "Whether the platform supports environment variables" OFF) option(BUILD_TESTING "Whether to enable tests" ON) +option(WITH_BENCHMARK "Whether to build benchmark program" ON) + option(BUILD_W3CTRACECONTEXT_TEST "Whether to build w3c trace context" OFF) option(OTELCPP_MAINTAINER_MODE "Build in maintainer mode (-Wall -Werror)" OFF) @@ -478,8 +480,10 @@ if(BUILD_TESTING) message("GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}") message("GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}") enable_testing() - # Benchmark respects the CMAKE_PREFIX_PATH - find_package(benchmark CONFIG REQUIRED) + if(WITH_BENCHMARK) + # Benchmark respects the CMAKE_PREFIX_PATH + find_package(benchmark CONFIG REQUIRED) + endif() endif() include(CMakePackageConfigHelpers) diff --git a/api/test/baggage/BUILD b/api/test/baggage/BUILD index 7c021f46e7..a6a4ae2165 100644 --- a/api/test/baggage/BUILD +++ b/api/test/baggage/BUILD @@ -20,6 +20,7 @@ otel_cc_benchmark( srcs = ["baggage_benchmark.cc"], tags = [ "api", + "benchmark", "test", ], deps = ["//api"], diff --git a/api/test/baggage/CMakeLists.txt b/api/test/baggage/CMakeLists.txt index 0d6cba5a0d..cb58f169fb 100644 --- a/api/test/baggage/CMakeLists.txt +++ b/api/test/baggage/CMakeLists.txt @@ -9,7 +9,10 @@ foreach(testname baggage_test) TEST_PREFIX baggage. TEST_LIST ${testname}) endforeach() -add_executable(baggage_benchmark baggage_benchmark.cc) -target_link_libraries(baggage_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) + +if(WITH_BENCHMARK) + add_executable(baggage_benchmark baggage_benchmark.cc) + target_link_libraries(baggage_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +endif() add_subdirectory(propagation) diff --git a/api/test/common/BUILD b/api/test/common/BUILD index 5bfc1115d7..438a9bbf6e 100644 --- a/api/test/common/BUILD +++ b/api/test/common/BUILD @@ -5,6 +5,7 @@ otel_cc_benchmark( srcs = ["spinlock_benchmark.cc"], tags = [ "api", + "benchmark", "test", ], deps = ["//api"], diff --git a/api/test/common/CMakeLists.txt b/api/test/common/CMakeLists.txt index 5816b64b1a..330a7765aa 100644 --- a/api/test/common/CMakeLists.txt +++ b/api/test/common/CMakeLists.txt @@ -10,6 +10,8 @@ foreach(testname kv_properties_test string_util_test) TEST_LIST ${testname}) endforeach() -add_executable(spinlock_benchmark spinlock_benchmark.cc) -target_link_libraries(spinlock_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +if(WITH_BENCHMARK) + add_executable(spinlock_benchmark spinlock_benchmark.cc) + target_link_libraries(spinlock_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +endif() diff --git a/api/test/trace/BUILD b/api/test/trace/BUILD index a9b5b01700..60d5c9f02c 100644 --- a/api/test/trace/BUILD +++ b/api/test/trace/BUILD @@ -53,6 +53,7 @@ otel_cc_benchmark( srcs = ["span_id_benchmark.cc"], tags = [ "api", + "benchmark", "test", "trace", ], @@ -64,6 +65,7 @@ otel_cc_benchmark( srcs = ["span_benchmark.cc"], tags = [ "api", + "benchmark", "test", "trace", ], diff --git a/api/test/trace/CMakeLists.txt b/api/test/trace/CMakeLists.txt index 09d2c12d88..0e2d6631d3 100644 --- a/api/test/trace/CMakeLists.txt +++ b/api/test/trace/CMakeLists.txt @@ -21,9 +21,11 @@ foreach( TEST_LIST api_${testname}) endforeach() -add_executable(span_id_benchmark span_id_benchmark.cc) -target_link_libraries(span_id_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) -add_executable(span_benchmark span_benchmark.cc) -target_link_libraries(span_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +if(WITH_BENCHMARK) + add_executable(span_id_benchmark span_id_benchmark.cc) + target_link_libraries(span_id_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) + add_executable(span_benchmark span_benchmark.cc) + target_link_libraries(span_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +endif() diff --git a/exporters/etw/CMakeLists.txt b/exporters/etw/CMakeLists.txt index fbcec8144f..7b092155f2 100644 --- a/exporters/etw/CMakeLists.txt +++ b/exporters/etw/CMakeLists.txt @@ -32,8 +32,6 @@ if(BUILD_TESTING) add_executable(etw_tracer_test test/etw_tracer_test.cc) add_executable(etw_logger_test test/etw_logger_test.cc) - add_executable(etw_perf_test test/etw_perf_test.cc) - target_link_libraries(etw_provider_test ${GTEST_BOTH_LIBRARIES} opentelemetry_exporter_etw ${CMAKE_THREAD_LIBS_INIT}) @@ -43,9 +41,12 @@ if(BUILD_TESTING) target_link_libraries(etw_logger_test ${GTEST_BOTH_LIBRARIES} opentelemetry_exporter_etw ${CMAKE_THREAD_LIBS_INIT}) - target_link_libraries( - etw_perf_test benchmark::benchmark ${GTEST_BOTH_LIBRARIES} - opentelemetry_exporter_etw ${CMAKE_THREAD_LIBS_INIT}) + if(WITH_BENCHMARK) + add_executable(etw_perf_test test/etw_perf_test.cc) + target_link_libraries( + etw_perf_test benchmark::benchmark ${GTEST_BOTH_LIBRARIES} + opentelemetry_exporter_etw ${CMAKE_THREAD_LIBS_INIT}) + endif() gtest_add_tests( TARGET etw_provider_test diff --git a/exporters/otlp/BUILD b/exporters/otlp/BUILD index 04f922f1d8..b2667eca9c 100644 --- a/exporters/otlp/BUILD +++ b/exporters/otlp/BUILD @@ -487,6 +487,7 @@ otel_cc_benchmark( name = "otlp_grpc_exporter_benchmark", srcs = ["test/otlp_grpc_exporter_benchmark.cc"], tags = [ + "benchmark", "otlp", "otlp_grpc", "test", diff --git a/sdk/test/common/BUILD b/sdk/test/common/BUILD index 91d56996fb..08ecb0bc8a 100644 --- a/sdk/test/common/BUILD +++ b/sdk/test/common/BUILD @@ -27,7 +27,10 @@ cc_test( otel_cc_benchmark( name = "random_benchmark", srcs = ["random_benchmark.cc"], - tags = ["test"], + tags = [ + "benchmark", + "test", + ], deps = ["//sdk/src/common:random"], ) @@ -82,7 +85,10 @@ cc_library( otel_cc_benchmark( name = "circular_buffer_benchmark", srcs = ["circular_buffer_benchmark.cc"], - tags = ["test"], + tags = [ + "benchmark", + "test", + ], deps = [ ":baseline_circular_buffer", "//sdk:headers", @@ -145,7 +151,10 @@ cc_test( otel_cc_benchmark( name = "attributemap_hash_benchmark", srcs = ["attributemap_hash_benchmark.cc"], - tags = ["test"], + tags = [ + "benchmark", + "test", + ], deps = [ "//api", "//sdk:headers", diff --git a/sdk/test/common/CMakeLists.txt b/sdk/test/common/CMakeLists.txt index 0fefc86b10..a2a81ecc5a 100644 --- a/sdk/test/common/CMakeLists.txt +++ b/sdk/test/common/CMakeLists.txt @@ -24,14 +24,16 @@ add_executable(random_fork_test random_fork_test.cc) target_link_libraries(random_fork_test opentelemetry_common) add_test(random_fork_test random_fork_test) -add_executable(random_benchmark random_benchmark.cc) -target_link_libraries(random_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common) +if(WITH_BENCHMARK) + add_executable(random_benchmark random_benchmark.cc) + target_link_libraries(random_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common) -add_executable(circular_buffer_benchmark circular_buffer_benchmark.cc) -target_link_libraries(circular_buffer_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) + add_executable(circular_buffer_benchmark circular_buffer_benchmark.cc) + target_link_libraries(circular_buffer_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) -add_executable(attributemap_hash_benchmark attributemap_hash_benchmark.cc) -target_link_libraries(attributemap_hash_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common) + add_executable(attributemap_hash_benchmark attributemap_hash_benchmark.cc) + target_link_libraries(attributemap_hash_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common) +endif() diff --git a/sdk/test/instrumentationscope/BUILD b/sdk/test/instrumentationscope/BUILD index 5ee93f120e..0dd54ab648 100644 --- a/sdk/test/instrumentationscope/BUILD +++ b/sdk/test/instrumentationscope/BUILD @@ -1,5 +1,3 @@ -load("//bazel:otel_cc_benchmark.bzl", "otel_cc_benchmark") - cc_test( name = "instrumentationscope_test", srcs = [ diff --git a/sdk/test/metrics/BUILD b/sdk/test/metrics/BUILD index 333670dc6f..294510b571 100644 --- a/sdk/test/metrics/BUILD +++ b/sdk/test/metrics/BUILD @@ -242,6 +242,7 @@ otel_cc_benchmark( "attributes_processor_benchmark.cc", ], tags = [ + "benchmark", "metrics", "test", ], @@ -256,6 +257,7 @@ otel_cc_benchmark( "attributes_hashmap_benchmark.cc", ], tags = [ + "benchmark", "metrics", "test", ], diff --git a/sdk/test/metrics/CMakeLists.txt b/sdk/test/metrics/CMakeLists.txt index 3e5e8f488a..2acbc6bd18 100644 --- a/sdk/test/metrics/CMakeLists.txt +++ b/sdk/test/metrics/CMakeLists.txt @@ -28,12 +28,15 @@ foreach( TEST_LIST ${testname}) endforeach() -add_executable(attributes_processor_benchmark attributes_processor_benchmark.cc) -target_link_libraries(attributes_processor_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common) +if(WITH_BENCHMARK) + add_executable(attributes_processor_benchmark + attributes_processor_benchmark.cc) + target_link_libraries(attributes_processor_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common) -add_executable(attributes_hashmap_benchmark attributes_hashmap_benchmark.cc) -target_link_libraries(attributes_hashmap_benchmark benchmark::benchmark - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common) + add_executable(attributes_hashmap_benchmark attributes_hashmap_benchmark.cc) + target_link_libraries(attributes_hashmap_benchmark benchmark::benchmark + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_common) +endif() add_subdirectory(exemplar) diff --git a/sdk/test/trace/BUILD b/sdk/test/trace/BUILD index 70e517684c..c00b91484a 100644 --- a/sdk/test/trace/BUILD +++ b/sdk/test/trace/BUILD @@ -144,6 +144,7 @@ otel_cc_benchmark( name = "sampler_benchmark", srcs = ["sampler_benchmark.cc"], tags = [ + "benchmark", "test", "trace", ], diff --git a/sdk/test/trace/CMakeLists.txt b/sdk/test/trace/CMakeLists.txt index b02ff705fa..1e66704e2f 100644 --- a/sdk/test/trace/CMakeLists.txt +++ b/sdk/test/trace/CMakeLists.txt @@ -24,7 +24,10 @@ foreach( TEST_LIST ${testname}) endforeach() -add_executable(sampler_benchmark sampler_benchmark.cc) -target_link_libraries( - sampler_benchmark benchmark::benchmark ${CMAKE_THREAD_LIBS_INIT} - opentelemetry_trace opentelemetry_resources opentelemetry_exporter_in_memory) +if(WITH_BENCHMARK) + add_executable(sampler_benchmark sampler_benchmark.cc) + target_link_libraries( + sampler_benchmark benchmark::benchmark ${CMAKE_THREAD_LIBS_INIT} + opentelemetry_trace opentelemetry_resources + opentelemetry_exporter_in_memory) +endif()