diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a3671abae..32cbde6729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,22 @@ Increment the: ## [Unreleased] +* [BUILD] Narrow the `//ext:headers` Bazel target to the four headers the + CMake package installs, and add internal targets for the rest + [#4634](https://github.com/open-telemetry/opentelemetry-cpp/pull/4634) + * `//ext:headers` now exposes only the four that `ext/CMakeLists.txt` + installs: `http/client/http_client.h`, + `http/client/http_client_factory.h`, + `http/client/curl/http_client_factory_curl.h` and + `http/common/url_parser.h`. + * Code that included any of the other six moves to an internal target: + `//ext:curl_implementation_headers` or `//ext:http_client_detail` in + `implementation_deps`, and `//ext:server_headers` for tests and examples. + * CMake narrowed to the same four in #4327, which first shipped in 1.29.0. + A CMake consumer of the other six lost them there, so this change brings + the Bazel surface in line rather than removing anything CMake still + installs. + * [SDK] Release provider mutexes before construction-failure diagnostics so custom log handlers can retrieve cached or noop tracers, loggers, and meters from the same provider without deadlocking. 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..e8f97cd702 100644 --- a/exporters/elasticsearch/BUILD +++ b/exporters/elasticsearch/BUILD @@ -16,6 +16,9 @@ cc_library( "include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h", "include/opentelemetry/exporters/elasticsearch/es_log_recordable.h", ], + implementation_deps = [ + "//ext:http_client_detail", + ], linkopts = select({ "//bazel:windows": [ "-DEFAULTLIB:advapi32.lib", diff --git a/exporters/otlp/BUILD b/exporters/otlp/BUILD index 0e6e8beb7e..fa3f750810 100644 --- a/exporters/otlp/BUILD +++ b/exporters/otlp/BUILD @@ -210,6 +210,9 @@ cc_library( copts = [ "-DCURL_STATICLIB", ], + implementation_deps = [ + "//ext:http_client_detail", + ], linkopts = select({ "//bazel:windows": [ "-DEFAULTLIB:advapi32.lib", @@ -798,6 +801,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/exporters/zipkin/BUILD b/exporters/zipkin/BUILD index b79294c955..bafa4b6696 100644 --- a/exporters/zipkin/BUILD +++ b/exporters/zipkin/BUILD @@ -37,6 +37,9 @@ cc_library( copts = [ "-DCURL_STATICLIB", ], + implementation_deps = [ + "//ext:http_client_detail", + ], strip_include_prefix = "include", tags = ["zipkin"], deps = [ @@ -68,6 +71,7 @@ cc_test( deps = [ ":zipkin_exporter", ":zipkin_recordable", + "//ext:curl_implementation_headers", "//test_common/src/http/client/nosend:http_client_nosend", "@com_google_googletest//:gtest_main", ], diff --git a/ext/BUILD b/ext/BUILD index 82ff180a0e..bdf079c6b6 100644 --- a/ext/BUILD +++ b/ext/BUILD @@ -5,13 +5,83 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") package(default_visibility = ["//visibility:public"]) +# Headers installed by CMake and exposed to Bazel consumers cc_library( name = "headers", - hdrs = glob(["include/**/*.h"]), + 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/common/url_parser.h", + ], + strip_include_prefix = "include", + deps = [ + "//api", + ], +) + +# 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 = [ + "//exporters/zipkin:__pkg__", + "//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 +cc_library( + name = "http_client_detail", + hdrs = [ + "include/opentelemetry/ext/http/client/detail/default_factory.h", + ], + strip_include_prefix = "include", + visibility = [ + "//exporters/elasticsearch:__pkg__", + "//exporters/otlp:__pkg__", + "//exporters/zipkin:__pkg__", + ], + deps = [ + ":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", + ], 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": [], }), strip_include_prefix = "include", + visibility = [ + "//examples/http:__pkg__", + "//exporters/otlp:__pkg__", + "//ext/test/http:__pkg__", + "//ext/test/w3c_tracecontext_http_test_server:__pkg__", + ], + deps = [ + "//api", + ], ) diff --git a/ext/src/http/client/curl/BUILD b/ext/src/http/client/curl/BUILD index 73b0f2257b..f7550228af 100644 --- a/ext/src/http/client/curl/BUILD +++ b/ext/src/http/client/curl/BUILD @@ -16,6 +16,9 @@ cc_library( defines = [ "ENABLE_HTTP_CLIENT_CURL", ], + implementation_deps = [ + "//ext:curl_implementation_headers", + ], include_prefix = "src/http/client/curl", linkopts = select({ "//bazel:windows": [ diff --git a/ext/test/http/BUILD b/ext/test/http/BUILD index ffae7ec111..4e486624bc 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", ], ) @@ -24,7 +23,9 @@ cc_test( ], tags = ["test"], deps = [ + "//ext:curl_implementation_headers", "//ext:headers", + "//ext:server_headers", "//ext/src/http/client/curl:http_client_curl", "//sdk/src/trace", "@com_google_googletest//:gtest_main", diff --git a/ext/test/w3c_tracecontext_http_test_server/BUILD b/ext/test/w3c_tracecontext_http_test_server/BUILD index 5c3b197155..6ae95e4460 100644 --- a/ext/test/w3c_tracecontext_http_test_server/BUILD +++ b/ext/test/w3c_tracecontext_http_test_server/BUILD @@ -19,7 +19,9 @@ 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", "//sdk/src/trace", "@curl",