diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index c902f606d2..2587324dc7 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -8,6 +8,30 @@ target_include_directories( "$") set_target_properties(opentelemetry_api PROPERTIES EXPORT_NAME api) +set(EXPORTED_OTELCPP_TARGETS opentelemetry_api) + +if(WIN32) + # * abi_symbol_bridge + add_library(opentelemetry_api_symbol_bridge SHARED + src/symbol_bridge_implementation_windows.cc) + target_link_libraries(opentelemetry_api_symbol_bridge + PRIVATE opentelemetry_api) + set_target_properties( + opentelemetry_api_symbol_bridge + PROPERTIES EXPORT_NAME api_symbol_bridge RUNTIME_OUTPUT_NAME + opentelemetry_api_symbol_bridge) + + target_compile_options( + opentelemetry_api_symbol_bridge + PRIVATE $<$:/wd4190> + $<$:-Wno-return-type-c-linkage>) + target_link_options( + opentelemetry_api_symbol_bridge INTERFACE + $<$:/INCLUDE:OpenTelemetryAbiBridgeHook> + $<$:-Wl,-u,OpenTelemetryAbiBridgeHook>) + + list(APPEND EXPORTED_OTELCPP_TARGETS opentelemetry_api_symbol_bridge) +endif() unset(TARGET_DEPS) @@ -115,7 +139,7 @@ otel_add_component( COMPONENT api TARGETS - opentelemetry_api + ${EXPORTED_OTELCPP_TARGETS} FILES_DIRECTORY "include/opentelemetry" FILES_DESTINATION diff --git a/api/include/opentelemetry/baggage/baggage.h b/api/include/opentelemetry/baggage/baggage.h index 6d23d06a24..dd4129d964 100644 --- a/api/include/opentelemetry/baggage/baggage.h +++ b/api/include/opentelemetry/baggage/baggage.h @@ -11,6 +11,10 @@ #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" +#ifdef _WIN32 +# include "opentelemetry/common/detail/symbol_bridge_windows.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace baggage @@ -36,6 +40,12 @@ class OPENTELEMETRY_EXPORT Baggage OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr GetDefault() { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol (*)()>( + "OpenTelemetryBaggageBaggageGetDefault")) + return address(); +#endif static nostd::shared_ptr baggage{new Baggage()}; return baggage; } diff --git a/api/include/opentelemetry/common/detail/symbol_bridge_windows.h b/api/include/opentelemetry/common/detail/symbol_bridge_windows.h new file mode 100644 index 0000000000..1f50161671 --- /dev/null +++ b/api/include/opentelemetry/common/detail/symbol_bridge_windows.h @@ -0,0 +1,99 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/version.h" + +#ifndef OPENTELEMETRY_SYMBOL_BRIDGE_NOINLINE +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include +#endif + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace common +{ +namespace detail +{ + +struct LoadedBridgeSymbol +{ + void *address; + bool try_again; +}; + +LoadedBridgeSymbol LoadSymbolBridgeSymbol(const char *symbol_name) noexcept; + +template +Signature LoadSymbolBridgeSymbol(const char *symbol_name) noexcept +{ + static LoadedBridgeSymbol symbol{nullptr, true}; + if (!symbol.address && symbol.try_again) + { + symbol = LoadSymbolBridgeSymbol(symbol_name); + } + return reinterpret_cast(symbol.address); +} + +#ifndef OPENTELEMETRY_SYMBOL_BRIDGE_NOINLINE +inline +#endif + +#if !defined(OPENTELEMETRY_SYMBOL_BRIDGE_NOINLINE) || defined(OPENTELEMETRY_SYMBOL_BRIDGE_IMPL) + LoadedBridgeSymbol + LoadSymbolBridgeSymbol(const char *symbol_name) noexcept +{ + struct ModuleLifetime + { + ::HMODULE module{nullptr}; + bool load_failed{false}; + + ~ModuleLifetime() + { + if (module) + { + ::FreeLibrary(module); + } + } + }; + + static ::ATOM bridge_present_atom{0}; + if (bridge_present_atom == 0) + { + bridge_present_atom = ::FindAtomW(L"otelcpp-abi-bridge"); + if (bridge_present_atom == 0) + { + return {nullptr, true}; + } + } + + static ModuleLifetime bridge_module{}; + if (!bridge_module.module) + { + if (bridge_module.load_failed) + { + return {nullptr, false}; + } + + ::GetModuleHandleExW(0x0, L"opentelemetry_api_symbol_bridge", &bridge_module.module); + bridge_module.load_failed = !bridge_module.module; + + if (bridge_module.load_failed) + { + return {nullptr, false}; + } + } + + const auto address = ::GetProcAddress(bridge_module.module, symbol_name); + return {reinterpret_cast(address), false}; +} +#endif + +} // namespace detail +} // namespace common +OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/context/propagation/global_propagator.h b/api/include/opentelemetry/context/propagation/global_propagator.h index 483b0e1fa7..c9dc1d25be 100644 --- a/api/include/opentelemetry/context/propagation/global_propagator.h +++ b/api/include/opentelemetry/context/propagation/global_propagator.h @@ -13,6 +13,10 @@ #include "opentelemetry/version.h" +#ifdef _WIN32 +# include "opentelemetry/common/detail/symbol_bridge_windows.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace context { @@ -60,12 +64,24 @@ class OPENTELEMETRY_EXPORT GlobalTextMapPropagator private: OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetPropagator() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol &(*)()>( + "OpenTelemetryContextPropagationGlobalTextMapPropagatorGetPropagator")) + return address(); +#endif static nostd::shared_ptr propagator(new NoOpPropagator()); return propagator; } OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol( + "OpenTelemetryContextPropagationGlobalTextMapPropagatorGetLock")) + return address(); +#endif static common::SpinLockMutex lock; return lock; } diff --git a/api/include/opentelemetry/context/runtime_context.h b/api/include/opentelemetry/context/runtime_context.h index e86b8873f0..0e8bb68f4c 100644 --- a/api/include/opentelemetry/context/runtime_context.h +++ b/api/include/opentelemetry/context/runtime_context.h @@ -14,9 +14,18 @@ #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" +#ifdef _WIN32 +# include "opentelemetry/common/detail/symbol_bridge_windows.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace context { +namespace detail +{ +struct AbiBridgePrivacyIntruder; +} // namespace detail + // The Token object provides is returned when attaching objects to the // RuntimeContext object and is associated with a context object, and // can be provided to the RuntimeContext Detach method to remove the @@ -192,6 +201,12 @@ class OPENTELEMETRY_EXPORT RuntimeContext OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetStorage() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol &(*)()>( + "OpenTelemetryContextRuntimeContextGetStorage")) + return address(); +#endif static nostd::shared_ptr context(GetDefaultStorage()); return context; } @@ -250,10 +265,13 @@ class ThreadLocalContextStorage : public RuntimeContextStorage } private: + friend struct detail::AbiBridgePrivacyIntruder; + // A nested class to store the attached contexts in a stack. class Stack { friend class ThreadLocalContextStorage; + friend struct detail::AbiBridgePrivacyIntruder; /** * Limit the max stack depth. @@ -384,6 +402,11 @@ class ThreadLocalContextStorage : public RuntimeContextStorage OPENTELEMETRY_API_SINGLETON Stack &GetStack() { +#ifdef _WIN32 + if (const auto address = common::detail::LoadSymbolBridgeSymbol( + "OpenTelemetryContextThreadLocalContextStorageStackGetStack")) + return address(); +#endif static thread_local Stack stack_{}; return stack_; } diff --git a/api/include/opentelemetry/logs/provider.h b/api/include/opentelemetry/logs/provider.h index 1ed54bf410..3f67960da0 100644 --- a/api/include/opentelemetry/logs/provider.h +++ b/api/include/opentelemetry/logs/provider.h @@ -11,6 +11,10 @@ #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/version.h" +#ifdef _WIN32 +# include "opentelemetry/common/detail/symbol_bridge_windows.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace logs { @@ -97,6 +101,12 @@ class OPENTELEMETRY_EXPORT Provider private: OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetProvider() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol &(*)()>( + "OpenTelemetryLogsProviderGetProvider")) + return address(); +#endif static nostd::shared_ptr provider(new NoopLoggerProvider); return provider; } @@ -105,6 +115,12 @@ class OPENTELEMETRY_EXPORT Provider OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr & GetEventProvider() noexcept { +# ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol &(*)()>( + "OpenTelemetryLogsProviderGetEventProvider")) + return address(); +# endif static nostd::shared_ptr provider(new NoopEventLoggerProvider); return provider; } @@ -112,6 +128,12 @@ class OPENTELEMETRY_EXPORT Provider OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol( + "OpenTelemetryLogsProviderGetLock")) + return address(); +#endif static common::SpinLockMutex lock; return lock; } diff --git a/api/include/opentelemetry/metrics/provider.h b/api/include/opentelemetry/metrics/provider.h index a1278a1098..6e910bd203 100644 --- a/api/include/opentelemetry/metrics/provider.h +++ b/api/include/opentelemetry/metrics/provider.h @@ -11,6 +11,10 @@ #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/version.h" +#ifdef _WIN32 +# include "opentelemetry/common/detail/symbol_bridge_windows.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { @@ -55,12 +59,24 @@ class Provider private: OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetProvider() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol &(*)()>( + "OpenTelemetryMetricsProviderGetProvider")) + return address(); +#endif static nostd::shared_ptr provider(new NoopMeterProvider); return provider; } OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol( + "OpenTelemetryMetricsProviderGetLock")) + return address(); +#endif static common::SpinLockMutex lock; return lock; } diff --git a/api/include/opentelemetry/trace/provider.h b/api/include/opentelemetry/trace/provider.h index 9b2dc7daa6..e1f7501d09 100644 --- a/api/include/opentelemetry/trace/provider.h +++ b/api/include/opentelemetry/trace/provider.h @@ -11,6 +11,10 @@ #include "opentelemetry/trace/tracer_provider.h" #include "opentelemetry/version.h" +#ifdef _WIN32 +# include "opentelemetry/common/detail/symbol_bridge_windows.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace trace { @@ -55,12 +59,24 @@ class OPENTELEMETRY_EXPORT Provider private: OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetProvider() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol &(*)()>( + "OpenTelemetryTraceProviderGetProvider")) + return address(); +#endif static nostd::shared_ptr provider(new NoopTracerProvider); return provider; } OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol( + "OpenTelemetryTraceProviderGetLock")) + return address(); +#endif static common::SpinLockMutex lock; return lock; } diff --git a/api/include/opentelemetry/trace/trace_state.h b/api/include/opentelemetry/trace/trace_state.h index 730ce3f9c5..e91302347f 100644 --- a/api/include/opentelemetry/trace/trace_state.h +++ b/api/include/opentelemetry/trace/trace_state.h @@ -15,9 +15,17 @@ #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" +#ifdef _WIN32 +# include "opentelemetry/common/detail/symbol_bridge_windows.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace trace { +namespace detail +{ +struct AbiBridgePrivacyIntruder; +} // namespace detail /** * TraceState carries tracing-system specific context in a list of key-value pairs. TraceState @@ -38,6 +46,12 @@ class OPENTELEMETRY_EXPORT TraceState OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr GetDefault() { +#ifdef _WIN32 + if (const auto address = + common::detail::LoadSymbolBridgeSymbol (*)()>( + "OpenTelemetryTraceTraceStateGetDefault")) + return address(); +#endif static nostd::shared_ptr ts{new TraceState()}; return ts; } @@ -246,6 +260,8 @@ class OPENTELEMETRY_EXPORT TraceState } private: + friend struct detail::AbiBridgePrivacyIntruder; + TraceState() : kv_properties_(new common::KeyValueProperties()) {} TraceState(size_t size) : kv_properties_(new common::KeyValueProperties(size)) {} diff --git a/api/src/symbol_bridge_implementation_windows.cc b/api/src/symbol_bridge_implementation_windows.cc new file mode 100644 index 0000000000..a4c5df5e91 --- /dev/null +++ b/api/src/symbol_bridge_implementation_windows.cc @@ -0,0 +1,183 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/baggage/baggage.h" +#include "opentelemetry/context/propagation/global_propagator.h" +#include "opentelemetry/context/runtime_context.h" + +#include "opentelemetry/logs/provider.h" +#include "opentelemetry/metrics/provider.h" +#include "opentelemetry/trace/provider.h" + +#include + +// privacy intruders +OPENTELEMETRY_BEGIN_NAMESPACE +namespace context +{ +namespace detail +{ +struct AbiBridgePrivacyIntruder +{ + using ThreadLocalContextStorageStack = ThreadLocalContextStorage::Stack; + + static ThreadLocalContextStorageStack &GetThreadLocalContextStorageStack() + { + static thread_local ThreadLocalContextStorage::Stack stack_{}; + return stack_; + } +}; +} // namespace detail +} // namespace context + +namespace trace +{ +namespace detail +{ +struct AbiBridgePrivacyIntruder +{ + static nostd::shared_ptr GetDefaultTraceState() + { + static nostd::shared_ptr ts{new TraceState()}; + return ts; + } +}; +} // namespace detail +} // namespace trace +OPENTELEMETRY_END_NAMESPACE + +// atom lifetime +namespace +{ +struct AtomLifetime +{ + AtomLifetime() : atom{::AddAtomW(L"otelcpp-abi-bridge")} {} + ~AtomLifetime() + { + if (atom != 0) + ::DeleteAtom(atom); + } + + ::ATOM atom{0}; +}; + +const AtomLifetime bridgeAtom{}; +} // namespace + +extern "C" { + +__declspec(dllexport) void OpenTelemetryAbiBridgeHook() {} + +// - baggage +__declspec(dllexport) OPENTELEMETRY_NAMESPACE::nostd::shared_ptr +OpenTelemetryBaggageBaggageGetDefault() +{ + static OPENTELEMETRY_NAMESPACE::nostd::shared_ptr baggage{ + new OPENTELEMETRY_NAMESPACE::baggage::Baggage()}; + return baggage; +} + +// - runtime_context +__declspec(dllexport) +OPENTELEMETRY_NAMESPACE::nostd::shared_ptr & +OpenTelemetryContextRuntimeContextGetStorage() +{ + static OPENTELEMETRY_NAMESPACE::nostd::shared_ptr + context(OPENTELEMETRY_NAMESPACE::context::GetDefaultStorage()); + return context; +} +__declspec(dllexport) +OPENTELEMETRY_NAMESPACE::context::detail::AbiBridgePrivacyIntruder::ThreadLocalContextStorageStack & +OpenTelemetryContextThreadLocalContextStorageStackGetStack() +{ + return OPENTELEMETRY_NAMESPACE::context::detail::AbiBridgePrivacyIntruder:: + GetThreadLocalContextStorageStack(); +} + +// - global_propagator +__declspec(dllexport) +OPENTELEMETRY_NAMESPACE::nostd::shared_ptr & +OpenTelemetryContextPropagationGlobalTextMapPropagatorGetPropagator() +{ + static OPENTELEMETRY_NAMESPACE::nostd::shared_ptr< + opentelemetry::context::propagation::TextMapPropagator> + propagator(new OPENTELEMETRY_NAMESPACE::context::propagation::NoOpPropagator()); + return propagator; +} +__declspec(dllexport) OPENTELEMETRY_NAMESPACE::common::SpinLockMutex & +OpenTelemetryContextPropagationGlobalTextMapPropagatorGetLock() +{ + static OPENTELEMETRY_NAMESPACE::common::SpinLockMutex lock; + return lock; +} + +// - logs provider +__declspec(dllexport) +OPENTELEMETRY_NAMESPACE::nostd::shared_ptr & +OpenTelemetryLogsProviderGetProvider() +{ + static OPENTELEMETRY_NAMESPACE::nostd::shared_ptr + provider(new OPENTELEMETRY_NAMESPACE::logs::NoopLoggerProvider); + return provider; +} + +#if OPENTELEMETRY_ABI_VERSION_NO < 2 +__declspec(dllexport) +OPENTELEMETRY_NAMESPACE::nostd::shared_ptr & +OpenTelemetryLogsProviderGetEventProvider() +{ + static OPENTELEMETRY_NAMESPACE::nostd::shared_ptr< + OPENTELEMETRY_NAMESPACE::logs::EventLoggerProvider> + provider(new OPENTELEMETRY_NAMESPACE::logs::NoopEventLoggerProvider); + return provider; +} +#endif + +__declspec(dllexport) OPENTELEMETRY_NAMESPACE::common::SpinLockMutex & +OpenTelemetryLogsProviderGetLock() +{ + static OPENTELEMETRY_NAMESPACE::common::SpinLockMutex lock; + return lock; +} + +// - metrics provider +__declspec(dllexport) +OPENTELEMETRY_NAMESPACE::nostd::shared_ptr & +OpenTelemetryMetricsProviderGetProvider() +{ + static OPENTELEMETRY_NAMESPACE::nostd::shared_ptr + provider(new OPENTELEMETRY_NAMESPACE::metrics::NoopMeterProvider); + return provider; +} +__declspec(dllexport) OPENTELEMETRY_NAMESPACE::common::SpinLockMutex & +OpenTelemetryMetricsProviderGetLock() +{ + static OPENTELEMETRY_NAMESPACE::common::SpinLockMutex lock; + return lock; +} + +// - trace provider +__declspec(dllexport) +OPENTELEMETRY_NAMESPACE::nostd::shared_ptr & +OpenTelemetryTraceProviderGetProvider() +{ + static OPENTELEMETRY_NAMESPACE::nostd::shared_ptr + provider(new OPENTELEMETRY_NAMESPACE::trace::NoopTracerProvider); + return provider; +} + +__declspec(dllexport) OPENTELEMETRY_NAMESPACE::common::SpinLockMutex & +OpenTelemetryTraceProviderGetLock() +{ + static OPENTELEMETRY_NAMESPACE::common::SpinLockMutex lock; + return lock; +} + +// - trace_state +__declspec(dllexport) +OPENTELEMETRY_NAMESPACE::nostd::shared_ptr +OpenTelemetryTraceTraceStateGetDefault() +{ + return OPENTELEMETRY_NAMESPACE::trace::detail::AbiBridgePrivacyIntruder::GetDefaultTraceState(); +} +} diff --git a/api/test/singleton/CMakeLists.txt b/api/test/singleton/CMakeLists.txt index 7c30d6e571..5274f8f631 100644 --- a/api/test/singleton/CMakeLists.txt +++ b/api/test/singleton/CMakeLists.txt @@ -17,6 +17,10 @@ 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) +if(WIN32) + target_link_libraries(component_d opentelemetry_api_symbol_bridge) +endif() + 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) diff --git a/api/test/singleton/singleton_test.cc b/api/test/singleton/singleton_test.cc index e63e00c11e..146d36a205 100644 --- a/api/test/singleton/singleton_test.cc +++ b/api/test/singleton/singleton_test.cc @@ -352,14 +352,6 @@ static 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(); @@ -402,30 +394,26 @@ TEST(SingletonTest, Uniqueness) EXPECT_EQ(span_b_f1_count, 2); EXPECT_EQ(span_b_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 + 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); #ifndef BAZEL_BUILD -# 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 + 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); #endif EXPECT_EQ(unknown_span_count, 0); diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index 90ea5aae01..12f5ab8df4 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -80,6 +80,7 @@ switch ($action) { if ($exit -ne 0) { exit $exit } + $env:PATH = FindAndMergeDllPath "$BUILD_DIR\api\Debug" ctest -C Debug $exit = $LASTEXITCODE if ($exit -ne 0) { @@ -101,7 +102,7 @@ switch ($action) { if ($exit -ne 0) { exit $exit } - $env:PATH = FindAndMergeDllPath "$BUILD_DIR\ext\src\dll\Debug" + $env:PATH = FindAndMergeDllPath "$BUILD_DIR\ext\src\dll\Debug", "$BUILD_DIR\api\Debug" ctest -C Debug $exit = $LASTEXITCODE if ($exit -ne 0) { @@ -124,7 +125,7 @@ switch ($action) { if ($exit -ne 0) { exit $exit } - $env:PATH = FindAndMergeDllPath "$BUILD_DIR\ext\src\dll\Debug" + $env:PATH = FindAndMergeDllPath "$BUILD_DIR\ext\src\dll\Debug", "$BUILD_DIR\api\Debug" ctest -C Debug $exit = $LASTEXITCODE if ($exit -ne 0) { @@ -317,7 +318,7 @@ switch ($action) { if ($exit -ne 0) { exit $exit } - $env:PATH = FindAndMergeDllPath "$BUILD_DIR\ext\src\dll\Debug", "$BUILD_DIR\Debug" + $env:PATH = FindAndMergeDllPath "$BUILD_DIR\ext\src\dll\Debug", "$BUILD_DIR\Debug", "$BUILD_DIR\api\Debug" ctest -C Debug $exit = $LASTEXITCODE if ($exit -ne 0) { diff --git a/install/test/src/test_ext_dll.cc b/install/test/src/test_ext_dll.cc index ed8c1b9941..3e2c63cde8 100644 --- a/install/test/src/test_ext_dll.cc +++ b/install/test/src/test_ext_dll.cc @@ -113,4 +113,5 @@ TEST(ExtDllInstallTest, MeterProviderCheck) ASSERT_TRUE(counter != nullptr); counter->Add(1); } -} \ No newline at end of file + metrics::Provider::SetMeterProvider({}); +}