Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
matrix:
include:
- cmake_options: all-options-abiv1-preview
warning_limit: 142
warning_limit: 139
- cmake_options: all-options-abiv2-preview
warning_limit: 152
warning_limit: 149
env:
CC: /usr/bin/clang-22
CXX: /usr/bin/clang++-22
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ Increment the:
* [CODE HEALTH] Fix remaining misc-override-with-different-visibility warnings
[#4280](https://github.com/open-telemetry/opentelemetry-cpp/pull/4280)

* [CODE HEALTH] Move SDK common and logs test helpers into anonymous
namespaces
[#4302](https://github.com/open-telemetry/opentelemetry-cpp/pull/4302)

Breaking changes:

* [METRICS SDK] Rename Base2 Exponential Histogram Aggregation config field
Expand Down
16 changes: 11 additions & 5 deletions sdk/test/common/global_log_handle_singleton_lifetime_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "opentelemetry/sdk/common/attribute_utils.h"
#include "opentelemetry/sdk/common/global_log_handler.h"

namespace
{

class GlobalLogHandlerChecker
{
public:
Expand All @@ -19,9 +22,13 @@ class GlobalLogHandlerChecker
{
using opentelemetry::sdk::common::internal_log::GlobalLogHandler;
auto handle = GlobalLogHandler::GetLogHandler();
if (handle && custom_handler_destroyed)
// The checker must outlive the global handler. Fail if it is destroyed first
// (custom_handler_destroyed still false) or if the handler is somehow still reachable
// (handle non-null). The old "handle && custom_handler_destroyed" only caught the second
// case, so a reversed order slipped through.
if (!custom_handler_destroyed || handle)
{
OTEL_INTERNAL_LOG_ERROR("GlobalLogHandler should be destroyed here");
OTEL_INTERNAL_LOG_ERROR("GlobalLogHandler must be destroyed before the checker");
abort();
}
std::cout << "GlobalLogHandlerChecker destroyed and check pass.\n";
Expand All @@ -38,14 +45,11 @@ class GlobalLogHandlerChecker
};
bool GlobalLogHandlerChecker::custom_handler_destroyed = false;

namespace
{
static GlobalLogHandlerChecker &ConstructChecker()
{
static GlobalLogHandlerChecker checker;
return checker;
}
} // namespace

class CustomLogHandler : public opentelemetry::sdk::common::internal_log::LogHandler
{
Expand Down Expand Up @@ -112,3 +116,5 @@ TEST(GlobalLogHandleSingletonTest, Lifetime)
EXPECT_TRUE(!!handle);
}
}

} // namespace
5 changes: 5 additions & 0 deletions sdk/test/logs/logger_provider_set_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ namespace nostd = opentelemetry::nostd;
namespace logs_api = opentelemetry::logs;
namespace logs_sdk = opentelemetry::sdk::logs;

namespace
{

class TestProvider : public LoggerProvider
{
public:
Expand Down Expand Up @@ -86,3 +89,5 @@ TEST(Provider, MultipleLoggerProviders)

ASSERT_NE(logs_api::Provider::GetLoggerProvider(), tf);
}

} // namespace
Loading