Skip to content

Commit

Permalink
Merge branch 'main' into bazel_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Nov 24, 2022
2 parents 3e483a4 + 3f0eee6 commit 9ae4a9e
Show file tree
Hide file tree
Showing 25 changed files with 132 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -413,7 +413,7 @@ jobs:

format:
name: Format
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: setup
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions api/test/baggage/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ otel_cc_benchmark(
srcs = ["baggage_benchmark.cc"],
tags = [
"api",
"benchmark",
"test",
],
deps = ["//api"],
Expand Down
9 changes: 6 additions & 3 deletions api/test/baggage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions api/test/common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ otel_cc_benchmark(
srcs = ["spinlock_benchmark.cc"],
tags = [
"api",
"benchmark",
"test",
],
deps = ["//api"],
Expand Down
8 changes: 5 additions & 3 deletions api/test/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 2 additions & 0 deletions api/test/trace/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ otel_cc_benchmark(
srcs = ["span_id_benchmark.cc"],
tags = [
"api",
"benchmark",
"test",
"trace",
],
Expand All @@ -64,6 +65,7 @@ otel_cc_benchmark(
srcs = ["span_benchmark.cc"],
tags = [
"api",
"benchmark",
"test",
"trace",
],
Expand Down
14 changes: 8 additions & 6 deletions api/test/trace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
16 changes: 13 additions & 3 deletions bazel/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand Down
11 changes: 8 additions & 3 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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:"
Expand Down
11 changes: 6 additions & 5 deletions exporters/etw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions exporters/otlp/test/otlp_grpc_exporter_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -212,5 +216,6 @@ void BM_otlp_grpc_with_collector(benchmark::State &state)
}
BENCHMARK(BM_otlp_grpc_with_collector);
} // namespace
#endif

BENCHMARK_MAIN();
2 changes: 2 additions & 0 deletions exporters/otlp/test/otlp_http_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# include "opentelemetry/sdk/trace/tracer_provider.h"
# include "opentelemetry/trace/provider.h"

# include <google/protobuf/message_lite.h>
# include <gtest/gtest.h>
# include "gmock/gmock.h"

Expand Down Expand Up @@ -466,6 +467,7 @@ TEST_F(OtlpHttpExporterTestPeer, ExportJsonIntegrationTestSync)
TEST_F(OtlpHttpExporterTestPeer, ExportJsonIntegrationTestAsync)
{
ExportJsonIntegrationTestAsync();
google::protobuf::ShutdownProtobufLibrary();
}
# endif

Expand Down
2 changes: 2 additions & 0 deletions exporters/otlp/test/otlp_http_log_record_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# include "opentelemetry/sdk/logs/logger_provider.h"
# include "opentelemetry/sdk/resource/resource.h"

# include <google/protobuf/message_lite.h>
# include <gtest/gtest.h>
# include "gmock/gmock.h"

Expand Down Expand Up @@ -507,6 +508,7 @@ TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportJsonIntegrationTestSync)
TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportJsonIntegrationTestAsync)
{
ExportJsonIntegrationTestAsync();
google::protobuf::ShutdownProtobufLibrary();
}
# endif

Expand Down
2 changes: 2 additions & 0 deletions exporters/otlp/test/otlp_http_metric_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "opentelemetry/sdk/metrics/instruments.h"
#include "opentelemetry/sdk/resource/resource.h"

#include <google/protobuf/message_lite.h>
#include <gtest/gtest.h>
#include "gmock/gmock.h"

Expand Down Expand Up @@ -845,6 +846,7 @@ TEST_F(OtlpHttpMetricExporterTestPeer, ConfigJsonBytesMappingTest)
opts.json_bytes_mapping = JsonBytesMappingKind::kHex;
std::unique_ptr<OtlpHttpMetricExporter> exporter(new OtlpHttpMetricExporter(opts));
EXPECT_EQ(GetOptions(exporter).json_bytes_mapping, JsonBytesMappingKind::kHex);
google::protobuf::ShutdownProtobufLibrary();
}

#ifndef NO_GETENV
Expand Down
Loading

0 comments on commit 9ae4a9e

Please sign in to comment.