From d8ba3942fcc14626ea89113deab66cebd544a0d3 Mon Sep 17 00:00:00 2001 From: Niclas Johansson Date: Fri, 20 Sep 2024 10:10:56 +0200 Subject: [PATCH 1/7] Update conanfile.py: adding missing grpc proto library grpc proto library is missing when using grpc exporters. --- recipes/opentelemetry-cpp/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 7d46d7427d052..4301a2730388b 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -306,6 +306,7 @@ def _otel_libraries(self): libraries.append("opentelemetry_exporter_otlp_grpc") libraries.append("opentelemetry_exporter_otlp_grpc_metrics") libraries.append("opentelemetry_exporter_otlp_grpc_client") + libraries.append("opentelemetry_proto_grpc") if Version(self.version) >= "1.11" or self.options.with_logs_preview: libraries.append("opentelemetry_exporter_otlp_grpc_log") if self.options.with_otlp_http: @@ -396,6 +397,7 @@ def package_info(self): self.cpp_info.components["opentelemetry_exporter_otlp_grpc_client"].requires.extend([ "grpc::grpc++", "opentelemetry_proto", + "opentelemetry_proto_grpc", ]) self.cpp_info.components["opentelemetry_exporter_otlp_grpc"].requires.extend([ From 4873f83cdeea54b89b38382c464c977dc84f06d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Thu, 24 Oct 2024 15:00:39 +0200 Subject: [PATCH 2/7] Version guard new libs --- recipes/opentelemetry-cpp/all/conanfile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 4301a2730388b..d135c3682d93c 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -306,7 +306,8 @@ def _otel_libraries(self): libraries.append("opentelemetry_exporter_otlp_grpc") libraries.append("opentelemetry_exporter_otlp_grpc_metrics") libraries.append("opentelemetry_exporter_otlp_grpc_client") - libraries.append("opentelemetry_proto_grpc") + if Version(self.version) >= "1.9.1": + libraries.append("opentelemetry_proto_grpc") if Version(self.version) >= "1.11" or self.options.with_logs_preview: libraries.append("opentelemetry_exporter_otlp_grpc_log") if self.options.with_otlp_http: @@ -397,9 +398,11 @@ def package_info(self): self.cpp_info.components["opentelemetry_exporter_otlp_grpc_client"].requires.extend([ "grpc::grpc++", "opentelemetry_proto", - "opentelemetry_proto_grpc", ]) + if Version(self.version) >= "1.9.1": + self.cpp_info.components["opentelemetry_exporter_otlp_grpc_client"].requires.append("opentelemetry_proto_grpc") + self.cpp_info.components["opentelemetry_exporter_otlp_grpc"].requires.extend([ "opentelemetry_otlp_recordable", "opentelemetry_exporter_otlp_grpc_client" From 915f10afc96a92a96419a956390b636f54c0cd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Thu, 24 Oct 2024 15:53:44 +0200 Subject: [PATCH 3/7] Fix etw on non-windows, fix prometheous option, fix opentelemtry-proto usage, and add abseil versionrange --- recipes/opentelemetry-cpp/all/conanfile.py | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index d135c3682d93c..7bd35d8f804f6 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -90,6 +90,7 @@ def _compilers_minimum_version(self): def config_options(self): if self.settings.os == "Windows": self.options.rm_safe("fPIC") + del self.options.with_etw if Version(self.version) >= "1.10": del self.options.with_jaeger if Version(self.version) >= "1.11": @@ -110,7 +111,7 @@ def requirements(self): self.requires("ms-gsl/4.0.0") if self.options.with_abseil: - self.requires("abseil/20230802.1", transitive_headers=True) + self.requires("abseil/[>=20230125.3 <=20230802.1]", transitive_headers=True) if self.options.with_otlp_grpc or self.options.with_otlp_http: self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True) @@ -121,7 +122,7 @@ def requirements(self): if (self.options.with_zipkin or self.options.with_elasticsearch or self.options.with_otlp_http or - self.options.with_etw + self.options.get_safe("with_etw") ): self.requires("nlohmann_json/3.11.3") self.requires("openssl/[>=1.1 <4]") @@ -175,7 +176,7 @@ def validate(self): def build_requirements(self): if self.options.with_otlp_grpc or self.options.with_otlp_http: - self.tool_requires("opentelemetry-proto/1.2.0") + self.tool_requires("opentelemetry-proto/1.3.0") self.tool_requires("protobuf/") if self.options.with_otlp_grpc: @@ -215,13 +216,17 @@ def generate(self): 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 + if self.options.with_otlp_grpc or self.options.with_otlp_http: + tc.cache_variables["OTELCPP_PROTO_PATH"] = self.dependencies.build["opentelemetry-proto"].conf_info.get("user.opentelemetry-proto:proto_root").replace("\\", "/") 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.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 + if self.options.get_safe("with_etw"): + # CMakeLists checks for definition, not value + tc.cache_variables["WITH_ETW"] = True if Version(self.version) < "1.11": tc.cache_variables["WITH_LOGS_PREVIEW"] = self.options.with_logs_preview tc.cache_variables["WITH_ASYNC_EXPORT_PREVIEW"] = self.options.with_async_export_preview @@ -331,7 +336,7 @@ def _otel_libraries(self): "opentelemetry_logs", "opentelemetry_exporter_ostream_logs", ]) - if self.settings.os == "Windows" and self.options.with_etw: + if self.options.get_safe("with_etw"): libraries.append("opentelemetry_exporter_etw") return libraries @@ -468,7 +473,13 @@ def package_info(self): "boost::locale" ) - if self.settings.os == "Windows" and self.options.with_etw: + if self.options.with_prometheus: + self.cpp_info.components["opentelemetry_exporter_prometheus"].requires.extend([ + "prometheus-cpp::prometheus-cpp", + "opentelemetry_trace", + ]) + + if self.options.get_safe("with_etw"): self.cpp_info.components["opentelemetry_exporter_etw"].libs = [] self.cpp_info.components["opentelemetry_exporter_etw"].requires.append( "nlohmann_json::nlohmann_json", From bc87b1563258b59c31330205502d2ddf8087e6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Thu, 24 Oct 2024 16:45:10 +0200 Subject: [PATCH 4/7] Bump grpc, protobuf and abseil --- recipes/opentelemetry-cpp/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 7bd35d8f804f6..a6ac4062ed3a4 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -111,13 +111,13 @@ def requirements(self): self.requires("ms-gsl/4.0.0") if self.options.with_abseil: - self.requires("abseil/[>=20230125.3 <=20230802.1]", transitive_headers=True) + self.requires("abseil/[>=20240116.1 <20240117.0]", transitive_headers=True) if self.options.with_otlp_grpc or self.options.with_otlp_http: - self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True) + self.requires("protobuf/5.27.0", 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.65.0", transitive_headers=True, transitive_libs=True) if (self.options.with_zipkin or self.options.with_elasticsearch or From 6a8d6963ff118d798c75352a49236e7e526f6a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Thu, 24 Oct 2024 16:55:32 +0200 Subject: [PATCH 5/7] Old versions are not ready for newer abseil/grpc/protobuf combo --- recipes/opentelemetry-cpp/all/conanfile.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index a6ac4062ed3a4..c3bb0a22c974f 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -111,13 +111,22 @@ def requirements(self): self.requires("ms-gsl/4.0.0") if self.options.with_abseil: - self.requires("abseil/[>=20240116.1 <20240117.0]", transitive_headers=True) + if Version(self.version) >= "1.12.0": + self.requires("abseil/[>=20240116.1 <20240117.0]", transitive_headers=True) + else: + self.requires("abseil/[>=20230125.3 <=20230802.1]", transitive_headers=True) if self.options.with_otlp_grpc or self.options.with_otlp_http: - self.requires("protobuf/5.27.0", transitive_headers=True, transitive_libs=True) + if Version(self.version) >= "1.12.0": + self.requires("protobuf/5.27.0", transitive_headers=True, transitive_libs=True) + else: + self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True) if self.options.with_otlp_grpc: - self.requires("grpc/1.65.0", transitive_headers=True, transitive_libs=True) + if Version(self.version) >= "1.12.0": + self.requires("grpc/1.65.0", transitive_headers=True, transitive_libs=True) + else: + self.requires("grpc/1.54.3", transitive_headers=True, transitive_libs=True) if (self.options.with_zipkin or self.options.with_elasticsearch or From 3ba591e9289544bac891bc92b4d7ae98165cca2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Thu, 24 Oct 2024 16:59:04 +0200 Subject: [PATCH 6/7] Some docs --- recipes/opentelemetry-cpp/all/conanfile.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index c3bb0a22c974f..272ea723a4ac4 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -106,24 +106,33 @@ def configure(self): def layout(self): cmake_layout(self, src_folder="src") + def _supports_new_proto_grpc_abseil(self): + """Old versions do not support the new proto grpc abseil combo + (Usage of old imports etc) + This is technically only for protobuf, but we take care to + keep abseil range in line, and grpc dependencies in sync so no + conflicts arise if using any of the 3 elsewhere + """ + return Version(self.version) >= "1.12.0" + def requirements(self): if self.options.with_gsl: self.requires("ms-gsl/4.0.0") if self.options.with_abseil: - if Version(self.version) >= "1.12.0": + if self._supports_new_proto_grpc_abseil(): self.requires("abseil/[>=20240116.1 <20240117.0]", transitive_headers=True) else: self.requires("abseil/[>=20230125.3 <=20230802.1]", transitive_headers=True) if self.options.with_otlp_grpc or self.options.with_otlp_http: - if Version(self.version) >= "1.12.0": + if self._supports_new_proto_grpc_abseil(): self.requires("protobuf/5.27.0", transitive_headers=True, transitive_libs=True) else: self.requires("protobuf/3.21.12", transitive_headers=True, transitive_libs=True) if self.options.with_otlp_grpc: - if Version(self.version) >= "1.12.0": + if self._supports_new_proto_grpc_abseil(): self.requires("grpc/1.65.0", transitive_headers=True, transitive_libs=True) else: self.requires("grpc/1.54.3", transitive_headers=True, transitive_libs=True) From 1ca03421118242e7af50bd4ae0b1aecff8c8f840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Thu, 24 Oct 2024 17:33:17 +0200 Subject: [PATCH 7/7] Fix WITH_STL usage on newer versions, follow Conan's CPPSTD --- recipes/opentelemetry-cpp/all/conanfile.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/recipes/opentelemetry-cpp/all/conanfile.py b/recipes/opentelemetry-cpp/all/conanfile.py index 272ea723a4ac4..4027a85ffced7 100644 --- a/recipes/opentelemetry-cpp/all/conanfile.py +++ b/recipes/opentelemetry-cpp/all/conanfile.py @@ -46,11 +46,12 @@ class OpenTelemetryCppConan(ConanFile): "shared": False, "with_no_deprecated_code": False, + # Enabling this causes stack overflow in the test_package "with_stl": False, "with_gsl": False, "with_abseil": True, "with_otlp": "deprecated", - "with_otlp_grpc": True, + "with_otlp_grpc": False, "with_otlp_http": True, "with_zipkin": True, "with_prometheus": False, @@ -218,6 +219,20 @@ def package_id(self): def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + @property + def _stl_value(self): + # From 1.12.0 onwards, the STL can have various values + if Version(self.version) < "1.12.1": + return self.options.with_stl + if self.options.with_stl: + if self.settings.compiler.cppstd: + return "CXX" + str(self.settings.compiler.cppstd).replace("gnu", "") + else: + # ON for autodetection in upstream CML + return True + else: + return False + def generate(self): VirtualBuildEnv(self).generate(scope="build") VirtualRunEnv(self).generate(scope="build") @@ -227,7 +242,7 @@ def generate(self): 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_STL"] = self._stl_value tc.cache_variables["WITH_GSL"] = self.options.with_gsl tc.cache_variables["WITH_ABSEIL"] = self.options.with_abseil if Version(self.version) < "1.10": @@ -393,7 +408,7 @@ def package_info(self): if self.settings.os in ("Linux", "FreeBSD"): self.cpp_info.components["opentelemetry_common"].system_libs.extend(["pthread"]) - if self.options.with_stl: + if self._stl_value: self.cpp_info.components["opentelemetry_common"].defines.append("HAVE_CPP_STDLIB") if self.options.with_gsl: