Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opentelemetry-cpp: add version 1.16.1, 1.17.0 #25902

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions recipes/opentelemetry-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
sources:
"1.17.0":
url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.17.0.tar.gz"
sha256: "13542725463f1ea106edaef078c2276065cf3da998cb1d3dcf92630daa3f64d4"
"1.16.1":
url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.16.1.tar.gz"
sha256: "b8a78bb2a3a78133dbb08bcd04342f4b1e03cb4a19079b8416d408d905fffc37"
"1.14.2":
url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.14.2.tar.gz"
sha256: "c7e7801c9f6228751cdb9dd4724d0f04777ed53f524c8828e73bf4c9f894e0bd"
Expand Down
92 changes: 76 additions & 16 deletions recipes/opentelemetry-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
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
Expand Down Expand Up @@ -27,9 +28,10 @@ class OpenTelemetryCppConan(ConanFile):
"with_stl": [True, False],
"with_gsl": [True, False],
"with_abseil": [True, False],
"with_otlp": ["deprecated", True, False],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed so that the new versions don't have this from the get-go, and it's been deprecated long enough to warrant removal for old versions

"with_otlp_grpc": [True, False],
"with_otlp_http": [True, False],
"with_otlp_http_compression": [True, False],
"with_otlp_file": [True, False],
"with_zipkin": [True, False],
"with_prometheus": [True, False],
"with_elasticsearch": [True, False],
Expand All @@ -50,9 +52,11 @@ class OpenTelemetryCppConan(ConanFile):
"with_stl": False,
"with_gsl": False,
"with_abseil": True,
"with_otlp": "deprecated",
"with_otlp_grpc": False,
# True because dependencies usually need this, and it would generate missing binaries for those
"with_otlp_http": True,
"with_otlp_http_compression": False,
"with_otlp_file": False,
"with_zipkin": True,
"with_prometheus": False,
"with_elasticsearch": False,
Expand Down Expand Up @@ -96,13 +100,13 @@ def config_options(self):
del self.options.with_jaeger
if Version(self.version) >= "1.11":
del self.options.with_logs_preview
if Version(self.version) < "1.16.0":
del self.options.with_otlp_file
del self.options.with_otlp_http_compression

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")
Expand All @@ -116,6 +120,19 @@ def _supports_new_proto_grpc_abseil(self):
"""
return Version(self.version) >= "1.12.0"

@property
def _needs_proto(self):
return self.options.with_otlp_grpc or self.options.with_otlp_http or self.options.get_safe("with_otlp_file")

@property
def _otlp_http_needs_zlib(self):
# Bug before 1.17.X meant that zib was needed even with compression off
return (Version(self.version) >= "1.16.0"
# Check if new version released with this fix
# It was fixed in https://github.com/open-telemetry/opentelemetry-cpp/pull/3120
and (Version(self.version) < "1.17.1"
or self.options.with_otlp_http_compression))
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved

def requirements(self):
if self.options.with_gsl:
self.requires("ms-gsl/4.0.0")
Expand All @@ -126,7 +143,7 @@ def requirements(self):
else:
self.requires("abseil/[>=20230125.3 <=20230802.1]", transitive_headers=True)

if self.options.with_otlp_grpc or self.options.with_otlp_http:
if self._needs_proto:
if self._supports_new_proto_grpc_abseil():
self.requires("protobuf/5.27.0", transitive_headers=True, transitive_libs=True)
else:
Expand All @@ -141,7 +158,8 @@ def requirements(self):
if (self.options.with_zipkin or
self.options.with_elasticsearch or
self.options.with_otlp_http or
self.options.get_safe("with_etw")
self.options.get_safe("with_etw") or
self.options.get_safe("with_otlp_file")
):
self.requires("nlohmann_json/3.11.3")
self.requires("openssl/[>=1.1 <4]")
Expand All @@ -152,6 +170,9 @@ def requirements(self):
):
self.requires("libcurl/[>=7.78.0 <9]")

if self.options.with_otlp_http and self._otlp_http_needs_zlib:
self.requires("zlib/[>=1.2.11 <2]")

if self.options.with_prometheus:
self.requires("prometheus-cpp/1.1.0")

Expand Down Expand Up @@ -194,8 +215,8 @@ 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_grpc or self.options.with_otlp_http:
self.tool_requires("opentelemetry-proto/1.3.0")
if self._needs_proto:
self.tool_requires("opentelemetry-proto/1.3.2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open-telemetry/opentelemetry-cpp#2991 changes in the documentation seem to imply that there's not need to map 1:1 unless a new version requires a minimum version, so after checking locally, old versions till compile with this, so I've simplified this @ArielGMachado, lmkwyt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without knowing much in depth about the opentelemetry-cpp's internals, what I understand from documentation (https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/maintaining-dependencies.md) is that opentelemetry-cpp generates code from opentelemetry-proto as part of the opentelemetry-cpp build. That are protobuf specs.
Each 3rd party version that uses in opentelemetry-cpp is being indicated in the file third_party_release of each release.
When upgrading opentelemetry-proto to a newer release code can requires adjustment, so if a version requires code and a specific version of opentelemetry-proto, it is indicated in the release.
According to the (Release info v1.16.0) , was upgraded to opentelemetry-proto/1.3.1, and in the (Release info v1.17.0) was upgraded to opentelemetry-proto/1.3.2.
I made the change in the recipe according to this principle to ensure the receipe compile each version with the exact dependency version they indicate in the release and not diverge in the Conan recipe from the official version of opentelemetry-cpp project.
I hope this helps you understand the reason for the change.

self.tool_requires("protobuf/<host_version>")

if self.options.with_otlp_grpc:
Expand All @@ -212,10 +233,6 @@ 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)

Expand Down Expand Up @@ -249,7 +266,11 @@ 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:
if Version(self.version) >= "1.16.0":
tc.cache_variables["WITH_OTLP_HTTP_COMPRESSION"] = self.options.with_otlp_http_compression
if self.options.get_safe("with_otlp_file"):
tc.cache_variables["WITH_OTLP_FILE"] = True
if self._needs_proto:
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
Expand All @@ -274,7 +295,7 @@ def generate(self):
deps.generate()

def _patch_sources(self):
if self.options.with_otlp_http or self.options.with_otlp_grpc:
if self._needs_proto:
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,
Expand Down Expand Up @@ -335,7 +356,7 @@ def _otel_libraries(self):
if self.options.with_otlp_http or self.options.with_elasticsearch or self.options.get_safe("with_jaeger") or self.options.with_zipkin:
# https://github.com/open-telemetry/opentelemetry-cpp/blob/v1.12.0/CMakeLists.txt#L452-L460
libraries.append(self._http_client_name)
if self.options.with_otlp_grpc or self.options.with_otlp_http:
if self._needs_proto:
libraries.extend([
"opentelemetry_proto",
"opentelemetry_otlp_recordable",
Expand All @@ -354,6 +375,11 @@ def _otel_libraries(self):
libraries.append("opentelemetry_exporter_otlp_http_metric")
if Version(self.version) >= "1.11" or self.options.with_logs_preview:
libraries.append("opentelemetry_exporter_otlp_http_log")
if self.options.get_safe("with_otlp_file"):
libraries.append("opentelemetry_exporter_otlp_file")
libraries.append("opentelemetry_exporter_otlp_file_client")
libraries.append("opentelemetry_exporter_otlp_file_metric")
libraries.append("opentelemetry_exporter_otlp_file_log")
if self.options.with_prometheus:
libraries.append("opentelemetry_exporter_prometheus")
if self.options.with_elasticsearch and (Version(self.version) >= "1.11" or self.options.with_logs_preview):
Expand Down Expand Up @@ -408,6 +434,11 @@ def package_info(self):
if self.settings.os in ("Linux", "FreeBSD"):
self.cpp_info.components["opentelemetry_common"].system_libs.extend(["pthread"])

if Version(self.version) >= "1.16.0" and is_apple_os(self):
self.cpp_info.components["opentelemetry_common"].frameworks.extend(["CoreFoundation"])
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved

AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
if self.options.get_safe("with_otlp_http_compression"):
self.cpp_info.components["opentelemetry_common"].defines.append("ENABLE_OTLP_COMPRESSION_PREVIEW")
if self._stl_value:
self.cpp_info.components["opentelemetry_common"].defines.append("HAVE_CPP_STDLIB")

Expand Down Expand Up @@ -471,6 +502,11 @@ def package_info(self):
"opentelemetry_proto",
])

if self._otlp_http_needs_zlib:
# This version requires zlib for the http client even if not used, as it includes zconf.h
# regardless of WITH_OTLP_HTTP_COMPRESSION
self.cpp_info.components["opentelemetry_exporter_otlp_http_client"].requires.append("zlib::zlib")

self.cpp_info.components["opentelemetry_exporter_otlp_http"].requires.extend([
"opentelemetry_otlp_recordable",
"opentelemetry_exporter_otlp_http_client",
Expand All @@ -487,6 +523,30 @@ def package_info(self):
"opentelemetry_exporter_otlp_http_client",
])

if self.options.get_safe("with_otlp_file"):
self.cpp_info.components["opentelemetry_exporter_otlp_file_client"].requires.extend([
"nlohmann_json::nlohmann_json",
"opentelemetry_proto",
"opentelemetry_common"
])
if self.options.with_abseil:
self.cpp_info.components["opentelemetry_exporter_otlp_file_client"].requires.append("abseil::absl_strings")

self.cpp_info.components["opentelemetry_exporter_otlp_file"].requires.extend([
"opentelemetry_otlp_recordable",
"opentelemetry_exporter_otlp_file_client",
])

self.cpp_info.components["opentelemetry_exporter_otlp_file_log"].requires.extend([
"opentelemetry_otlp_recordable",
"opentelemetry_exporter_otlp_file_client",
])

self.cpp_info.components["opentelemetry_exporter_otlp_file_metric"].requires.extend([
"opentelemetry_otlp_recordable",
"opentelemetry_exporter_otlp_file_client",
])

if self.options.with_zipkin:
self.cpp_info.components["opentelemetry_exporter_zipkin_trace"].requires.extend([
self._http_client_name,
Expand Down
9 changes: 0 additions & 9 deletions recipes/opentelemetry-cpp/all/test_v1_package/CMakeLists.txt

This file was deleted.

18 changes: 0 additions & 18 deletions recipes/opentelemetry-cpp/all/test_v1_package/conanfile.py

This file was deleted.

4 changes: 4 additions & 0 deletions recipes/opentelemetry-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
versions:
"1.17.0":
folder: all
"1.16.1":
folder: all
"1.14.2":
folder: all
"1.12.0":
Expand Down