From 19c787900debf60f788c632ffeb1d075e7332c1a Mon Sep 17 00:00:00 2001 From: thc1006 <84045975+thc1006@users.noreply.github.com> Date: Fri, 5 Jun 2026 01:51:55 +0800 Subject: [PATCH] [CODE HEALTH] Move sdk_builder.cc builders into anonymous namespace Wraps the 10 file-local builder classes in sdk/src/configuration/sdk_builder.cc within an anonymous namespace inside the existing opentelemetry::sdk::configuration namespace. This gives them internal linkage and clears the 10 misc-use-internal-linkage warnings clang-tidy reports on this file. The wrap covers ResourceAttributeValueSetter, SamplerBuilder, SpanProcessorBuilder, SpanExporterBuilder, MetricReaderBuilder, PushMetricExporterBuilder, PullMetricExporterBuilder, AggregationConfigBuilder, LogRecordProcessorBuilder, and LogRecordExporterBuilder. All 10 use inline methods and are only instantiated from SdkBuilder member functions. None are declared in any header or referenced from any other translation unit. SdkBuilder 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 reachable from SdkBuilder methods via the implicit using-directive that hoists anonymous namespace symbols into the enclosing configuration namespace. This mirrors the structure established by #4121 (registry.cc propagator builders). Ratchet: * abiv1-preview warning_limit lowered from 366 to 356 * abiv2-preview warning_limit lowered from 372 to 362 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/sdk_builder.cc | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index 53dfab682b..159a550605 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: 366 + warning_limit: 356 - cmake_options: all-options-abiv2-preview - warning_limit: 372 + warning_limit: 362 env: CC: /usr/bin/clang-22 CXX: /usr/bin/clang++-22 diff --git a/CHANGELOG.md b/CHANGELOG.md index 31e2470f39..ca1390311b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,9 @@ Increment the: * [CODE HEALTH] Move registry.cc propagator builders into anonymous namespace [#4121](https://github.com/open-telemetry/opentelemetry-cpp/pull/4121) +* [CODE HEALTH] Move sdk_builder.cc builders into anonymous namespace + [#4122](https://github.com/open-telemetry/opentelemetry-cpp/pull/4122) + ## [1.27.0] 2026-05-13 * [RELEASE] Bump main branch to 1.27.0-dev diff --git a/sdk/src/configuration/sdk_builder.cc b/sdk/src/configuration/sdk_builder.cc index b0986ed090..6d61411eef 100644 --- a/sdk/src/configuration/sdk_builder.cc +++ b/sdk/src/configuration/sdk_builder.cc @@ -188,6 +188,9 @@ namespace configuration using common::WildcardMatch; +namespace +{ + class ResourceAttributeValueSetter : public opentelemetry::sdk::configuration::AttributeValueConfigurationVisitor { @@ -747,6 +750,8 @@ class LogRecordExporterBuilder const SdkBuilder *sdk_builder_; }; +} // namespace + std::unique_ptr SdkBuilder::CreateAlwaysOffSampler( const opentelemetry::sdk::configuration::AlwaysOffSamplerConfiguration * /* model */) const {