Skip to content

[CODE HEALTH] Move func_grpc_main classes into anonymous namespace#4129

Merged
marcalff merged 1 commit into
open-telemetry:mainfrom
thc1006:codehealth/func-grpc-internal-linkage
Jun 6, 2026
Merged

[CODE HEALTH] Move func_grpc_main classes into anonymous namespace#4129
marcalff merged 1 commit into
open-telemetry:mainfrom
thc1006:codehealth/func-grpc-internal-linkage

Conversation

@thc1006

@thc1006 thc1006 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Wraps the 3 file-scope class/struct declarations in
functional/otlp/func_grpc_main.cc within an anonymous namespace,
clearing the misc-use-internal-linkage warnings.

7th PR of the misc-use-internal-linkage campaign and the twin of
#4128 (func_http_main, merged). Same wrap pattern, same boundary
rationale, same +3 site clearance.

Changes

  • functional/otlp/func_grpc_main.cc: insert namespace { after
    the command-line opt_* variables and } // namespace after the
    test_case struct closing brace. Wrap covers TestResult (line
    63), TestLogHandler (line 128), and test_case (line 316).
  • .github/workflows/clang-tidy.yaml: abiv1 349 -> 346 (-3),
    abiv2 353 -> 350 (-3).
  • CHANGELOG.md: one bullet under [Unreleased].

Why the wrap ends before line 322

Same rationale as #4128: the static int test_*() forward
declarations are matched by definitions in the lower half of the
file (after main()). Wrapping declarations alone would produce
(anonymous namespace)::test_* symbols that fail to link.

main(), the static const test_case all_tests[] table,
list_test_cases, run_test_case, and the test definitions remain
at file scope.

Test plan

  • Local build of func_otlp_grpc: 122/122 ninja steps
    (-DWITH_OTLP_HTTP=ON -DWITH_OTLP_GRPC=ON per the CMake quirk
    that the outer functional/CMakeLists.txt only adds otlp subdir
    when WITH_OTLP_HTTP=ON)
  • func_otlp_grpc --help smoke test prints usage
  • 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 6, 2026 01:16
Wraps the 3 file-scope class and struct declarations in
functional/otlp/func_grpc_main.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 covers TestResult (line 63), TestLogHandler (line 128), and
test_case (line 316). It deliberately ends BEFORE the static int
test_*() forward declarations at line 322+.

This boundary follows the same pattern as open-telemetry#4128 (func_http_main):
the test_*() declarations are matched by definitions in the lower
half of the file (after main()). Wrapping the declarations alone
would create (anonymous namespace)::test_* symbols that fail to
link against the file-scope static test_*() definitions. Local
verification: build of func_otlp_grpc target with
WITH_OTLP_HTTP=ON + WITH_OTLP_GRPC=ON succeeded 122/122 ninja steps;
--help smoke test prints usage as expected.

main() and all test_*() infrastructure (declarations, the
all_tests[] table, list_test_cases, run_test_case, and definitions)
remain at file scope with their existing static linkage.

Ratchet:
* abiv1-preview warning_limit lowered from 349 to 346
* abiv2-preview warning_limit lowered from 353 to 350

Part of open-telemetry#2053

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
@thc1006 thc1006 force-pushed the codehealth/func-grpc-internal-linkage branch from f710a4e to 5cb0ddf Compare June 6, 2026 01:17
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.94%. Comparing base (5791b30) to head (5cb0ddf).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4129   +/-   ##
=======================================
  Coverage   81.94%   81.94%           
=======================================
  Files         385      385           
  Lines       16067    16067           
=======================================
  Hits        13164    13164           
  Misses       2903     2903           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcalff marcalff merged commit e649c7f into open-telemetry:main Jun 6, 2026
71 checks passed
@thc1006 thc1006 deleted the codehealth/func-grpc-internal-linkage branch June 6, 2026 06:06
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.

2 participants