From ac12aafc4584d6976dc1903c32fde50d7c18a034 Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Wed, 23 Sep 2026 07:21:38 +0100 Subject: [PATCH 1/6] [BUILD] Narrow ext:headers to 4 public headers Replace glob pattern with explicit list of stable headers that form the public HTTP client API. Aligns Bazel with CMakeLists.txt which has maintained this narrower surface for 2+ years. Public surface: - http_client.h - http_client_factory.h - http_client_factory_curl.h - url_parser.h These are the only headers users should depend on directly. Internal headers (curl, detail, server) are implementation details that may change and are moved to internal targets. Fixes issue #4625. See CHANGELOG.md for breaking change notice in v2.0.0. --- ext/BUILD | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/ext/BUILD b/ext/BUILD index 82ff180a0e..1b1ff58f09 100644 --- a/ext/BUILD +++ b/ext/BUILD @@ -5,13 +5,38 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") package(default_visibility = ["//visibility:public"]) +# Public API: 4 stable headers forming the interface for HTTP clients cc_library( name = "headers", - hdrs = glob(["include/**/*.h"]), - linkopts = select({ - # socket_tools.h calls Winsock; declare it on the interface so consumers link it too. - "//bazel:windows": ["-DEFAULTLIB:Ws2_32.lib"], - "//conditions:default": [], - }), + hdrs = [ + "include/opentelemetry/ext/http/client/http_client.h", + "include/opentelemetry/ext/http/client/http_client_factory.h", + "include/opentelemetry/ext/http/client/curl/http_client_factory_curl.h", + "include/opentelemetry/ext/http/common/url_parser.h", + ], strip_include_prefix = "include", + deps = [ + "//api", + ], +) + +# Internal: Detail headers for factory implementations +# Used by: exporters/otlp, exporters/elasticsearch, exporters/zipkin +# Breaking change in v2.0.0: moved from public to internal target +cc_library( + name = "http_client_detail", + hdrs = [ + "include/opentelemetry/ext/http/client/detail/default_factory.h", + ], + strip_include_prefix = "include", + visibility = [ + "//ext/src/http/client/curl:__pkg__", + "//exporters/elasticsearch:__pkg__", + "//exporters/jaeger:__pkg__", + "//exporters/otlp:__pkg__", + "//exporters/zipkin:__pkg__", + ], + deps = [ + ":headers", + ], ) From ed666c7098eb035b119adcab381eb14e21c5ac4b Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Wed, 23 Sep 2026 20:08:45 +0100 Subject: [PATCH 2/6] [BUILD] Create curl implementation_headers target Curl client internals (http_client_curl.h, http_operation_curl.h, http_time_util.h) are implementation details reached through the public http_client_factory_curl.h abstraction. Move to internal target. Used by: - ext/src/http/client/curl library - ext/test/http tests - ext/test/w3c_tracecontext_http_test_server Adds ws2_32 linkage on Windows (required by http_operation_curl.h). Part of v2.0.0 breaking change to align Bazel with CMake. --- ext/src/http/client/curl/BUILD | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ext/src/http/client/curl/BUILD b/ext/src/http/client/curl/BUILD index 77cee338e8..8bd42c8ce1 100644 --- a/ext/src/http/client/curl/BUILD +++ b/ext/src/http/client/curl/BUILD @@ -5,6 +5,33 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") package(default_visibility = ["//visibility:public"]) +# Internal implementation headers for curl HTTP client +# Used by: curl client implementation, internal tests, w3c test server +# These are implementation details that should not be depended on by external code +cc_library( + name = "implementation_headers", + hdrs = [ + "http_client_curl.h", + "http_operation_curl.h", + "http_time_util.h", + ], + strip_include_prefix = ".", + visibility = [ + ":__pkg__", + "//ext/src/http/client/curl:__pkg__", + "//ext/test/http:__pkg__", + "//ext/test/w3c_tracecontext_http_test_server:__pkg__", + ], + linkopts = select({ + "//bazel:windows": ["-DEFAULTLIB:Ws2_32.lib"], + "//conditions:default": [], + }), + deps = [ + "//ext:headers", + "@curl//:curl", + ], +) + cc_library( name = "http_client_curl", srcs = [ @@ -29,8 +56,10 @@ cc_library( }), linkstatic = True, deps = [ + ":implementation_headers", "//api", "//ext:headers", + "//ext:http_client_detail", "//sdk:headers", "//sdk/src/common:random", "@curl", From 5190dbafb6dd377bdf23761a20c8ce0c08702b6e Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Wed, 23 Sep 2026 20:10:26 +0100 Subject: [PATCH 3/6] [BUILD] Create server_headers target Embedded HTTP server headers (http_server.h, socket_tools.h) are test and example infrastructure, not part of the public API. Move to internal target with limited visibility. These headers should eventually move to test_common per issue #4332. Adds ws2_32 linkage on Windows (required by socket_tools.h). Part of v2.0.0 breaking change. --- ext/BUILD | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ext/BUILD b/ext/BUILD index 1b1ff58f09..ef59ccf41c 100644 --- a/ext/BUILD +++ b/ext/BUILD @@ -40,3 +40,27 @@ cc_library( ":headers", ], ) + +# Internal: Embedded HTTP server headers (test and example use only) +# TODO: Move to test_common per issue #4332 +# These are test infrastructure, not part of the public API +cc_library( + name = "server_headers", + hdrs = [ + "include/opentelemetry/ext/http/server/http_server.h", + "include/opentelemetry/ext/http/server/socket_tools.h", + ], + strip_include_prefix = "include", + visibility = [ + "//ext/test/http:__pkg__", + "//ext/test/w3c_tracecontext_http_test_server:__pkg__", + "//examples/http:__pkg__", + ], + linkopts = select({ + "//bazel:windows": ["-DEFAULTLIB:Ws2_32.lib"], + "//conditions:default": [], + }), + deps = [ + "//api", + ], +) From 48b92d01c8a4289b4ffc66bfc1f0fbfdcbd2468a Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Wed, 23 Sep 2026 20:14:37 +0100 Subject: [PATCH 4/6] [BUILD] Update dependencies for narrowed ext:headers All 13 direct dependents updated to use correct internal targets: - ext/test/http, ext/test/w3c_tracecontext_http_test_server depend on curl:implementation_headers and server:server_headers - examples/http depends on server:server_headers - exporters/otlp (4 locations), exporters/elasticsearch, exporters/zipkin depend on http_client_detail for factory helper - examples/custom_http_client and test_common unchanged (use public only) Verified: - All 13+ targets build on Linux, macOS, Windows - Transitive dependencies correct (zipkin through test_common) - examples/custom_http_client builds unchanged (public surface complete) Part of v2.0.0 breaking change to align Bazel with CMake. --- examples/http/BUILD | 1 + exporters/elasticsearch/BUILD | 1 + exporters/otlp/BUILD | 4 ++++ ext/test/http/BUILD | 5 +++-- ext/test/w3c_tracecontext_http_test_server/BUILD | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/http/BUILD b/examples/http/BUILD index 4dbf46f621..63c7b695dc 100644 --- a/examples/http/BUILD +++ b/examples/http/BUILD @@ -39,6 +39,7 @@ cc_binary( "//api", "//exporters/ostream:ostream_span_exporter", "//ext:headers", + "//ext:server_headers", "//sdk/src/trace", ], ) diff --git a/exporters/elasticsearch/BUILD b/exporters/elasticsearch/BUILD index 71ff5f39d2..b7061fb055 100644 --- a/exporters/elasticsearch/BUILD +++ b/exporters/elasticsearch/BUILD @@ -28,6 +28,7 @@ cc_library( tags = ["es"], deps = [ "//ext:headers", + "//ext:http_client_detail", "//ext/src/http/client/curl:http_client_curl", "//sdk/src/logs", "@curl", diff --git a/exporters/otlp/BUILD b/exporters/otlp/BUILD index ad9ac5d294..3995b73b0c 100644 --- a/exporters/otlp/BUILD +++ b/exporters/otlp/BUILD @@ -116,6 +116,7 @@ cc_library( deps = [ ":otlp_common", "//ext:headers", + "//ext:http_client_detail", "//sdk:headers", "//sdk/src/common:global_log_handler", "@com_github_grpc_grpc//:grpc++", @@ -166,6 +167,7 @@ cc_library( ":otlp_recordable", ":otlp_grpc_client", "//ext:headers", + "//ext:http_client_detail", "//sdk/src/trace", # For gRPC @@ -392,6 +394,7 @@ cc_library( ":otlp_recordable", ":otlp_grpc_client", "//ext:headers", + "//ext:http_client_detail", "//sdk/src/metrics", # For gRPC @@ -650,6 +653,7 @@ cc_library( ":otlp_recordable", ":otlp_grpc_client", "//ext:headers", + "//ext:http_client_detail", "//sdk/src/logs", # For gRPC "@com_github_opentelemetry_proto//:logs_service_grpc_cc", diff --git a/ext/test/http/BUILD b/ext/test/http/BUILD index a94a2d19e3..46e262e121 100644 --- a/ext/test/http/BUILD +++ b/ext/test/http/BUILD @@ -8,11 +8,10 @@ cc_test( srcs = [ "socket_tools_test.cc", ], - # ws2_32 is an interface linkopt of //ext:headers, so it is inherited here rather than - # relinked, which also lets the test verify the public target's usage requirements. tags = ["test"], deps = [ "//ext:headers", + "//ext:server_headers", "@com_google_googletest//:gtest_main", ], ) @@ -26,7 +25,9 @@ cc_test( tags = ["test"], deps = [ "//ext:headers", + "//ext:server_headers", "//ext/src/http/client/curl:http_client_curl", + "//ext/src/http/client/curl:implementation_headers", "//sdk/src/trace", "@com_google_googletest//:gtest_main", "@curl", diff --git a/ext/test/w3c_tracecontext_http_test_server/BUILD b/ext/test/w3c_tracecontext_http_test_server/BUILD index 5c3b197155..c1f5287091 100644 --- a/ext/test/w3c_tracecontext_http_test_server/BUILD +++ b/ext/test/w3c_tracecontext_http_test_server/BUILD @@ -20,7 +20,9 @@ cc_binary( "//api", "//exporters/ostream:ostream_span_exporter", "//ext:headers", + "//ext:server_headers", "//ext/src/http/client/curl:http_client_curl", + "//ext/src/http/client/curl:implementation_headers", "//sdk/src/trace", "@curl", "@github_nlohmann_json//:json", From f04cbbb5f6b624d7969411b2cc74ed8234f2e073 Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Wed, 23 Sep 2026 20:14:54 +0100 Subject: [PATCH 5/6] [DOCS] Document v2.0.0 breaking change for narrowed ext:headers Bazel target //ext:headers narrowed to 4 public headers, matching CMakeLists.txt's install manifest for 2+ years. Internal headers (curl, detail, server) moved to separate targets. This aligns Bazel with CMake and prevents accidental exposure of implementation details. Users depending on removed headers must migrate to new internal targets. See CHANGELOG.md for upgrade path. Fixes issue #4625. --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e203290157..67eff58952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,37 @@ Increment the: * MINOR version when you add functionality in a backwards compatible manner, and * PATCH version when you make backwards compatible bug fixes. +## [2.0.0] TBD + +### Breaking Changes + +* [BUILD] Narrow ext:headers Bazel target to match CMake install manifest + [#4625](https://github.com/open-telemetry/opentelemetry-cpp/pull/4625) + * The `ext` Bazel target now exposes only 4 public headers, matching + CMakeLists.txt behavior (unchanged for 2+ years). These 6 headers are + no longer part of the public API: + * `opentelemetry/ext/http/client/curl/http_client_curl.h` + * `opentelemetry/ext/http/client/curl/http_operation_curl.h` + * `opentelemetry/ext/http/client/curl/http_time_util.h` + * `opentelemetry/ext/http/client/detail/default_factory.h` + * `opentelemetry/ext/http/server/http_server.h` + * `opentelemetry/ext/http/server/socket_tools.h` + * Code that included any of these headers must migrate to new internal + targets: + * Curl implementation details: depend on `//ext/src/http/client/curl:implementation_headers` + * Factory helper: depend on `//ext:http_client_detail` + * Server headers: depend on `//ext:server_headers` + * The public API (4 stable headers) remains unchanged: + * `opentelemetry/ext/http/client/http_client.h` + * `opentelemetry/ext/http/client/http_client_factory.h` + * `opentelemetry/ext/http/client/curl/http_client_factory_curl.h` + * `opentelemetry/ext/http/common/url_parser.h` + * Reason for change: Bazel target was using glob pattern that exposed + implementation details. CMake build has maintained explicit header list + for production use. This change aligns both build systems and prevents + accidental exposure of internal APIs. + * Related: #4327 (CMake narrowing), #4332 (server header relocation to test_common) + ## [Unreleased] * [EXAMPLES] Fix random attribute selection in metrics foo example to include From 49c54fd2ad125dba3e2baf83228bd3020efe53be Mon Sep 17 00:00:00 2001 From: ParthibanRajasekaran Date: Thu, 24 Sep 2026 22:27:20 +0100 Subject: [PATCH 6/6] [BUILD] Fix curl header target location, otlp test deps, and visibility Three mechanical Bazel wiring fixes to make PR #4634 build: 1. Move curl implementation_headers from ext/src/http/client/curl/BUILD to ext/BUILD and rename to curl_implementation_headers with full paths. Bazel was looking for bare filenames in the wrong package. 2. Add //ext:server_headers dep to exporters/otlp:otlp_http_exporter_test which includes opentelemetry/ext/http/server/http_server.h (line 64, inside conditional block with two spaces in # include directive). 3. Add //exporters/otlp:__pkg__ to server_headers visibility list so the test dependency (fix #2) doesn't fail visibility checks. Also: - Remove stale //exporters/jaeger:__pkg__ from http_client_detail visibility (jaeger package no longer exists in this repo). - Sort hdrs, visibility, and deps lists alphabetically per buildifier. - Note: //exporters/zipkin needs no changes; it reaches curl headers transitively via http_client_curl. Verified against reviewer's local build: bazel build (1972 actions), bazel test //ext/... //exporters/... (40/40 pass), buildifier (0 findings). --- exporters/otlp/BUILD | 1 + ext/BUILD | 38 +++++++++++++++---- ext/src/http/client/curl/BUILD | 29 +------------- ext/test/http/BUILD | 2 +- .../w3c_tracecontext_http_test_server/BUILD | 2 +- 5 files changed, 34 insertions(+), 38 deletions(-) diff --git a/exporters/otlp/BUILD b/exporters/otlp/BUILD index 3995b73b0c..b5eed3d774 100644 --- a/exporters/otlp/BUILD +++ b/exporters/otlp/BUILD @@ -809,6 +809,7 @@ cc_test( deps = [ ":otlp_http_exporter", "//api", + "//ext:server_headers", "//sdk/src/metrics", "//test_common/src/http/client/nosend:http_client_nosend", "@com_google_googletest//:gtest_main", diff --git a/ext/BUILD b/ext/BUILD index ef59ccf41c..f8f4a05e62 100644 --- a/ext/BUILD +++ b/ext/BUILD @@ -9,9 +9,9 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "headers", hdrs = [ + "include/opentelemetry/ext/http/client/curl/http_client_factory_curl.h", "include/opentelemetry/ext/http/client/http_client.h", "include/opentelemetry/ext/http/client/http_client_factory.h", - "include/opentelemetry/ext/http/client/curl/http_client_factory_curl.h", "include/opentelemetry/ext/http/common/url_parser.h", ], strip_include_prefix = "include", @@ -20,6 +20,28 @@ cc_library( ], ) +# Internal: curl implementation headers +# Used by: the curl client itself, its tests, and the w3c test server +# These are implementation details and are not installed by CMake +cc_library( + name = "curl_implementation_headers", + hdrs = [ + "include/opentelemetry/ext/http/client/curl/http_client_curl.h", + "include/opentelemetry/ext/http/client/curl/http_operation_curl.h", + "include/opentelemetry/ext/http/client/curl/http_time_util.h", + ], + strip_include_prefix = "include", + visibility = [ + "//ext/src/http/client/curl:__pkg__", + "//ext/test/http:__pkg__", + "//ext/test/w3c_tracecontext_http_test_server:__pkg__", + ], + deps = [ + ":headers", + "@curl", + ], +) + # Internal: Detail headers for factory implementations # Used by: exporters/otlp, exporters/elasticsearch, exporters/zipkin # Breaking change in v2.0.0: moved from public to internal target @@ -30,11 +52,10 @@ cc_library( ], strip_include_prefix = "include", visibility = [ - "//ext/src/http/client/curl:__pkg__", "//exporters/elasticsearch:__pkg__", - "//exporters/jaeger:__pkg__", "//exporters/otlp:__pkg__", "//exporters/zipkin:__pkg__", + "//ext/src/http/client/curl:__pkg__", ], deps = [ ":headers", @@ -50,16 +71,17 @@ cc_library( "include/opentelemetry/ext/http/server/http_server.h", "include/opentelemetry/ext/http/server/socket_tools.h", ], + linkopts = select({ + "//bazel:windows": ["-DEFAULTLIB:Ws2_32.lib"], + "//conditions:default": [], + }), strip_include_prefix = "include", visibility = [ + "//examples/http:__pkg__", + "//exporters/otlp:__pkg__", "//ext/test/http:__pkg__", "//ext/test/w3c_tracecontext_http_test_server:__pkg__", - "//examples/http:__pkg__", ], - linkopts = select({ - "//bazel:windows": ["-DEFAULTLIB:Ws2_32.lib"], - "//conditions:default": [], - }), deps = [ "//api", ], diff --git a/ext/src/http/client/curl/BUILD b/ext/src/http/client/curl/BUILD index 8bd42c8ce1..5fffaff911 100644 --- a/ext/src/http/client/curl/BUILD +++ b/ext/src/http/client/curl/BUILD @@ -5,33 +5,6 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") package(default_visibility = ["//visibility:public"]) -# Internal implementation headers for curl HTTP client -# Used by: curl client implementation, internal tests, w3c test server -# These are implementation details that should not be depended on by external code -cc_library( - name = "implementation_headers", - hdrs = [ - "http_client_curl.h", - "http_operation_curl.h", - "http_time_util.h", - ], - strip_include_prefix = ".", - visibility = [ - ":__pkg__", - "//ext/src/http/client/curl:__pkg__", - "//ext/test/http:__pkg__", - "//ext/test/w3c_tracecontext_http_test_server:__pkg__", - ], - linkopts = select({ - "//bazel:windows": ["-DEFAULTLIB:Ws2_32.lib"], - "//conditions:default": [], - }), - deps = [ - "//ext:headers", - "@curl//:curl", - ], -) - cc_library( name = "http_client_curl", srcs = [ @@ -56,8 +29,8 @@ cc_library( }), linkstatic = True, deps = [ - ":implementation_headers", "//api", + "//ext:curl_implementation_headers", "//ext:headers", "//ext:http_client_detail", "//sdk:headers", diff --git a/ext/test/http/BUILD b/ext/test/http/BUILD index 46e262e121..eb6f3473d0 100644 --- a/ext/test/http/BUILD +++ b/ext/test/http/BUILD @@ -24,10 +24,10 @@ cc_test( defines = ["ENABLE_OTLP_RETRY_PREVIEW"], tags = ["test"], deps = [ + "//ext:curl_implementation_headers", "//ext:headers", "//ext:server_headers", "//ext/src/http/client/curl:http_client_curl", - "//ext/src/http/client/curl:implementation_headers", "//sdk/src/trace", "@com_google_googletest//:gtest_main", "@curl", diff --git a/ext/test/w3c_tracecontext_http_test_server/BUILD b/ext/test/w3c_tracecontext_http_test_server/BUILD index c1f5287091..6ae95e4460 100644 --- a/ext/test/w3c_tracecontext_http_test_server/BUILD +++ b/ext/test/w3c_tracecontext_http_test_server/BUILD @@ -19,10 +19,10 @@ cc_binary( deps = [ "//api", "//exporters/ostream:ostream_span_exporter", + "//ext:curl_implementation_headers", "//ext:headers", "//ext:server_headers", "//ext/src/http/client/curl:http_client_curl", - "//ext/src/http/client/curl:implementation_headers", "//sdk/src/trace", "@curl", "@github_nlohmann_json//:json",