From 6a81014154a199fdcb91e445394e67e8e8224be4 Mon Sep 17 00:00:00 2001 From: om7057 Date: Tue, 4 Aug 2026 00:50:57 +0530 Subject: [PATCH] [CODE HEALTH] Move remaining misc-use-internal-linkage sites into anonymous namespaces Closes the last four sites left open on #4196: the OTLP file exporter's OtlpFileSystemBackend/OtlpFileOstreamBackend, the Elasticsearch log exporter's ResponseHandler/AsyncResponseHandler and json_assign_visitor, and the TestMode/test_mode enums in the OTLP functional test binaries. All are file-local with no header exposure. --- CHANGELOG.md | 6 ++++++ exporters/elasticsearch/src/es_log_record_exporter.cc | 3 +++ exporters/elasticsearch/src/es_log_recordable.cc | 3 +++ exporters/otlp/src/otlp_file_client.cc | 2 +- functional/otlp/func_grpc_main.cc | 3 +++ functional/otlp/func_http_main.cc | 3 +++ 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe609db7e..56d4e66f9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,12 @@ Increment the: ## [Unreleased] +* [CODE HEALTH] Move remaining `misc-use-internal-linkage` classes/enums into + anonymous namespaces: `OtlpFileSystemBackend`/`OtlpFileOstreamBackend` in + the OTLP file exporter, `ResponseHandler`/`AsyncResponseHandler`/ + `json_assign_visitor` in the Elasticsearch log exporter, and the + `TestMode`/`test_mode` enums in the OTLP functional test binaries. + [#4196](https://github.com/open-telemetry/opentelemetry-cpp/issues/4196) * [METRICS SDK] Fix Windows metrics tail latency on the synchronous record path: `SyncMetricStorage::attribute_hashmap_lock_` now uses `std::mutex` instead of `common::SpinLockMutex`. The spin lock's final `sleep_for(1ms)` back-off is diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index a87a514f01..f8b6ec7b11 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -41,6 +41,8 @@ namespace exporter { namespace logs { +namespace +{ /** * This class handles the response message from the Elasticsearch request */ @@ -349,6 +351,7 @@ class AsyncResponseHandler : public http_client::EventHandler bool console_debug_ = false; }; #endif +} // namespace ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter() : ElasticsearchLogRecordExporter(ElasticsearchExporterOptions()) diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index a1bafa28ca..c333934e5d 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -31,6 +31,8 @@ namespace nlohmann { +namespace +{ template struct json_assign_visitor { @@ -53,6 +55,7 @@ struct json_assign_visitor } } }; +} // namespace template <> struct adl_serializer diff --git a/exporters/otlp/src/otlp_file_client.cc b/exporters/otlp/src/otlp_file_client.cc index 7cdc467e83..fe44f7a9b2 100644 --- a/exporters/otlp/src/otlp_file_client.cc +++ b/exporters/otlp/src/otlp_file_client.cc @@ -973,7 +973,6 @@ void ConvertListFieldToJson(nlohmann::json &value, // NOLINTEND(misc-no-recursion) suppressing for performance as if implemented with stack needs // Dynamic memory allocation -} // namespace class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender { @@ -1615,6 +1614,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileOstreamBackend : public OtlpFileAppende private: std::reference_wrapper os_; }; +} // namespace OtlpFileClient::OtlpFileClient(OtlpFileClientOptions &&options, OtlpFileClientRuntimeOptions &&runtime_options) diff --git a/functional/otlp/func_grpc_main.cc b/functional/otlp/func_grpc_main.cc index 0e71ef90dd..e7b9d27025 100644 --- a/functional/otlp/func_grpc_main.cc +++ b/functional/otlp/func_grpc_main.cc @@ -39,12 +39,15 @@ const int TEST_FAILED = 1; Command line parameters. */ +namespace +{ enum class TestMode : std::uint8_t { kNone, kHttp, kHttps }; +} // namespace static bool opt_help = false; static bool opt_list = false; diff --git a/functional/otlp/func_http_main.cc b/functional/otlp/func_http_main.cc index 6e68a52420..73b91e9dda 100644 --- a/functional/otlp/func_http_main.cc +++ b/functional/otlp/func_http_main.cc @@ -38,12 +38,15 @@ const int TEST_FAILED = 1; Command line parameters. */ +namespace +{ enum test_mode : std::uint8_t { MODE_NONE, MODE_HTTP, MODE_HTTPS }; +} // namespace static bool opt_help = false; static bool opt_list = false;