Skip to content

Commit

Permalink
Merge branch 'main' into ImproveCompression
Browse files Browse the repository at this point in the history
  • Loading branch information
chusitoo authored Dec 17, 2024
2 parents 34bd0bd + 902ee88 commit fadff90
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 102 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ jobs:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
run: |
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
- name: run cmake tests (without otlp-exporter)
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
run: |
./ci/do_ci.sh cmake.test
Expand Down Expand Up @@ -263,15 +263,15 @@ jobs:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
run: |
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
- name: run cmake tests (without otlp-exporter)
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
run: |
./ci/do_ci.sh cmake.with_async_export.test
Expand Down Expand Up @@ -359,7 +359,7 @@ jobs:

cmake_test_cxx20_clang:
name: CMake C++20 test(Clang with libc++)
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -409,7 +409,7 @@ jobs:

cmake_test_cxx23_clang:
name: CMake C++23 test(Clang with libc++)
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -538,15 +538,15 @@ jobs:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
run: |
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
- name: run tests
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
run: ./ci/do_ci.sh cmake.test_example_plugin

bazel_test:
Expand Down Expand Up @@ -858,7 +858,7 @@ jobs:

code_coverage:
name: Code coverage
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -936,8 +936,8 @@ jobs:
submodules: 'recursive'
- name: setup
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
run: |
sudo -E ./ci/setup_googletest.sh
sudo -E ./ci/setup_ci_environment.sh
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
env:
CC: /usr/bin/gcc-10
CXX: /usr/bin/g++-10
CC: /usr/bin/gcc-12
CXX: /usr/bin/g++-12
GOOGLETEST_VERSION: 1.12.1
run: |
sudo -E ./ci/setup_googletest.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log`
echo "include-what-you-use reported ${WARNING_COUNT} warning(s)"
# Acceptable limit, to decrease over time down to 0
readonly WARNING_LIMIT=10
readonly WARNING_LIMIT=180
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
exit 1
Expand Down
106 changes: 50 additions & 56 deletions api/test/singleton/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,53 @@

include(GoogleTest)

# Header only singletons are not available in windows yet.

if(NOT WIN32)

add_library(component_a STATIC component_a.cc)
target_link_libraries(component_a opentelemetry_api)

add_library(component_b STATIC component_b.cc)
target_link_libraries(component_b opentelemetry_api)

add_library(component_c SHARED component_c.cc)
set_target_properties(component_c PROPERTIES CXX_VISIBILITY_PRESET default)
target_link_libraries(component_c opentelemetry_api)

add_library(component_d SHARED component_d.cc)
set_target_properties(component_d PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_libraries(component_d opentelemetry_api)

add_library(component_e SHARED component_e.cc)
set_target_properties(component_e PROPERTIES CXX_VISIBILITY_PRESET default)
target_link_libraries(component_e opentelemetry_api)

add_library(component_f SHARED component_f.cc)
set_target_properties(component_f PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_libraries(component_f opentelemetry_api)

add_library(component_g SHARED component_g.cc)
set_target_properties(component_g PROPERTIES CXX_VISIBILITY_PRESET default)
target_link_libraries(component_g opentelemetry_api)

add_library(component_h SHARED component_h.cc)
set_target_properties(component_h PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_libraries(component_h opentelemetry_api)

add_executable(singleton_test singleton_test.cc)

# Not linking with component_g and component_h on purpose
target_link_libraries(
singleton_test
component_a
component_b
component_c
component_d
component_e
component_f
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
opentelemetry_api)

gtest_add_tests(
TARGET singleton_test
TEST_PREFIX singleton.
TEST_LIST singleton_test)

endif()
add_library(component_a STATIC component_a.cc)
target_link_libraries(component_a opentelemetry_api)

add_library(component_b STATIC component_b.cc)
target_link_libraries(component_b opentelemetry_api)

add_library(component_c SHARED component_c.cc)
set_target_properties(component_c PROPERTIES CXX_VISIBILITY_PRESET default)
target_link_libraries(component_c opentelemetry_api)

add_library(component_d SHARED component_d.cc)
set_target_properties(component_d PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_libraries(component_d opentelemetry_api)

add_library(component_e SHARED component_e.cc)
set_target_properties(component_e PROPERTIES CXX_VISIBILITY_PRESET default)
target_link_libraries(component_e opentelemetry_api)

add_library(component_f SHARED component_f.cc)
set_target_properties(component_f PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_libraries(component_f opentelemetry_api)

add_library(component_g SHARED component_g.cc)
set_target_properties(component_g PROPERTIES CXX_VISIBILITY_PRESET default)
target_link_libraries(component_g opentelemetry_api)

add_library(component_h SHARED component_h.cc)
set_target_properties(component_h PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_libraries(component_h opentelemetry_api)

add_executable(singleton_test singleton_test.cc)

# Not linking with component_g and component_h on purpose
target_link_libraries(
singleton_test
component_a
component_b
component_c
component_d
component_e
component_f
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
opentelemetry_api)

gtest_add_tests(
TARGET singleton_test
TEST_PREFIX singleton.
TEST_LIST singleton_test)
89 changes: 64 additions & 25 deletions api/test/singleton/singleton_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
#include <gtest/gtest.h>
#include <stdint.h>

/*
TODO:
Once singleton are supported for windows,
expand this test to use ::LoadLibrary, ::GetProcAddress, ::FreeLibrary
*/
#ifndef _WIN32
#ifdef _WIN32
# include <windows.h>
#else
# include <dlfcn.h>
#endif

Expand Down Expand Up @@ -58,28 +55,57 @@ void do_something()
#ifndef BAZEL_BUILD
/* Call do_something_in_g() */

# ifdef _WIN32
HMODULE component_g = LoadLibraryA("component_g.dll");
# else
void *component_g = dlopen("libcomponent_g.so", RTLD_NOW);
# endif

EXPECT_NE(component_g, nullptr);

# ifdef _WIN32
auto *func_g = reinterpret_cast<void (*)()>(GetProcAddress(component_g, "do_something_in_g"));
# else
auto *func_g = reinterpret_cast<void (*)()>(dlsym(component_g, "do_something_in_g"));
# endif

EXPECT_NE(func_g, nullptr);

(*func_g)();

# ifdef _WIN32
FreeLibrary(component_g);
# else
dlclose(component_g);
# endif

/* Call do_something_in_h() */

# ifdef _WIN32
HMODULE component_h = LoadLibraryA("component_h.dll");
# else
void *component_h = dlopen("libcomponent_h.so", RTLD_NOW);
# endif

EXPECT_NE(component_h, nullptr);

# ifdef _WIN32
auto *func_h = reinterpret_cast<void (*)()>(GetProcAddress(component_h, "do_something_in_h"));
# else
auto *func_h = reinterpret_cast<void (*)()>(dlsym(component_h, "do_something_in_h"));
# endif

EXPECT_NE(func_h, nullptr);

(*func_h)();

# ifdef _WIN32
FreeLibrary(component_h);
# else
dlclose(component_h);
#endif
# endif

#endif /* BAZEL_BUILD */
}

int span_a_lib_count = 0;
Expand Down Expand Up @@ -316,6 +342,14 @@ void cleanup_otel()
trace_api::Provider::SetTracerProvider(provider);
}

// TODO: Remove once windows api singletons are supported.
// See https://github.com/open-telemetry/opentelemetry-cpp/issues/2534
#ifdef _WIN32
# define RUN_FAILING_WINDOWS_TEST 0
#else
# define RUN_FAILING_WINDOWS_TEST 1
#endif

TEST(SingletonTest, Uniqueness)
{
do_something();
Expand Down Expand Up @@ -357,26 +391,31 @@ TEST(SingletonTest, Uniqueness)
EXPECT_EQ(span_b_lib_count, 1);
EXPECT_EQ(span_b_f1_count, 2);
EXPECT_EQ(span_b_f2_count, 1);
EXPECT_EQ(span_c_lib_count, 1);
EXPECT_EQ(span_c_f1_count, 2);
EXPECT_EQ(span_c_f2_count, 1);
EXPECT_EQ(span_d_lib_count, 1);
EXPECT_EQ(span_d_f1_count, 2);
EXPECT_EQ(span_d_f2_count, 1);
EXPECT_EQ(span_e_lib_count, 1);
EXPECT_EQ(span_e_f1_count, 2);
EXPECT_EQ(span_e_f2_count, 1);
EXPECT_EQ(span_f_lib_count, 1);
EXPECT_EQ(span_f_f1_count, 2);
EXPECT_EQ(span_f_f2_count, 1);

#if RUN_FAILING_WINDOWS_TEST
EXPECT_EQ(span_c_lib_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_c_f1_count, 2); // Fails with shared libraries on Windows
EXPECT_EQ(span_c_f2_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_d_lib_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_d_f1_count, 2); // Fails with shared libraries on Windows
EXPECT_EQ(span_d_f2_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_e_lib_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_e_f1_count, 2); // Fails with shared libraries on Windows
EXPECT_EQ(span_e_f2_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_f_lib_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_f_f1_count, 2); // Fails with shared libraries on Windows
EXPECT_EQ(span_f_f2_count, 1); // Fails with shared libraries on Windows
#endif

#ifndef BAZEL_BUILD
EXPECT_EQ(span_g_lib_count, 1);
EXPECT_EQ(span_g_f1_count, 2);
EXPECT_EQ(span_g_f2_count, 1);
EXPECT_EQ(span_h_lib_count, 1);
EXPECT_EQ(span_h_f1_count, 2);
EXPECT_EQ(span_h_f2_count, 1);
# if RUN_FAILING_WINDOWS_TEST
EXPECT_EQ(span_g_lib_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_g_f1_count, 2); // Fails with shared libraries on Windows
EXPECT_EQ(span_g_f2_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_h_lib_count, 1); // Fails with shared libraries on Windows
EXPECT_EQ(span_h_f1_count, 2); // Fails with shared libraries on Windows
EXPECT_EQ(span_h_f2_count, 1); // Fails with shared libraries on Windows
# endif
#endif

EXPECT_EQ(unknown_span_count, 0);
Expand Down
2 changes: 2 additions & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ $PLUGIN_DIR = Join-Path "$SRC_DIR" "plugin"

$VCPKG_DIR = Join-Path "$SRC_DIR" "tools" "vcpkg"

$Env:CTEST_OUTPUT_ON_FAILURE = "1"

switch ($action) {
"bazel.build" {
bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS --action_env=VCPKG_DIR=$VCPKG_DIR --deleted_packages=opentracing-shim -- //...
Expand Down
3 changes: 2 additions & 1 deletion exporters/otlp/test/otlp_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ TEST(OtlpRecordable, SetInstrumentationScopeWithAttributes)

ASSERT_EQ(proto_instr_libr.attributes_size(), 1);
const auto &proto_attributes = proto_instr_libr.attributes(0);
ASSERT_TRUE(proto_attributes.value().has_string_value());
// Requires protoc 3.15.0
// ASSERT_TRUE(proto_attributes.value().has_string_value());
EXPECT_EQ("test_key", proto_attributes.key());
EXPECT_EQ("test_value", proto_attributes.value().string_value());
}
Expand Down

0 comments on commit fadff90

Please sign in to comment.