From b5ac2f3050782dbb27beb085b4055a27d4b1da1d Mon Sep 17 00:00:00 2001 From: thc1006 <84045975+thc1006@users.noreply.github.com> Date: Thu, 4 Jun 2026 11:31:41 +0800 Subject: [PATCH] [CODE HEALTH] Move registry.cc propagator builders into anonymous namespace Wraps the 5 file-local TextMapPropagatorBuilder subclasses in sdk/src/configuration/registry.cc within an anonymous namespace inside the existing opentelemetry::sdk::configuration namespace. This gives them internal linkage and clears the 5 misc-use-internal-linkage warnings clang-tidy reports on this file. The wrap covers TraceContextBuilder, BaggageBuilder, B3Builder, B3MultiBuilder, and JaegerBuilder. The 5 classes are only instantiated inside Registry::Registry() via std::make_unique. None of them are declared in registry.h or referenced from any other translation unit. Registry member function definitions remain outside the anonymous namespace since they must keep external linkage as members of a class declared in the public header. The anonymous namespace contents are still reachable from Registry::Registry() via the implicit using-directive that hoists anonymous namespace symbols into the enclosing configuration namespace. Ratchet: * abiv1-preview warning_limit lowered from 371 to 366 * abiv2-preview warning_limit lowered from 377 to 372 Part of #2053 Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com> --- .github/workflows/clang-tidy.yaml | 4 ++-- CHANGELOG.md | 3 +++ sdk/src/configuration/registry.cc | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index 3a8a6b0f69..b9f6b94e77 100644 --- a/.github/workflows/clang-tidy.yaml +++ b/.github/workflows/clang-tidy.yaml @@ -17,9 +17,9 @@ jobs: matrix: include: - cmake_options: all-options-abiv1-preview - warning_limit: 371 + warning_limit: 366 - cmake_options: all-options-abiv2-preview - warning_limit: 377 + warning_limit: 372 env: CC: /usr/bin/clang-22 CXX: /usr/bin/clang++-22 diff --git a/CHANGELOG.md b/CHANGELOG.md index c4a5e3c487..31e2470f39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,9 @@ Increment the: * [CODE HEALTH] Move simple_log_record_processor_test into anonymous namespace [#4116](https://github.com/open-telemetry/opentelemetry-cpp/pull/4116) +* [CODE HEALTH] Move registry.cc propagator builders into anonymous namespace + [#4121](https://github.com/open-telemetry/opentelemetry-cpp/pull/4121) + ## [1.27.0] 2026-05-13 * [RELEASE] Bump main branch to 1.27.0-dev diff --git a/sdk/src/configuration/registry.cc b/sdk/src/configuration/registry.cc index 88807ac8a6..0671db848f 100644 --- a/sdk/src/configuration/registry.cc +++ b/sdk/src/configuration/registry.cc @@ -27,6 +27,9 @@ namespace sdk namespace configuration { +namespace +{ + class TraceContextBuilder : public TextMapPropagatorBuilder { public: @@ -77,6 +80,8 @@ class JaegerBuilder : public TextMapPropagatorBuilder } }; +} // namespace + Registry::Registry() { SetTextMapPropagatorBuilder("tracecontext", std::make_unique());