diff --git a/CHANGELOG.md b/CHANGELOG.md index a1c997fd35..f0cf628784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,23 @@ Increment the: Breaking changes: +* [BUILD] Install an explicit list of ext headers instead of the whole + directory + [#4327](https://github.com/open-telemetry/opentelemetry-cpp/pull/4327) + * The `ext_common` component installed `include/opentelemetry/ext` with a + `*.h` glob. It now installs a named list, and these five headers are no + longer part of the package: + * `opentelemetry/ext/http/client/curl/http_client_curl.h` + * `opentelemetry/ext/http/client/curl/http_operation_curl.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 them from an installed package will no longer + compile. A curl client is created through `http_client_factory_curl.h`, + which needs only the abstract `http_client_factory.h`. The two server + headers are an embedded test server; moving them out of `ext` is tracked + in #4332. + * [METRICS SDK] Rename Base2 Exponential Histogram Aggregation config field [#4253](https://github.com/open-telemetry/opentelemetry-cpp/pull/4253) * The public configuration member `max_buckets_` was renamed to `max_size_` to diff --git a/examples/http/CMakeLists.txt b/examples/http/CMakeLists.txt index ffc286354c..d8110b958b 100644 --- a/examples/http/CMakeLists.txt +++ b/examples/http/CMakeLists.txt @@ -14,4 +14,7 @@ if(WITH_HTTP_CLIENT_CURL) http_server PRIVATE opentelemetry-cpp::trace opentelemetry-cpp::http_client_curl opentelemetry-cpp::ostream_span_exporter) + if(WIN32) + target_link_libraries(http_server PRIVATE ws2_32) + endif() endif() diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index d43f12dfc3..25d45c72e0 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -1014,6 +1014,9 @@ if(BUILD_TESTING) nlohmann_json::nlohmann_json protobuf::libprotobuf opentelemetry_test_common) + if(WIN32) + target_link_libraries(otlp_http_exporter_test ws2_32) + endif() gtest_add_tests( TARGET otlp_http_exporter_test TEST_PREFIX exporter.otlp. @@ -1041,6 +1044,9 @@ if(BUILD_TESTING) opentelemetry_http_client_nosend nlohmann_json::nlohmann_json opentelemetry_test_common) + if(WIN32) + target_link_libraries(otlp_http_log_record_exporter_test ws2_32) + endif() gtest_add_tests( TARGET otlp_http_log_record_exporter_test TEST_PREFIX exporter.otlp. diff --git a/exporters/zipkin/CMakeLists.txt b/exporters/zipkin/CMakeLists.txt index b90b1177ce..46fbecb1c1 100644 --- a/exporters/zipkin/CMakeLists.txt +++ b/exporters/zipkin/CMakeLists.txt @@ -74,6 +74,9 @@ if(BUILD_TESTING) opentelemetry_resources opentelemetry_http_client_nosend CURL::libcurl) + if(WIN32) + target_link_libraries(zipkin_exporter_test ws2_32) + endif() gtest_add_tests( TARGET zipkin_exporter_test diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index 39a97c4dea..db7fbaf1d5 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -10,14 +10,21 @@ target_include_directories( set_target_properties(opentelemetry_ext PROPERTIES EXPORT_NAME "ext") target_link_libraries(opentelemetry_ext INTERFACE opentelemetry_api) -# The embedded HTTP server headers (socket_tools.h) call Winsock, so declare the -# dependency on the interface target. MSVC also autolinks via #pragma -# comment(lib), but MinGW/GCC ignore that, so consumers there would otherwise -# fail to resolve inet_pton/WSAStartup. -if(WIN32) - target_link_libraries(opentelemetry_ext INTERFACE ws2_32) -endif() - +# client/detail/default_factory.h is an internal helper included by exporter +# sources rather than by any public header. client/curl/http_client_curl.h and +# client/curl/http_operation_curl.h are the curl implementation, reached through +# http_client_factory_curl.h, which depends on the abstract +# http_client_factory.h alone. server/http_server.h and server/socket_tools.h +# are the embedded server used by tests and the http example. +# +# The two directory excludes are what keeps client/detail and server out of the +# install tree entirely: install(DIRECTORY) creates a destination directory for +# every source directory it walks, so filtering on file names alone would leave +# both behind, empty. +# +# TODO: the embedded server headers do not belong beside the user facing ones +# under ext/include. Move them to an internal location such as test_common, see +# #4332. otel_add_component( COMPONENT ext_common @@ -29,7 +36,19 @@ otel_add_component( "include/opentelemetry" FILES_MATCHING PATTERN - "*.h") + "http_client.h" + PATTERN + "http_client_factory.h" + PATTERN + "http_client_factory_curl.h" + PATTERN + "url_parser.h" + PATTERN + "detail" + EXCLUDE + PATTERN + "server" + EXCLUDE) add_subdirectory(src) diff --git a/ext/test/http/CMakeLists.txt b/ext/test/http/CMakeLists.txt index 14d6aee613..fcf95c4d33 100644 --- a/ext/test/http/CMakeLists.txt +++ b/ext/test/http/CMakeLists.txt @@ -8,6 +8,9 @@ if(WITH_HTTP_CLIENT_CURL) ${FILENAME} PRIVATE ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES} opentelemetry_http_client_curl opentelemetry_common CURL::libcurl) + if(WIN32) + target_link_libraries(${FILENAME} PRIVATE ws2_32) + endif() gtest_add_tests( TARGET ${FILENAME} TEST_PREFIX ext.http.curl. @@ -18,9 +21,11 @@ set(SOCKET_TOOLS_FILENAME socket_tools_test) add_executable(${SOCKET_TOOLS_FILENAME} ${SOCKET_TOOLS_FILENAME}.cc) target_link_libraries(${SOCKET_TOOLS_FILENAME} opentelemetry_ext ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) -# ws2_32 is now an interface dependency of opentelemetry_ext, so it is inherited -# here; the test thus verifies the public target's usage requirements rather -# than papering over them locally. +# socket_tools.h calls Winsock, and the ext interface target no longer carries +# that link because it is only needed where the embedded server is compiled. +if(WIN32) + target_link_libraries(${SOCKET_TOOLS_FILENAME} ws2_32) +endif() gtest_add_tests( TARGET ${SOCKET_TOOLS_FILENAME} TEST_PREFIX ext.http.sockettools. diff --git a/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt b/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt index 064b186037..24cd3b6099 100644 --- a/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt +++ b/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt @@ -8,4 +8,7 @@ if(WITH_HTTP_CLIENT_CURL) PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace opentelemetry_http_client_curl opentelemetry_exporter_ostream_span CURL::libcurl nlohmann_json::nlohmann_json) + if(WIN32) + target_link_libraries(w3c_tracecontext_http_test_server PRIVATE ws2_32) + endif() endif() diff --git a/install/test/cmake/examples_test/CMakeLists.txt b/install/test/cmake/examples_test/CMakeLists.txt index 798a9124f2..30bd94bfe9 100644 --- a/install/test/cmake/examples_test/CMakeLists.txt +++ b/install/test/cmake/examples_test/CMakeLists.txt @@ -46,10 +46,10 @@ if("exporters_etw" IN_LIST OPENTELEMETRY_CPP_COMPONENTS_INSTALLED) set(WITH_ETW ON) endif() -if("ext_http_curl" IN_LIST OPENTELEMETRY_CPP_COMPONENTS_INSTALLED) - set(WITH_EXAMPLES_HTTP ON) - set(WITH_HTTP_CLIENT_CURL ON) -endif() +# The http example uses the embedded server headers, which the package no longer +# installs. The ext headers it does use are covered by +# install/test/src/test_ext_*.cc. +set(WITH_EXAMPLES_HTTP OFF) if("configuration" IN_LIST OPENTELEMETRY_CPP_COMPONENTS_INSTALLED) set(WITH_CONFIGURATION ON)