Skip to content

opentelemetry-cpp: add version 1.9.1, update dependencies #17873

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

Merged
merged 3 commits into from
Jun 20, 2023
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
7 changes: 7 additions & 0 deletions recipes/opentelemetry-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"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"
Expand All @@ -25,6 +28,10 @@ sources:
sha256: "32f12ff15ec257e3462883f84bc291c2d5dc30055604c12ec4b46a36dfa3f189"

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"
Expand Down
44 changes: 30 additions & 14 deletions recipes/opentelemetry-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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

import os
import textwrap
Expand All @@ -18,6 +19,7 @@ class OpenTelemetryCppConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/open-telemetry/opentelemetry-cpp"
topics = ("opentelemetry", "telemetry", "tracing", "metrics", "logs")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
Expand Down Expand Up @@ -91,14 +93,14 @@ def requirements(self):
self.requires("ms-gsl/4.0.0")

if self.options.with_abseil:
self.requires("abseil/20220623.0")
self.requires("abseil/20220623.0", transitive_headers=True)

if self.options.with_otlp:
self.requires("protobuf/3.21.4")
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.19.0")
self.requires("opentelemetry-proto/0.20.0")

if self.options.get_safe("with_otlp_grpc"):
self.requires("grpc/1.50.1")
Expand All @@ -109,13 +111,13 @@ def requirements(self):
self.options.with_etw
):
self.requires("nlohmann_json/3.11.2")
self.requires("openssl/1.1.1t")
self.requires("openssl/[>=1.1 <4]")

if (self.options.with_zipkin or
self.options.with_elasticsearch or
self.options.get_safe("with_otlp_http")
):
self.requires("libcurl/7.87.0")
self.requires("libcurl/8.1.1")

if self.options.with_prometheus:
self.requires("prometheus-cpp/1.1.0")
Expand Down Expand Up @@ -157,7 +159,7 @@ def validate(self):
)

def build_requirements(self):
self.tool_requires("protobuf/3.21.4")
self.tool_requires("protobuf/3.21.9")
self.tool_requires("grpc/1.50.1")

def _create_cmake_module_variables(self, module_file):
Expand All @@ -172,15 +174,15 @@ def _create_cmake_module_variables(self, module_file):
save(self, module_file, content)

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)

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
Expand All @@ -198,14 +200,21 @@ def generate(self):
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.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.deps_user_info["opentelemetry-proto"].proto_root.replace("\\", "/")
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",
Expand All @@ -215,10 +224,17 @@ def _patch_sources(self):
protos_cmake_path,
"if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)",
"if(1)")
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 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"))

apply_conandata_patches(self)
Expand Down
27 changes: 27 additions & 0 deletions recipes/opentelemetry-cpp/all/patches/1.9.1-0001-fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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)
2 changes: 2 additions & 0 deletions recipes/opentelemetry-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"1.9.1":
folder: all
"1.8.1":
folder: all
"1.7.0":
Expand Down