Skip to content

[CODE HEALTH] Move logger_sdk_test classes into anonymous namespace#4124

Merged
lalitb merged 2 commits into
open-telemetry:mainfrom
thc1006:codehealth/logger-sdk-test-internal-linkage
Jun 5, 2026
Merged

[CODE HEALTH] Move logger_sdk_test classes into anonymous namespace#4124
lalitb merged 2 commits into
open-telemetry:mainfrom
thc1006:codehealth/logger-sdk-test-internal-linkage

Conversation

@thc1006

@thc1006 thc1006 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Wraps the 6 file-scope class and struct declarations in
sdk/test/logs/logger_sdk_test.cc within an anonymous namespace,
clearing the corresponding misc-use-internal-linkage warnings.

This is the 5th PR of the misc-use-internal-linkage campaign (#4115,
#4116, #4121, #4122 already merged) and the first with an asymmetric
ratchet drop
because 2 of the 6 wrapped classes are inside an
#if OPENTELEMETRY_ABI_VERSION_NO >= 2 gate.

Changes

  • sdk/test/logs/logger_sdk_test.cc: insert namespace { after the
    first TEST(LoggerSDK, LogToNullProcessor) (ends at line 117) and
    } // namespace after the final #endif of the file-trailing
    #if OPENTELEMETRY_ABI_VERSION_NO < 2 block. Wrap covers:
    • MockLogRecordable (line 119, always-on)
    • MockProcessor (line 241, always-on)
    • EnabledProcessorCallState struct (line 276, abiv2-only)
    • EnablementAwareProcessor (line 286, abiv2-only)
    • CustomLogConfiguratorTestData (line 668, always-on)
    • CustomLoggerConfiguratorTestFixture TEST_P fixture (line 747,
      always-on)
  • The pre-existing anonymous namespace at lines 65-99 (wrapping two
    abiv2 helper functions inside an existing #if abiv2 gate) is left
    in place.
  • .github/workflows/clang-tidy.yaml: abiv1 356 -> 352 (-4),
    abiv2 362 -> 356 (-6).
  • CHANGELOG.md: one bullet under [Unreleased].

Why the ratchet drop is asymmetric

#if OPENTELEMETRY_ABI_VERSION_NO >= 2 at lines 275-338 contains
EnabledProcessorCallState and EnablementAwareProcessor. In abiv1
builds the preprocessor strips these out, so clang-tidy never sees
them and they are not counted in the abiv1 baseline of 356. In abiv2
builds they are visible and contribute 2 of the 362 total warnings.

After this PR clears all 6 sites, both ratchets drop by the count
visible in that build (abiv1: -4, abiv2: -6), and 2 of the abiv2-only
classes also stop counting against the abiv2 baseline. Net new limits:
abiv1 352, abiv2 356.

This is mechanically the same wrap as #4115 / #4116 / #4121 / #4122;
the only novelty is that this is the first wrapped file containing an
ABI-gated class.

Test plan

  • Local abiv1 build of logger_sdk_test: 59/59 ninja steps
    (WITH_OTLP_HTTP=OFF -DWITH_OTLP_GRPC=OFF)
  • Local abiv1 run: 9/9 tests pass
  • Local abiv2 build of logger_sdk_test:
    -DWITH_ABI_VERSION_2=ON -DWITH_ABI_VERSION_1=OFF, 59/59 steps
  • Local abiv2 run: 15/15 tests pass (extra 6 tests are
    abiv2-only, exercising EnabledProcessorCallState and
    EnablementAwareProcessor)
  • clang-format --dry-run --Werror clean on the modified file
  • DCO signed off

Part of #2053

@thc1006 thc1006 requested a review from a team as a code owner June 5, 2026 13:15
Wraps the 6 file-scope class and struct declarations in
sdk/test/logs/logger_sdk_test.cc within an anonymous namespace to give
them internal linkage and clear the misc-use-internal-linkage warnings
clang-tidy reports on this file.

The wrap spans from the first class (MockLogRecordable at line 119) to
end of file, covering MockLogRecordable, MockProcessor,
EnabledProcessorCallState, EnablementAwareProcessor,
CustomLogConfiguratorTestData, and CustomLoggerConfiguratorTestFixture.
TEST and TEST_P macros inside the namespace block work correctly with
gtest. The pre-existing anonymous namespace at lines 65-99 (wrapping
abiv2 helper functions inside an existing #if abiv2 gate) is left in
place.

The ratchet drop is asymmetric because 2 of the 6 classes
(EnabledProcessorCallState and EnablementAwareProcessor) are inside an
#if OPENTELEMETRY_ABI_VERSION_NO >= 2 block and only exist in abiv2
builds:

* abiv1-preview warning_limit lowered from 356 to 352 (-4 always-on
  classes)
* abiv2-preview warning_limit lowered from 362 to 356 (-4 always-on
  + -2 abiv2-only classes = -6 total)

Part of open-telemetry#2053

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
@thc1006 thc1006 force-pushed the codehealth/logger-sdk-test-internal-linkage branch from 1cc54e0 to 86480bc Compare June 5, 2026 13:16
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.94%. Comparing base (d2f09f1) to head (1bb67df).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4124      +/-   ##
==========================================
- Coverage   81.95%   81.94%   -0.01%     
==========================================
  Files         385      385              
  Lines       16067    16067              
==========================================
- Hits        13166    13164       -2     
- Misses       2901     2903       +2     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lalitb lalitb enabled auto-merge (squash) June 5, 2026 22:26
@lalitb lalitb merged commit 5cdcc38 into open-telemetry:main Jun 5, 2026
70 checks passed
@thc1006 thc1006 deleted the codehealth/logger-sdk-test-internal-linkage branch June 5, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants