From 35a7bd03461d65fc02ea82689fb67a7757cb2167 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 23 Nov 2023 15:17:25 +0200 Subject: [PATCH 01/10] opentelemetry-cpp: drop old versions, bump deps --- recipes/opentelemetry-cpp/all/conandata.yml | 35 ---------- recipes/opentelemetry-cpp/all/conanfile.py | 69 ++++++++----------- .../all/patches/1.0.1-0001-fix-cmake.patch | 28 -------- .../all/patches/1.2.0-0001-fix-cmake.patch | 15 ---- .../all/patches/1.3.0-0001-fix-cmake.patch | 27 -------- .../all/patches/1.4.0-0001-fix-cmake.patch | 27 -------- recipes/opentelemetry-cpp/config.yml | 10 --- 7 files changed, 28 insertions(+), 183 deletions(-) delete mode 100644 recipes/opentelemetry-cpp/all/patches/1.0.1-0001-fix-cmake.patch delete mode 100644 recipes/opentelemetry-cpp/all/patches/1.2.0-0001-fix-cmake.patch delete mode 100644 recipes/opentelemetry-cpp/all/patches/1.3.0-0001-fix-cmake.patch delete mode 100644 recipes/opentelemetry-cpp/all/patches/1.4.0-0001-fix-cmake.patch diff --git a/recipes/opentelemetry-cpp/all/conandata.yml b/recipes/opentelemetry-cpp/all/conandata.yml index 2342d2e0da093..86f8cbee7d4d6 100644 --- a/recipes/opentelemetry-cpp/all/conandata.yml +++ b/recipes/opentelemetry-cpp/all/conandata.yml @@ -11,21 +11,6 @@ sources: "1.6.1": url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.6.1.tar.gz" sha256: "1fc371be049b3220b8b9571c8b713f03e9a84f3c5684363f64ccc814638391a5" - "1.4.1": - url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.4.1.tar.gz" - sha256: "301b1ab74a664723560f46c29f228360aff1e2d63e930b963755ea077ae67524" - "1.4.0": - url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.4.0.tar.gz" - sha256: "110f4fb2e38dcc72a421647631cfbb9429afd3c77c6c98829cc1d11bd0c72563" - "1.3.0": - url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.3.0.tar.gz" - sha256: "6a4c43b9c9f753841ebc0fe2717325271f02e2a1d5ddd0b52735c35243629ab3" - "1.2.0": - url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.2.0.tar.gz" - sha256: "7a6420f9e4fa44b81a5b06e30e5e116da71decc9086e5cc4f126e1efc8a397c2" - "1.0.1": - url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.0.1.tar.gz" - sha256: "32f12ff15ec257e3462883f84bc291c2d5dc30055604c12ec4b46a36dfa3f189" patches: "1.9.1": @@ -44,23 +29,3 @@ patches: - patch_file: "patches/1.6.1-0001-fix-cmake.patch" patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" patch_type: "conan" - "1.4.1": - - patch_file: "patches/1.4.0-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" - "1.4.0": - - patch_file: "patches/1.4.0-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" - "1.3.0": - - patch_file: "patches/1.3.0-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" - "1.2.0": - - patch_file: "patches/1.2.0-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" - "1.0.1": - - patch_file: "patches/1.0.1-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 7d1799e99839a..50f02d41cd1e0 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -10,7 +10,7 @@ import os import textwrap -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.56.0 <2 || >=2.0.6" class OpenTelemetryCppConan(ConanFile): name = "opentelemetry-cpp" @@ -93,17 +93,14 @@ def requirements(self): self.requires("ms-gsl/4.0.0") if self.options.with_abseil: - self.requires("abseil/20220623.0", transitive_headers=True) + self.requires("abseil/20230125.3", transitive_headers=True) if self.options.with_otlp: - self.requires("protobuf/3.21.9") - if Version(self.version) <= "1.4.1": - self.requires("opentelemetry-proto/0.11.0") - else: - self.requires("opentelemetry-proto/0.20.0") + self.requires("protobuf/3.21.12") + self.requires("opentelemetry-proto/0.20.0") if self.options.get_safe("with_otlp_grpc"): - self.requires("grpc/1.50.1") + self.requires("grpc/1.54.3") if (self.options.with_zipkin or self.options.with_elasticsearch or @@ -117,20 +114,18 @@ def requirements(self): self.options.with_elasticsearch or self.options.get_safe("with_otlp_http") ): - self.requires("libcurl/8.1.1") + self.requires("libcurl/[>=7.78.0 <9]") if self.options.with_prometheus: self.requires("prometheus-cpp/1.1.0") if self.options.with_jaeger: self.requires("thrift/0.17.0") - - if Version(self.version) >= "1.3.0": - self.requires("boost/1.82.0") + self.requires("boost/1.82.0") @property def _required_boost_components(self): - return ["locale"] if self.options.with_jaeger and Version(self.version) >= "1.3.0" else [] + return ["locale"] if self.options.with_jaeger else [] def validate(self): if self.settings.get_safe("compiler.cppstd"): @@ -161,9 +156,9 @@ def validate(self): def build_requirements(self): if self.options.with_otlp: - self.tool_requires("protobuf/3.21.9") + self.tool_requires("protobuf/") if self.options.get_safe("with_otlp_grpc"): - self.tool_requires("grpc/1.50.1") + self.tool_requires("grpc/") def _create_cmake_module_variables(self, module_file): content = textwrap.dedent("""\ @@ -222,11 +217,10 @@ def _patch_sources(self): self.source_folder, "cmake", "opentelemetry-proto.cmake") - if Version(self.version) >= "1.1.0": - replace_in_file(self, - protos_cmake_path, - "if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)", - "if(1)") + replace_in_file(self, + protos_cmake_path, + "if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)", + "if(1)") if Version(self.version) < "1.9.0": replace_in_file(self, protos_cmake_path, @@ -272,7 +266,7 @@ def _otel_build_modules(self): @property def _http_client_name(self): - return "http_client_curl" if Version(self.version) < "1.3.0" else "opentelemetry_http_client_curl" + return "opentelemetry_http_client_curl" @property def _otel_libraries(self): @@ -295,8 +289,7 @@ def _otel_libraries(self): if self.options.get_safe("with_otlp_grpc"): libraries.append("opentelemetry_exporter_otlp_grpc") - if Version(self.version) >= "1.5.0": - libraries.append("opentelemetry_exporter_otlp_grpc_metrics") + libraries.append("opentelemetry_exporter_otlp_grpc_metrics") if Version(self.version) >= "1.7.0": libraries.append("opentelemetry_exporter_otlp_grpc_client") @@ -307,11 +300,9 @@ def _otel_libraries(self): if self.options.get_safe("with_otlp_http"): libraries.append("opentelemetry_exporter_otlp_http") - if Version(self.version) >= "1.1.0": - libraries.append("opentelemetry_exporter_otlp_http_client") + libraries.append("opentelemetry_exporter_otlp_http_client") - if Version(self.version) >= "1.5.0": - libraries.append("opentelemetry_exporter_otlp_http_metric") + libraries.append("opentelemetry_exporter_otlp_http_metric") if self.options.with_logs_preview: libraries.append("opentelemetry_exporter_otlp_http_log") @@ -328,11 +319,9 @@ def _otel_libraries(self): if self.options.with_jaeger: libraries.append("opentelemetry_exporter_jaeger_trace") - if Version(self.version) >= "1.2.0": - libraries.append("opentelemetry_metrics") + libraries.append("opentelemetry_metrics") - if Version(self.version) >= "1.4.0": - libraries.append("opentelemetry_exporter_ostream_metrics") + libraries.append("opentelemetry_exporter_ostream_metrics") if self.options.with_logs_preview: libraries.extend([ @@ -404,7 +393,7 @@ def package_info(self): ]) if self.options.get_safe("with_otlp_grpc"): - if Version(self.version) >= "1.5.0" and Version(self.version) < "1.7.0": + if "1.5.0" <= Version(self.version) < "1.7.0": self.cpp_info.components["opentelemetry_exporter_otlp_grpc_metrics"].requires.extend([ "grpc::grpc++", "opentelemetry_otlp_recordable", @@ -457,11 +446,10 @@ def package_info(self): "opentelemetry_exporter_otlp_http_client", ]) - if Version(self.version) >= "1.5.0": - self.cpp_info.components["opentelemetry_exporter_otlp_http_metric"].requires.extend([ - "opentelemetry_otlp_recordable", - "opentelemetry_exporter_otlp_http_client" - ]) + self.cpp_info.components["opentelemetry_exporter_otlp_http_metric"].requires.extend([ + "opentelemetry_otlp_recordable", + "opentelemetry_exporter_otlp_http_client" + ]) if self.options.with_logs_preview: self.cpp_info.components["opentelemetry_exporter_otlp_http_log"].requires.extend([ @@ -484,10 +472,9 @@ def package_info(self): "thrift::thrift", ]) - if Version(self.version) >= "1.3.0": - self.cpp_info.components["opentelemetry_exporter_jaeger_trace"].requires.append( - "boost::locale" - ) + self.cpp_info.components["opentelemetry_exporter_jaeger_trace"].requires.append( + "boost::locale" + ) if self.settings.os == "Windows" and self.options.with_etw: self.cpp_info.components["opentelemetry_exporter_etw"].libs = [] diff --git a/recipes/opentelemetry-cpp/all/patches/1.0.1-0001-fix-cmake.patch b/recipes/opentelemetry-cpp/all/patches/1.0.1-0001-fix-cmake.patch deleted file mode 100644 index ecdbb0cf0f9fc..0000000000000 --- a/recipes/opentelemetry-cpp/all/patches/1.0.1-0001-fix-cmake.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake -index 9fb6f49..1f1547e 100644 ---- a/cmake/opentelemetry-proto.cmake -+++ b/cmake/opentelemetry-proto.cmake -@@ -162,6 +162,10 @@ else() # cmake 3.8 or lower - target_link_libraries(opentelemetry_proto INTERFACE ${Protobuf_LIBRARIES}) - endif() - -+if(TARGET gRPC::grpc++) -+ target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++) -+endif() -+ - if(BUILD_SHARED_LIBS) - set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON) - endif() -diff --git a/exporters/zipkin/CMakeLists.txt b/exporters/zipkin/CMakeLists.txt -index 2316860..8995b31 100644 ---- a/exporters/zipkin/CMakeLists.txt -+++ b/exporters/zipkin/CMakeLists.txt -@@ -21,7 +21,7 @@ add_library(opentelemetry_exporter_zipkin_trace src/zipkin_exporter.cc - src/recordable.cc) - - target_link_libraries(opentelemetry_exporter_zipkin_trace -- PUBLIC opentelemetry_trace http_client_curl) -+ PUBLIC opentelemetry_trace http_client_curl nlohmann_json::nlohmann_json) - - install( - TARGETS opentelemetry_exporter_zipkin_trace diff --git a/recipes/opentelemetry-cpp/all/patches/1.2.0-0001-fix-cmake.patch b/recipes/opentelemetry-cpp/all/patches/1.2.0-0001-fix-cmake.patch deleted file mode 100644 index 275e2c9b44a66..0000000000000 --- a/recipes/opentelemetry-cpp/all/patches/1.2.0-0001-fix-cmake.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake -index 8d8f868..2a78f98 100644 ---- a/cmake/opentelemetry-proto.cmake -+++ b/cmake/opentelemetry-proto.cmake -@@ -214,6 +214,10 @@ else() - ${METRICS_SERVICE_PB_CPP_FILE}) - endif() - -+if(TARGET gRPC::grpc++) -+ target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++) -+endif() -+ - if(needs_proto_download) - add_dependencies(opentelemetry_proto opentelemetry-proto) - endif() diff --git a/recipes/opentelemetry-cpp/all/patches/1.3.0-0001-fix-cmake.patch b/recipes/opentelemetry-cpp/all/patches/1.3.0-0001-fix-cmake.patch deleted file mode 100644 index ce868fbedca22..0000000000000 --- a/recipes/opentelemetry-cpp/all/patches/1.3.0-0001-fix-cmake.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 09c21fd..a8d7d16 100755 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -203,7 +203,6 @@ if(WITH_JAEGER) - find_package(Thrift QUIET) - if(Thrift_FOUND) - find_package(Boost REQUIRED) -- include_directories(${Boost_INCLUDE_DIR}) - else() - # Install Thrift and propagate via vcpkg toolchain file - if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) -diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake -index 8d8f868..2a78f98 100644 ---- a/cmake/opentelemetry-proto.cmake -+++ b/cmake/opentelemetry-proto.cmake -@@ -214,6 +214,10 @@ else() - ${METRICS_SERVICE_PB_CPP_FILE}) - endif() - -+if(TARGET gRPC::grpc++) -+ target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++) -+endif() -+ - if(needs_proto_download) - add_dependencies(opentelemetry_proto opentelemetry-proto) - endif() diff --git a/recipes/opentelemetry-cpp/all/patches/1.4.0-0001-fix-cmake.patch b/recipes/opentelemetry-cpp/all/patches/1.4.0-0001-fix-cmake.patch deleted file mode 100644 index 1fcf5a0427738..0000000000000 --- a/recipes/opentelemetry-cpp/all/patches/1.4.0-0001-fix-cmake.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 6d2b274..4611a6b 100755 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -208,7 +208,6 @@ if(WITH_JAEGER) - find_package(Thrift QUIET) - if(Thrift_FOUND) - find_package(Boost REQUIRED) -- include_directories(${Boost_INCLUDE_DIR}) - else() - # Install Thrift and propagate via vcpkg toolchain file - if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) -diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake -index 37d45da..89395c0 100644 ---- a/cmake/opentelemetry-proto.cmake -+++ b/cmake/opentelemetry-proto.cmake -@@ -215,6 +215,10 @@ else() - ${METRICS_SERVICE_PB_CPP_FILE}) - endif() - -+if(TARGET gRPC::grpc++) -+ target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++) -+endif() -+ - if(needs_proto_download) - add_dependencies(opentelemetry_proto opentelemetry-proto) - endif() diff --git a/recipes/opentelemetry-cpp/config.yml b/recipes/opentelemetry-cpp/config.yml index 8429e67e0bca0..40bbcbc049f29 100644 --- a/recipes/opentelemetry-cpp/config.yml +++ b/recipes/opentelemetry-cpp/config.yml @@ -7,13 +7,3 @@ versions: folder: all "1.6.1": folder: all - "1.4.1": - folder: all - "1.4.0": - folder: all - "1.3.0": - folder: all - "1.2.0": - folder: all - "1.0.1": - folder: all From 94f387ff865e2ea62794a6c98b18823c11ce0419 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 23 Nov 2023 15:48:26 +0200 Subject: [PATCH 02/10] opentelemetry-cpp: fix with_otlp=False handling --- recipes/opentelemetry-cpp/all/conanfile.py | 93 +++++++++------------- 1 file changed, 39 insertions(+), 54 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 50f02d41cd1e0..d3cabb929b305 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -5,7 +5,7 @@ from conan.tools.scm import Version from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.microsoft import check_min_vs -from conan.tools.env import Environment +from conan.tools.env import VirtualRunEnv, VirtualBuildEnv import os import textwrap @@ -135,12 +135,6 @@ def validate(self): if self.settings.os != "Linux" and self.options.shared: raise ConanInvalidConfiguration(f"{self.ref} supports building shared libraries only on Linux") - if self.options.get_safe("with_otlp_grpc") and not self.options.with_otlp: - raise ConanInvalidConfiguration("Option 'with_otlp_grpc' requires 'with_otlp'") - - if self.options.get_safe("with_otlp_http") and not self.options.with_otlp: - raise ConanInvalidConfiguration("Option 'with_otlp_http' requires 'with_otlp'") - if self.options.get_safe("with_otlp_grpc"): if not self.dependencies["grpc"].options.cpp_plugin: raise ConanInvalidConfiguration(f"{self.ref} requires grpc with cpp_plugin=True") @@ -175,62 +169,53 @@ def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): - tc = CMakeToolchain(self) + VirtualBuildEnv(self).generate(scope="build") + VirtualRunEnv(self).generate(scope="build") - tc.variables["BUILD_TESTING"] = False - tc.variables["BUILD_BENCHMARK"] = False - - tc.variables["WITH_EXAMPLES"] = False - tc.variables["WITH_NO_DEPRECATED_CODE"] = self.options.with_no_deprecated_code - tc.variables["WITH_STL"] = self.options.with_stl - tc.variables["WITH_GSL"] = self.options.with_gsl - tc.variables["WITH_ABSEIL"] = self.options.with_abseil - tc.variables["WITH_OTLP"] = self.options.with_otlp - tc.variables["WITH_OTLP_GRPC"] = self.options.get_safe("with_otlp_grpc") - tc.variables["WITH_OTLP_HTTP"] = self.options.get_safe("with_otlp_http") - tc.variables["WITH_ZIPKIN"] = self.options.with_zipkin - tc.variables["WITH_PROMETHEUS"] = self.options.with_prometheus - tc.variables["WITH_ELASTICSEARCH"] = self.options.with_elasticsearch - tc.variables["WITH_ZPAGES"] = self.options.with_zpages - tc.variables["WITH_JAEGER"] = self.options.with_jaeger - tc.variables["WITH_NO_GETENV"] = self.options.with_no_getenv - tc.variables["WITH_ETW"] = self.options.with_etw - tc.variables["WITH_LOGS_PREVIEW"] = self.options.with_logs_preview - tc.variables["WITH_ASYNC_EXPORT_PREVIEW"] = self.options.with_async_export_preview - tc.variables["WITH_METRICS_EXEMPLAR_PREVIEW"] = self.options.with_metrics_exemplar_preview + tc = CMakeToolchain(self) + tc.cache_variables["BUILD_TESTING"] = False + tc.cache_variables["BUILD_BENCHMARK"] = False + tc.cache_variables["WITH_EXAMPLES"] = False + tc.cache_variables["WITH_NO_DEPRECATED_CODE"] = self.options.with_no_deprecated_code + tc.cache_variables["WITH_STL"] = self.options.with_stl + tc.cache_variables["WITH_GSL"] = self.options.with_gsl + tc.cache_variables["WITH_ABSEIL"] = self.options.with_abseil + tc.cache_variables["WITH_OTLP"] = self.options.with_otlp + tc.cache_variables["WITH_OTLP_GRPC"] = self.options.get_safe("with_otlp_grpc", False) + tc.cache_variables["WITH_OTLP_HTTP"] = self.options.get_safe("with_otlp_http", False) + tc.cache_variables["WITH_ZIPKIN"] = self.options.with_zipkin + tc.cache_variables["WITH_PROMETHEUS"] = self.options.with_prometheus + tc.cache_variables["WITH_ELASTICSEARCH"] = self.options.with_elasticsearch + tc.cache_variables["WITH_ZPAGES"] = self.options.with_zpages + tc.cache_variables["WITH_JAEGER"] = self.options.with_jaeger + tc.cache_variables["WITH_NO_GETENV"] = self.options.with_no_getenv + tc.cache_variables["WITH_ETW"] = self.options.with_etw + tc.cache_variables["WITH_LOGS_PREVIEW"] = self.options.with_logs_preview + tc.cache_variables["WITH_ASYNC_EXPORT_PREVIEW"] = self.options.with_async_export_preview + tc.cache_variables["WITH_METRICS_EXEMPLAR_PREVIEW"] = self.options.with_metrics_exemplar_preview tc.generate() tc = CMakeDeps(self) tc.generate() - if self.settings.os == "Linux": - env = Environment() - if self.dependencies["grpc"].options.shared: - env.append_path("LD_LIBRARY_PATH", os.path.join(self.dependencies["grpc"].package_folder, "lib")) - if self.dependencies["protobuf"].options.shared: - env.append_path("LD_LIBRARY_PATH", os.path.join(self.dependencies["protobuf"].package_folder, "lib")) - env.vars(self).save_script("conanbuild_loadpath") - def _patch_sources(self): - protos_path = self.dependencies["opentelemetry-proto"].conf_info.get("user.opentelemetry-proto:proto_root").replace("\\", "/") - protos_cmake_path = os.path.join( - self.source_folder, - "cmake", - "opentelemetry-proto.cmake") - replace_in_file(self, - protos_cmake_path, - "if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)", - "if(1)") - if Version(self.version) < "1.9.0": - replace_in_file(self, - protos_cmake_path, - "set(PROTO_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto\")", - f"set(PROTO_PATH \"{protos_path}\")") - else: + if self.options.with_otlp: + protos_path = self.dependencies["opentelemetry-proto"].conf_info.get("user.opentelemetry-proto:proto_root").replace("\\", "/") + protos_cmake_path = os.path.join(self.source_folder, "cmake", "opentelemetry-proto.cmake") replace_in_file(self, protos_cmake_path, - "\"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto\")", - f"\"{protos_path}\")") + "if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)", + "if(1)") + if Version(self.version) < "1.9.0": + replace_in_file(self, + protos_cmake_path, + "set(PROTO_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto\")", + f"set(PROTO_PATH \"{protos_path}\")") + else: + replace_in_file(self, + protos_cmake_path, + "\"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto\")", + f"\"{protos_path}\")") rmdir(self, os.path.join(self.source_folder, "api", "include", "opentelemetry", "nostd", "absl")) From 8aa88508123d284fb1de6f51c463bd12d6855cea Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 23 Nov 2023 16:07:56 +0200 Subject: [PATCH 03/10] opentelemetry-cpp: fix opentelemetry-proto usage Fixes #18967. --- recipes/opentelemetry-cpp/all/conanfile.py | 83 +++++++++++----------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index d3cabb929b305..4894f2960fc72 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -4,7 +4,6 @@ from conan.tools.build import check_min_cppstd from conan.tools.scm import Version from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.microsoft import check_min_vs from conan.tools.env import VirtualRunEnv, VirtualBuildEnv import os @@ -67,9 +66,27 @@ class OpenTelemetryCppConan(ConanFile): short_paths = True @property - def _minimum_cpp_standard(self): + def _min_cppstd(self): + if self.options.with_abseil and Version(self.dependencies["abseil"].ref.version) >= "20230125": + return 14 return 11 + @property + def _compilers_minimum_version(self): + if self._min_cppstd == 14: + return { + "gcc": "6", + "clang": "5", + "apple-clang": "10", + "Visual Studio": "16", + "msvc": "192", + } + else: + return { + "Visual Studio": "16", + "msvc": "192", + } + def export_sources(self): export_conandata_patches(self) @@ -97,8 +114,6 @@ def requirements(self): if self.options.with_otlp: self.requires("protobuf/3.21.12") - self.requires("opentelemetry-proto/0.20.0") - if self.options.get_safe("with_otlp_grpc"): self.requires("grpc/1.54.3") @@ -128,9 +143,13 @@ def _required_boost_components(self): return ["locale"] if self.options.with_jaeger else [] def validate(self): - if self.settings.get_safe("compiler.cppstd"): - check_min_cppstd(self, self._minimum_cpp_standard) - check_min_vs(self, "192") + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) if self.settings.os != "Linux" and self.options.shared: raise ConanInvalidConfiguration(f"{self.ref} supports building shared libraries only on Linux") @@ -150,6 +169,7 @@ def validate(self): def build_requirements(self): if self.options.with_otlp: + self.tool_requires("opentelemetry-proto/1.0.0") self.tool_requires("protobuf/") if self.options.get_safe("with_otlp_grpc"): self.tool_requires("grpc/") @@ -193,6 +213,8 @@ def generate(self): tc.cache_variables["WITH_LOGS_PREVIEW"] = self.options.with_logs_preview tc.cache_variables["WITH_ASYNC_EXPORT_PREVIEW"] = self.options.with_async_export_preview tc.cache_variables["WITH_METRICS_EXEMPLAR_PREVIEW"] = self.options.with_metrics_exemplar_preview + if not self.settings.compiler.cppstd: + tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd tc.generate() tc = CMakeDeps(self) @@ -200,25 +222,21 @@ def generate(self): def _patch_sources(self): if self.options.with_otlp: - protos_path = self.dependencies["opentelemetry-proto"].conf_info.get("user.opentelemetry-proto:proto_root").replace("\\", "/") + protos_path = self.dependencies.build["opentelemetry-proto"].conf_info.get("user.opentelemetry-proto:proto_root").replace("\\", "/") protos_cmake_path = os.path.join(self.source_folder, "cmake", "opentelemetry-proto.cmake") - replace_in_file(self, - protos_cmake_path, - "if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)", - "if(1)") + replace_in_file(self, protos_cmake_path, + "if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)", + "if(1)") if Version(self.version) < "1.9.0": - replace_in_file(self, - protos_cmake_path, - "set(PROTO_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto\")", - f"set(PROTO_PATH \"{protos_path}\")") + replace_in_file(self, protos_cmake_path, + 'set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")', + f'set(PROTO_PATH "{protos_path}")') else: - replace_in_file(self, - protos_cmake_path, - "\"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto\")", - f"\"{protos_path}\")") + replace_in_file(self, protos_cmake_path, + '"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")', + f'"{protos_path}")') rmdir(self, os.path.join(self.source_folder, "api", "include", "opentelemetry", "nostd", "absl")) - apply_conandata_patches(self) def build(self): @@ -264,59 +282,41 @@ def _otel_libraries(self): "opentelemetry_trace", "opentelemetry_version", ] - if self.options.with_otlp: libraries.extend([ "opentelemetry_proto", "opentelemetry_otlp_recordable", ]) - if self.options.get_safe("with_otlp_grpc"): libraries.append("opentelemetry_exporter_otlp_grpc") - libraries.append("opentelemetry_exporter_otlp_grpc_metrics") - if Version(self.version) >= "1.7.0": libraries.append("opentelemetry_exporter_otlp_grpc_client") - if self.options.with_logs_preview: libraries.append("opentelemetry_exporter_otlp_grpc_log") - if self.options.get_safe("with_otlp_http"): libraries.append("opentelemetry_exporter_otlp_http") - libraries.append("opentelemetry_exporter_otlp_http_client") - libraries.append("opentelemetry_exporter_otlp_http_metric") - if self.options.with_logs_preview: libraries.append("opentelemetry_exporter_otlp_http_log") - if self.options.with_prometheus: libraries.append("opentelemetry_exporter_prometheus") - if self.options.with_elasticsearch and self.options.with_logs_preview: libraries.append("opentelemetry_exporter_elasticsearch_logs") - if self.options.with_zipkin: libraries.append("opentelemetry_exporter_zipkin_trace") - if self.options.with_jaeger: libraries.append("opentelemetry_exporter_jaeger_trace") - libraries.append("opentelemetry_metrics") - libraries.append("opentelemetry_exporter_ostream_metrics") - if self.options.with_logs_preview: libraries.extend([ "opentelemetry_logs", "opentelemetry_exporter_ostream_logs", ]) - if self.settings.os == "Windows" and self.options.with_etw: libraries.append("opentelemetry_exporter_etw") - return libraries def package_info(self): @@ -366,10 +366,7 @@ def package_info(self): self.cpp_info.components["opentelemetry_common"].requires.append("abseil::abseil") if self.options.with_otlp: - self.cpp_info.components["opentelemetry_proto"].requires.extend([ - "opentelemetry-proto::opentelemetry-proto", - "protobuf::protobuf", - ]) + self.cpp_info.components["opentelemetry_proto"].requires.append("protobuf::protobuf") self.cpp_info.components["opentelemetry_otlp_recordable"].requires.extend([ "opentelemetry_proto", From 8193d96039628d045b41c602a8c819263d3f1b3b Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 23 Nov 2023 16:15:07 +0200 Subject: [PATCH 04/10] opentelemetry-cpp: simplify patching --- recipes/opentelemetry-cpp/all/conandata.yml | 18 ------------- recipes/opentelemetry-cpp/all/conanfile.py | 13 +++++---- .../all/patches/1.6.1-0001-fix-cmake.patch | 27 ------------------- .../all/patches/1.7.0-0001-fix-cmake.patch | 27 ------------------- .../all/patches/1.8.1-0001-fix-cmake.patch | 27 ------------------- .../all/patches/1.9.1-0001-fix-cmake.patch | 27 ------------------- 6 files changed, 6 insertions(+), 133 deletions(-) delete mode 100644 recipes/opentelemetry-cpp/all/patches/1.6.1-0001-fix-cmake.patch delete mode 100644 recipes/opentelemetry-cpp/all/patches/1.7.0-0001-fix-cmake.patch delete mode 100644 recipes/opentelemetry-cpp/all/patches/1.8.1-0001-fix-cmake.patch delete mode 100644 recipes/opentelemetry-cpp/all/patches/1.9.1-0001-fix-cmake.patch diff --git a/recipes/opentelemetry-cpp/all/conandata.yml b/recipes/opentelemetry-cpp/all/conandata.yml index 86f8cbee7d4d6..18e2c291f0819 100644 --- a/recipes/opentelemetry-cpp/all/conandata.yml +++ b/recipes/opentelemetry-cpp/all/conandata.yml @@ -11,21 +11,3 @@ sources: "1.6.1": url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.6.1.tar.gz" sha256: "1fc371be049b3220b8b9571c8b713f03e9a84f3c5684363f64ccc814638391a5" - -patches: - "1.9.1": - - patch_file: "patches/1.9.1-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" - "1.8.1": - - patch_file: "patches/1.8.1-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" - "1.7.0": - - patch_file: "patches/1.7.0-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" - "1.6.1": - - patch_file: "patches/1.6.1-0001-fix-cmake.patch" - patch_description: "fix lack of linking libraries due to conan not generating the variables that are expected" - patch_type: "conan" diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 4894f2960fc72..70050d5b4a685 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir, replace_in_file, save +from conan.tools.files import get, copy, rmdir, replace_in_file, save from conan.tools.build import check_min_cppstd from conan.tools.scm import Version from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout @@ -87,9 +87,6 @@ def _compilers_minimum_version(self): "msvc": "192", } - def export_sources(self): - export_conandata_patches(self) - def config_options(self): if self.settings.os == "Windows": self.options.rm_safe("fPIC") @@ -217,8 +214,9 @@ def generate(self): tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd tc.generate() - tc = CMakeDeps(self) - tc.generate() + deps = CMakeDeps(self) + + deps.generate() def _patch_sources(self): if self.options.with_otlp: @@ -231,13 +229,14 @@ def _patch_sources(self): replace_in_file(self, protos_cmake_path, 'set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")', f'set(PROTO_PATH "{protos_path}")') + if self.options.get_safe("with_otlp_grpc"): + save(self, protos_cmake_path, "\ntarget_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++)", append=True) else: replace_in_file(self, protos_cmake_path, '"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")', f'"{protos_path}")') rmdir(self, os.path.join(self.source_folder, "api", "include", "opentelemetry", "nostd", "absl")) - apply_conandata_patches(self) def build(self): self._patch_sources() diff --git a/recipes/opentelemetry-cpp/all/patches/1.6.1-0001-fix-cmake.patch b/recipes/opentelemetry-cpp/all/patches/1.6.1-0001-fix-cmake.patch deleted file mode 100644 index b3391855652c4..0000000000000 --- a/recipes/opentelemetry-cpp/all/patches/1.6.1-0001-fix-cmake.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index a1b6934..d4f5251 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -209,7 +209,6 @@ if(WITH_JAEGER) - find_package(Thrift QUIET) - if(Thrift_FOUND) - find_package(Boost REQUIRED) -- include_directories(${Boost_INCLUDE_DIR}) - else() - # Install Thrift and propagate via vcpkg toolchain file - if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) -diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake -index 629ea81..3b09b92 100644 ---- a/cmake/opentelemetry-proto.cmake -+++ b/cmake/opentelemetry-proto.cmake -@@ -242,6 +242,10 @@ else() # cmake 3.8 or lower - target_link_libraries(opentelemetry_proto INTERFACE ${Protobuf_LIBRARIES}) - endif() - -+if(TARGET gRPC::grpc++) -+ target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++) -+endif() -+ - if(BUILD_SHARED_LIBS) - set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON) - endif() diff --git a/recipes/opentelemetry-cpp/all/patches/1.7.0-0001-fix-cmake.patch b/recipes/opentelemetry-cpp/all/patches/1.7.0-0001-fix-cmake.patch deleted file mode 100644 index e5e3898386303..0000000000000 --- a/recipes/opentelemetry-cpp/all/patches/1.7.0-0001-fix-cmake.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index e7597fc8..d880a90d 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -217,7 +217,6 @@ if(WITH_JAEGER) - find_package(Thrift QUIET) - if(Thrift_FOUND) - find_package(Boost REQUIRED) -- include_directories(${Boost_INCLUDE_DIR}) - else() - # Install Thrift and propagate via vcpkg toolchain file - if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) -diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake -index 629ea815..3b09b92e 100644 ---- a/cmake/opentelemetry-proto.cmake -+++ b/cmake/opentelemetry-proto.cmake -@@ -242,6 +242,10 @@ else() # cmake 3.8 or lower - target_link_libraries(opentelemetry_proto INTERFACE ${Protobuf_LIBRARIES}) - endif() - -+if(TARGET gRPC::grpc++) -+ target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++) -+endif() -+ - if(BUILD_SHARED_LIBS) - set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON) - endif() diff --git a/recipes/opentelemetry-cpp/all/patches/1.8.1-0001-fix-cmake.patch b/recipes/opentelemetry-cpp/all/patches/1.8.1-0001-fix-cmake.patch deleted file mode 100644 index 5c4fcae46b11b..0000000000000 --- a/recipes/opentelemetry-cpp/all/patches/1.8.1-0001-fix-cmake.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9b9710d..6eb42bb 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -222,7 +222,6 @@ if(WITH_JAEGER) - find_package(Thrift QUIET) - if(Thrift_FOUND) - find_package(Boost REQUIRED) -- include_directories(${Boost_INCLUDE_DIR}) - else() - # Install Thrift and propagate via vcpkg toolchain file - if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) -diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake -index 47f57a6..ebf5869 100644 ---- a/cmake/opentelemetry-proto.cmake -+++ b/cmake/opentelemetry-proto.cmake -@@ -280,6 +280,10 @@ else() # cmake 3.8 or lower - target_link_libraries(opentelemetry_proto INTERFACE ${Protobuf_LIBRARIES}) - endif() - -+if(TARGET gRPC::grpc++) -+ target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++) -+endif() -+ - if(BUILD_SHARED_LIBS) - set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON) - endif() diff --git a/recipes/opentelemetry-cpp/all/patches/1.9.1-0001-fix-cmake.patch b/recipes/opentelemetry-cpp/all/patches/1.9.1-0001-fix-cmake.patch deleted file mode 100644 index 6deba6e434af5..0000000000000 --- a/recipes/opentelemetry-cpp/all/patches/1.9.1-0001-fix-cmake.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index dbfb6a2..83c92cc 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -299,7 +299,6 @@ if(WITH_JAEGER) - find_package(Thrift QUIET) - if(Thrift_FOUND) - find_package(Boost REQUIRED) -- include_directories(${Boost_INCLUDE_DIR}) - else() - # Install Thrift and propagate via vcpkg toolchain file - if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) -diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake -index 34b33d3..19e67e9 100644 ---- a/cmake/opentelemetry-proto.cmake -+++ b/cmake/opentelemetry-proto.cmake -@@ -311,6 +311,10 @@ if(WITH_OTLP_GRPC) - endif() - endif() - -+if(TARGET gRPC::grpc++) -+ target_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++) -+endif() -+ - if(BUILD_SHARED_LIBS) - foreach(proto_target ${OPENTELEMETRY_PROTO_TARGETS}) - set_property(TARGET ${proto_target} PROPERTY POSITION_INDEPENDENT_CODE ON) From 90910d4386e34406e8295edc9f1d4b09d1f865d4 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 23 Nov 2023 16:32:33 +0200 Subject: [PATCH 05/10] opentelemetry-cpp: add v1.12.0, update options --- recipes/opentelemetry-cpp/all/conandata.yml | 12 ++-- recipes/opentelemetry-cpp/all/conanfile.py | 69 +++++++++++---------- recipes/opentelemetry-cpp/config.yml | 6 +- 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conandata.yml b/recipes/opentelemetry-cpp/all/conandata.yml index 18e2c291f0819..fb4e67647e394 100644 --- a/recipes/opentelemetry-cpp/all/conandata.yml +++ b/recipes/opentelemetry-cpp/all/conandata.yml @@ -1,13 +1,13 @@ sources: + "1.12.0": + url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.12.0.tar.gz" + sha256: "09c208a21fb1159d114a3ea15dc1bcc5dee28eb39907ba72a6012d2c7b7564a0" "1.9.1": url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.9.1.tar.gz" sha256: "668de24f81c8d36d75092ad9dcb02a97cd41473adbe72485ece05e336db48249" - "1.8.1": - url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.8.1.tar.gz" - sha256: "3d640201594b07f08dade9cd1017bd0b59674daca26223b560b9bb6bf56264c2" + "1.8.3": + url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.8.3.tar.gz" + sha256: "b23d3c80d2e0012734ea343d2be69b2a7139ec5545453c503b13e629eb8fbe05" "1.7.0": url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.7.0.tar.gz" sha256: "2ad0911cdc94fe84a93334773bef4789a38bd1f01e39560cabd4a5c267e823c3" - "1.6.1": - url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.6.1.tar.gz" - sha256: "1fc371be049b3220b8b9571c8b713f03e9a84f3c5684363f64ccc814638391a5" diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 70050d5b4a685..1d917f825406f 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -27,7 +27,7 @@ class OpenTelemetryCppConan(ConanFile): "with_stl": [True, False], "with_gsl": [True, False], "with_abseil": [True, False], - "with_otlp": [True, False], + "with_otlp": ["deprecated", True, False], "with_otlp_grpc": [True, False], "with_otlp_http": [True, False], "with_zipkin": [True, False], @@ -49,7 +49,7 @@ class OpenTelemetryCppConan(ConanFile): "with_stl": False, "with_gsl": False, "with_abseil": True, - "with_otlp": True, + "with_otlp": "deprecated", "with_otlp_grpc": True, "with_otlp_http": True, "with_zipkin": True, @@ -90,15 +90,13 @@ def _compilers_minimum_version(self): def config_options(self): if self.settings.os == "Windows": self.options.rm_safe("fPIC") + if Version(self.version) >= "1.10": + del self.options.with_jaeger def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - if not self.options.with_otlp: - self.options.rm_safe("with_otlp_grpc") - self.options.rm_safe("with_otlp_http") - def layout(self): cmake_layout(self, src_folder="src") @@ -109,14 +107,14 @@ def requirements(self): if self.options.with_abseil: self.requires("abseil/20230125.3", transitive_headers=True) - if self.options.with_otlp: + if self.options.with_otlp or self.options.with_otlp_grpc: self.requires("protobuf/3.21.12") - if self.options.get_safe("with_otlp_grpc"): + if self.options.with_otlp_grpc: self.requires("grpc/1.54.3") if (self.options.with_zipkin or self.options.with_elasticsearch or - self.options.get_safe("with_otlp_http") or + self.options.with_otlp_http or self.options.with_etw ): self.requires("nlohmann_json/3.11.2") @@ -124,20 +122,20 @@ def requirements(self): if (self.options.with_zipkin or self.options.with_elasticsearch or - self.options.get_safe("with_otlp_http") + self.options.with_otlp_http ): self.requires("libcurl/[>=7.78.0 <9]") if self.options.with_prometheus: self.requires("prometheus-cpp/1.1.0") - if self.options.with_jaeger: + if self.options.get_safe("with_jaeger"): self.requires("thrift/0.17.0") self.requires("boost/1.82.0") @property def _required_boost_components(self): - return ["locale"] if self.options.with_jaeger else [] + return ["locale"] if self.options.get_safe("with_jaeger") else [] def validate(self): if self.settings.compiler.cppstd: @@ -151,7 +149,7 @@ def validate(self): if self.settings.os != "Linux" and self.options.shared: raise ConanInvalidConfiguration(f"{self.ref} supports building shared libraries only on Linux") - if self.options.get_safe("with_otlp_grpc"): + if self.options.with_otlp_grpc: if not self.dependencies["grpc"].options.cpp_plugin: raise ConanInvalidConfiguration(f"{self.ref} requires grpc with cpp_plugin=True") @@ -165,10 +163,10 @@ def validate(self): ) def build_requirements(self): - if self.options.with_otlp: + if self.options.with_otlp or self.options.with_otlp_grpc: self.tool_requires("opentelemetry-proto/1.0.0") self.tool_requires("protobuf/") - if self.options.get_safe("with_otlp_grpc"): + if self.options.with_otlp_grpc: self.tool_requires("grpc/") def _create_cmake_module_variables(self, module_file): @@ -182,6 +180,10 @@ def _create_cmake_module_variables(self, module_file): """) save(self, module_file, content) + def package_id(self): + # deprecated + del self.info.options.with_otlp + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -197,19 +199,21 @@ def generate(self): tc.cache_variables["WITH_STL"] = self.options.with_stl tc.cache_variables["WITH_GSL"] = self.options.with_gsl tc.cache_variables["WITH_ABSEIL"] = self.options.with_abseil - tc.cache_variables["WITH_OTLP"] = self.options.with_otlp - tc.cache_variables["WITH_OTLP_GRPC"] = self.options.get_safe("with_otlp_grpc", False) - tc.cache_variables["WITH_OTLP_HTTP"] = self.options.get_safe("with_otlp_http", False) + if Version(self.version) < "1.10": + tc.cache_variables["WITH_OTLP"] = self.options.with_otlp + tc.cache_variables["WITH_OTLP_GRPC"] = self.options.with_otlp_grpc + tc.cache_variables["WITH_OTLP_HTTP"] = self.options.with_otlp_http tc.cache_variables["WITH_ZIPKIN"] = self.options.with_zipkin tc.cache_variables["WITH_PROMETHEUS"] = self.options.with_prometheus tc.cache_variables["WITH_ELASTICSEARCH"] = self.options.with_elasticsearch tc.cache_variables["WITH_ZPAGES"] = self.options.with_zpages - tc.cache_variables["WITH_JAEGER"] = self.options.with_jaeger + tc.cache_variables["WITH_JAEGER"] = self.options.get_safe("with_jaeger", False) tc.cache_variables["WITH_NO_GETENV"] = self.options.with_no_getenv tc.cache_variables["WITH_ETW"] = self.options.with_etw tc.cache_variables["WITH_LOGS_PREVIEW"] = self.options.with_logs_preview tc.cache_variables["WITH_ASYNC_EXPORT_PREVIEW"] = self.options.with_async_export_preview tc.cache_variables["WITH_METRICS_EXEMPLAR_PREVIEW"] = self.options.with_metrics_exemplar_preview + tc.cache_variables["OPENTELEMETRY_INSTALL"] = True if not self.settings.compiler.cppstd: tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd tc.generate() @@ -219,22 +223,22 @@ def generate(self): deps.generate() def _patch_sources(self): - if self.options.with_otlp: + if self.options.with_otlp_http or self.options.with_otlp_grpc: protos_path = self.dependencies.build["opentelemetry-proto"].conf_info.get("user.opentelemetry-proto:proto_root").replace("\\", "/") protos_cmake_path = os.path.join(self.source_folder, "cmake", "opentelemetry-proto.cmake") replace_in_file(self, protos_cmake_path, "if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)", "if(1)") - if Version(self.version) < "1.9.0": + if Version(self.version) < "1.8.3": replace_in_file(self, protos_cmake_path, 'set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")', f'set(PROTO_PATH "{protos_path}")') - if self.options.get_safe("with_otlp_grpc"): - save(self, protos_cmake_path, "\ntarget_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++)", append=True) else: replace_in_file(self, protos_cmake_path, '"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")', f'"{protos_path}")') + if self.options.with_otlp_grpc and Version(self.version) < "1.9.1": + save(self, protos_cmake_path, "\ntarget_link_libraries(opentelemetry_proto PUBLIC gRPC::grpc++)", append=True) rmdir(self, os.path.join(self.source_folder, "api", "include", "opentelemetry", "nostd", "absl")) @@ -281,19 +285,19 @@ def _otel_libraries(self): "opentelemetry_trace", "opentelemetry_version", ] - if self.options.with_otlp: + if self.options.with_otlp_grpc or self.options.with_otlp_http: libraries.extend([ "opentelemetry_proto", "opentelemetry_otlp_recordable", ]) - if self.options.get_safe("with_otlp_grpc"): + if self.options.with_otlp_grpc: libraries.append("opentelemetry_exporter_otlp_grpc") libraries.append("opentelemetry_exporter_otlp_grpc_metrics") if Version(self.version) >= "1.7.0": libraries.append("opentelemetry_exporter_otlp_grpc_client") if self.options.with_logs_preview: libraries.append("opentelemetry_exporter_otlp_grpc_log") - if self.options.get_safe("with_otlp_http"): + if self.options.with_otlp_http: libraries.append("opentelemetry_exporter_otlp_http") libraries.append("opentelemetry_exporter_otlp_http_client") libraries.append("opentelemetry_exporter_otlp_http_metric") @@ -305,7 +309,7 @@ def _otel_libraries(self): libraries.append("opentelemetry_exporter_elasticsearch_logs") if self.options.with_zipkin: libraries.append("opentelemetry_exporter_zipkin_trace") - if self.options.with_jaeger: + if self.options.get_safe("with_jaeger"): libraries.append("opentelemetry_exporter_jaeger_trace") libraries.append("opentelemetry_metrics") libraries.append("opentelemetry_exporter_ostream_metrics") @@ -364,16 +368,15 @@ def package_info(self): self.cpp_info.components["opentelemetry_common"].defines.append("HAVE_ABSEIL") self.cpp_info.components["opentelemetry_common"].requires.append("abseil::abseil") - if self.options.with_otlp: + if self.options.with_otlp_http or self.options.with_otlp_grpc: self.cpp_info.components["opentelemetry_proto"].requires.append("protobuf::protobuf") - self.cpp_info.components["opentelemetry_otlp_recordable"].requires.extend([ "opentelemetry_proto", "opentelemetry_resources", "opentelemetry_trace", ]) - if self.options.get_safe("with_otlp_grpc"): + if self.options.with_otlp_grpc: if "1.5.0" <= Version(self.version) < "1.7.0": self.cpp_info.components["opentelemetry_exporter_otlp_grpc_metrics"].requires.extend([ "grpc::grpc++", @@ -408,14 +411,14 @@ def package_info(self): "opentelemetry_exporter_otlp_grpc_client", ]) - if (self.options.get_safe("with_otlp_http") or + if (self.options.with_otlp_http or self.options.with_zipkin or self.options.with_elasticsearch ): self.cpp_info.components[self._http_client_name].requires.append("libcurl::libcurl") self.cpp_info.components[self._http_client_name].requires.append("openssl::openssl") - if self.options.get_safe("with_otlp_http"): + if self.options.with_otlp_http: self.cpp_info.components["opentelemetry_exporter_otlp_http_client"].requires.extend([ self._http_client_name, "nlohmann_json::nlohmann_json", @@ -445,7 +448,7 @@ def package_info(self): "opentelemetry_trace", ]) - if self.options.with_jaeger: + if self.options.get_safe("with_jaeger"): self.cpp_info.components["opentelemetry_exporter_jaeger_trace"].requires.extend([ self._http_client_name, "openssl::openssl", diff --git a/recipes/opentelemetry-cpp/config.yml b/recipes/opentelemetry-cpp/config.yml index 40bbcbc049f29..ea5fa8db677c4 100644 --- a/recipes/opentelemetry-cpp/config.yml +++ b/recipes/opentelemetry-cpp/config.yml @@ -1,9 +1,9 @@ versions: + "1.12.0": + folder: all "1.9.1": folder: all - "1.8.1": + "1.8.3": folder: all "1.7.0": folder: all - "1.6.1": - folder: all From 114e1799d257a4cf505589ee667b8cc497b617da Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 23 Nov 2023 16:38:06 +0200 Subject: [PATCH 06/10] opentelemetry-cpp: add transitive_headers=True --- recipes/opentelemetry-cpp/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 1d917f825406f..cecc192d600c2 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -108,9 +108,9 @@ def requirements(self): self.requires("abseil/20230125.3", transitive_headers=True) if self.options.with_otlp or self.options.with_otlp_grpc: - self.requires("protobuf/3.21.12") + self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True) if self.options.with_otlp_grpc: - self.requires("grpc/1.54.3") + self.requires("grpc/1.54.3", transitive_headers=True, transitive_libs=True) if (self.options.with_zipkin or self.options.with_elasticsearch or From 89065cc6e912d903b370b62cebb75286008af2bf Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 23 Nov 2023 17:18:28 +0200 Subject: [PATCH 07/10] opentelemetry-cpp: rmdir lib/pkgconfig --- recipes/opentelemetry-cpp/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index cecc192d600c2..891619b8798c2 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -253,6 +253,7 @@ def package(self): cmake = CMake(self) cmake.install() rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) self._create_cmake_module_variables( os.path.join(self.package_folder, self._otel_cmake_variables_path) ) From 942068a8d730c1be453443435b1d5c2e053042bb Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 30 Nov 2023 14:11:03 +0200 Subject: [PATCH 08/10] opentelemetry-cpp: disable failing configuration --- recipes/opentelemetry-cpp/all/conanfile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 891619b8798c2..9638c1e127a44 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -1,4 +1,4 @@ -from conan import ConanFile +from conan import ConanFile, conan_version from conan.errors import ConanInvalidConfiguration from conan.tools.files import get, copy, rmdir, replace_in_file, save from conan.tools.build import check_min_cppstd @@ -162,6 +162,11 @@ def validate(self): f"{', '.join(self._required_boost_components)}" ) + if conan_version.major == 1 and self.settings.compiler == "apple-clang" and Version(self.version) >= "1.12.0": + # Only fails on apple-clang in this configuration for some reason: + # https://github.com/conan-io/conan-center-index/pull/21332#issuecomment-1830766894 + raise ConanInvalidConfiguration("opentelemetry-cpp >= 1.12.0 does not support Apple Clang on Conan v1") + def build_requirements(self): if self.options.with_otlp or self.options.with_otlp_grpc: self.tool_requires("opentelemetry-proto/1.0.0") From 91aafc437437ef7162340cf15f107f3878a01920 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 8 Jan 2024 13:23:01 +0200 Subject: [PATCH 09/10] Apply suggestions from code review Co-authored-by: Uilian Ries --- recipes/opentelemetry-cpp/all/conanfile.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 9638c1e127a44..476919fbf32b1 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -96,7 +96,8 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - + if self.options.with_otlp != "deprecated": + self.output.warning(f"{self.ref}:with_otlp option is deprecated, do not use anymore. Please, consider with_otlp_grpc or with_otlp_http instead.") def layout(self): cmake_layout(self, src_folder="src") @@ -107,10 +108,9 @@ def requirements(self): if self.options.with_abseil: self.requires("abseil/20230125.3", transitive_headers=True) - if self.options.with_otlp or self.options.with_otlp_grpc: + if self.options.with_otlp_grpc: self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True) - if self.options.with_otlp_grpc: - self.requires("grpc/1.54.3", transitive_headers=True, transitive_libs=True) + self.requires("grpc/1.54.3", transitive_headers=True, transitive_libs=True) if (self.options.with_zipkin or self.options.with_elasticsearch or @@ -168,11 +168,10 @@ def validate(self): raise ConanInvalidConfiguration("opentelemetry-cpp >= 1.12.0 does not support Apple Clang on Conan v1") def build_requirements(self): - if self.options.with_otlp or self.options.with_otlp_grpc: + if self.options.with_otlp_grpc: self.tool_requires("opentelemetry-proto/1.0.0") self.tool_requires("protobuf/") - if self.options.with_otlp_grpc: - self.tool_requires("grpc/") + self.tool_requires("grpc/") def _create_cmake_module_variables(self, module_file): content = textwrap.dedent("""\ @@ -205,7 +204,7 @@ def generate(self): tc.cache_variables["WITH_GSL"] = self.options.with_gsl tc.cache_variables["WITH_ABSEIL"] = self.options.with_abseil if Version(self.version) < "1.10": - tc.cache_variables["WITH_OTLP"] = self.options.with_otlp + tc.cache_variables["WITH_OTLP"] = self.options.with_otlp_grpc or self.options.with_otlp_http tc.cache_variables["WITH_OTLP_GRPC"] = self.options.with_otlp_grpc tc.cache_variables["WITH_OTLP_HTTP"] = self.options.with_otlp_http tc.cache_variables["WITH_ZIPKIN"] = self.options.with_zipkin From 9f86bc0a9de81bae60e363a594b32a383f65654f Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 8 Jan 2024 19:45:21 +0200 Subject: [PATCH 10/10] opentelemetry-cpp: fix formatting --- recipes/opentelemetry-cpp/all/conanfile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 476919fbf32b1..e13d0077e219b 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -96,8 +96,10 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - if self.options.with_otlp != "deprecated": - self.output.warning(f"{self.ref}:with_otlp option is deprecated, do not use anymore. Please, consider with_otlp_grpc or with_otlp_http instead.") + if self.options.with_otlp != "deprecated": + self.output.warning(f"{self.ref}:with_otlp option is deprecated, do not use anymore. " + "Please, consider with_otlp_grpc or with_otlp_http instead.") + def layout(self): cmake_layout(self, src_folder="src")