-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Changes from 5 commits
fcb0fa7
2981ec2
b0c7785
fd4b2e2
a1f7ff0
fd37008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
@@ -27,9 +28,10 @@ class OpenTelemetryCppConan(ConanFile): | |
"with_stl": [True, False], | ||
"with_gsl": [True, False], | ||
"with_abseil": [True, False], | ||
"with_otlp": ["deprecated", True, False], | ||
"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], | ||
|
@@ -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, | ||
|
@@ -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") | ||
|
@@ -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") | ||
|
@@ -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: | ||
|
@@ -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]") | ||
|
@@ -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") | ||
|
||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without knowing much in depth about the |
||
self.tool_requires("protobuf/<host_version>") | ||
|
||
if self.options.with_otlp_grpc: | ||
|
@@ -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) | ||
|
||
|
@@ -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 | ||
|
@@ -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, | ||
|
@@ -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", | ||
|
@@ -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): | ||
|
@@ -408,6 +434,9 @@ 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._stl_value: | ||
self.cpp_info.components["opentelemetry_common"].defines.append("HAVE_CPP_STDLIB") | ||
|
||
|
@@ -471,6 +500,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", | ||
|
@@ -487,6 +521,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, | ||
|
This file was deleted.
This file was deleted.
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": | ||
|
There was a problem hiding this comment.
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