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 1.10.0 #18647

Closed
wants to merge 13 commits into from
Closed
9 changes: 9 additions & 0 deletions recipes/opentelemetry-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
sources:
"1.12.0":
url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.12.0.tar.gz"
sha256: "09c208a21fb1159d114a3ea15dc1bcc5dee28eb39907ba72a6012d2c7b7564a0"
"1.11.0":
url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.11.0.tar.gz"
sha256: "f30cd88bf898a5726d245eba882b8e81012021eb00df34109f4dfb203f005cea"
"1.10.0":
url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.10.0.tar.gz"
sha256: "19e8ade04a674c8cf7f0dc6da1f7b0583a27d2cf4dbc03df87894a16a4547834"
"1.9.1":
url: "https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.9.1.tar.gz"
sha256: "668de24f81c8d36d75092ad9dcb02a97cd41473adbe72485ece05e336db48249"
Expand Down
150 changes: 104 additions & 46 deletions recipes/opentelemetry-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class OpenTelemetryCppConan(ConanFile):
"with_prometheus": False,
"with_elasticsearch": False,
"with_zpages": False,
"with_jaeger": True,
"with_jaeger": False,
"with_no_getenv": False,
"with_etw": False,
"with_logs_preview": False,
Expand All @@ -68,14 +68,30 @@ class OpenTelemetryCppConan(ConanFile):

@property
def _minimum_cpp_standard(self):
if self.options.with_abseil:
return 14
if Version(self.version) >= "1.12.0":
return 14
return 11

@property
def _minimum_compilers_version(self):
return {
"Visual Studio": "15",
"gcc": "5",
"clang": "3.4",
"apple-clang": "5.1",
}


def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
if Version(self.version) >= "1.11.0":
self.options.rm_safe("with_logs_preview")

def configure(self):
if self.options.shared:
Expand All @@ -93,31 +109,31 @@ 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")
self.requires("protobuf/3.21.12")
if Version(self.version) <= "1.4.1":
self.requires("opentelemetry-proto/0.11.0")
else:
self.requires("opentelemetry-proto/0.20.0")
self.requires("opentelemetry-proto/1.0.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
self.options.get_safe("with_otlp_http") or
self.options.with_etw
):
self.requires("nlohmann_json/3.11.2")
self.requires("openssl/[>=1.1 <4]")
self.requires("nlohmann_json/3.11.2")
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/8.1.1")
self.requires("libcurl/8.2.1")

if self.options.with_prometheus:
self.requires("prometheus-cpp/1.1.0")
Expand All @@ -133,8 +149,18 @@ def _required_boost_components(self):
return ["locale"] if self.options.with_jaeger and Version(self.version) >= "1.3.0" else []

def validate(self):
if self.settings.get_safe("compiler.cppstd"):
compiler = self.settings.compiler
compiler_name = str(compiler)

if compiler.get_safe("cppstd"):
check_min_cppstd(self, self._minimum_cpp_standard)

minimum_version = self._minimum_compilers_version.get(compiler_name, False)
if minimum_version and Version(compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"Requires compiler {compiler_name} minimum version: {minimum_version} with C++17 support."
)

check_min_vs(self, "192")

if self.settings.os != "Linux" and self.options.shared:
Expand All @@ -150,6 +176,13 @@ def validate(self):
if not self.dependencies["grpc"].options.cpp_plugin:
raise ConanInvalidConfiguration(f"{self.ref} requires grpc with cpp_plugin=True")

if Version(self.version) >= "1.10":
if self.options.with_otlp and not self.options.get_safe("with_otlp_grpc") and not self.options.get_safe("with_otlp_http"):
raise ConanInvalidConfiguration("'with_otlp' requires either 'with_otlp_grpc' or 'with_otlp_http' to be enabled")

if self.options.with_jaeger:
raise ConanInvalidConfiguration("Jeager-Support has been removed in opentelemetry-cpp >= 1.10")

boost_required_comp = any(self.dependencies["boost"].options.get_safe(f"without_{boost_comp}", True)
for boost_comp in self._required_boost_components)

Expand All @@ -161,9 +194,9 @@ def validate(self):

def build_requirements(self):
if self.options.with_otlp:
self.tool_requires("protobuf/3.21.9")
self.tool_requires("protobuf/3.21.12")
if self.options.get_safe("with_otlp_grpc"):
self.tool_requires("grpc/1.50.1")
self.tool_requires("grpc/1.54.3")

def _create_cmake_module_variables(self, module_file):
content = textwrap.dedent("""\
Expand All @@ -187,22 +220,35 @@ def generate(self):

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_STL"] = "ON" if self.options.with_stl else "OFF"
tc.variables["WITH_GSL"] = self.options.with_gsl
tc.variables["WITH_ABSEIL"] = self.options.with_abseil
tc.variables["WITH_OTLP"] = self.options.with_otlp
uilianries marked this conversation as resolved.
Show resolved Hide resolved
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_OTLP_GRPC"] = self.options.get_safe("with_otlp_grpc") or False
tc.variables["WITH_OTLP_HTTP"] = self.options.get_safe("with_otlp_http") or False
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

if self.options.get_safe("with_otlp_grpc") or self.options.get_safe("with_otlp_http"):
tc.variables["OTELCPP_PROTO_PATH"] = self._proto_root

if Version(self.version) < "1.10":
tc.variables["WITH_OTLP"] = self.options.with_otlp
tc.variables["WITH_JAEGER"] = self.options.with_jaeger

if Version(self.version) < "1.11":
tc.variables["WITH_LOGS_PREVIEW"] = self.options.with_logs_preview

cppstd = self.settings.compiler.get_safe("cppstd")
if not cppstd:
cppstd = self._minimum_cpp_standard
tc.variables["CMAKE_CXX_STANDARD"] = cppstd

tc.generate()

tc = CMakeDeps(self)
Expand All @@ -216,27 +262,26 @@ def generate(self):
env.append_path("LD_LIBRARY_PATH", os.path.join(self.dependencies["protobuf"].package_folder, "lib"))
env.vars(self).save_script("conanbuild_loadpath")

@property
def _proto_root(self):
return self.dependencies["opentelemetry-proto"].conf_info.get("user.opentelemetry-proto:proto_root").replace("\\", "/")

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")
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)")
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}\")")
if self.options.get_safe("with_otlp"):
protos_cmake_path = os.path.join(
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)")
if Version(self.version) < "1.8.0":
replace_in_file(self,
protos_cmake_path,
"set(PROTO_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto\")",
f"set(PROTO_PATH \"{self._proto_root}\")")

rmdir(self, os.path.join(self.source_folder, "api", "include", "opentelemetry", "nostd", "absl"))

Expand Down Expand Up @@ -277,7 +322,6 @@ def _http_client_name(self):
@property
def _otel_libraries(self):
libraries = [
self._http_client_name,
"opentelemetry_common",
"opentelemetry_exporter_in_memory",
"opentelemetry_exporter_ostream_span",
Expand All @@ -286,6 +330,9 @@ def _otel_libraries(self):
"opentelemetry_version",
]

if self.options.get_safe("with_otlp_http") or self.options.with_zipkin or self.options.with_elasticsearch:
libraries.append(self._http_client_name)

if self.options.with_otlp:
libraries.extend([
"opentelemetry_proto",
Expand All @@ -301,7 +348,10 @@ def _otel_libraries(self):
if Version(self.version) >= "1.7.0":
libraries.append("opentelemetry_exporter_otlp_grpc_client")

if self.options.with_logs_preview:
if Version(self.version) >= "1.9":
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.get_safe("with_otlp_http"):
Expand All @@ -313,13 +363,13 @@ def _otel_libraries(self):
if Version(self.version) >= "1.5.0":
libraries.append("opentelemetry_exporter_otlp_http_metric")

if self.options.with_logs_preview:
if Version(self.version) >= "1.11" or 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:
if self.options.with_elasticsearch and (Version(self.version) >= "1.11" or self.options.with_logs_preview):
libraries.append("opentelemetry_exporter_elasticsearch_logs")

if self.options.with_zipkin:
Expand All @@ -334,7 +384,7 @@ def _otel_libraries(self):
if Version(self.version) >= "1.4.0":
libraries.append("opentelemetry_exporter_ostream_metrics")

if self.options.with_logs_preview:
if Version(self.version) >= "1.11" or self.options.with_logs_preview:
libraries.extend([
"opentelemetry_logs",
"opentelemetry_exporter_ostream_logs",
Expand Down Expand Up @@ -367,7 +417,7 @@ def package_info(self):

self.cpp_info.components["opentelemetry_exporter_in_memory"].libs = []

if self.options.with_logs_preview:
if Version(self.version) >= "1.11" or self.options.with_logs_preview:
self.cpp_info.components["opentelemetry_logs"].requires.extend([
"opentelemetry_resources",
"opentelemetry_common",
Expand All @@ -393,7 +443,6 @@ def package_info(self):

if self.options.with_otlp:
self.cpp_info.components["opentelemetry_proto"].requires.extend([
"opentelemetry-proto::opentelemetry-proto",
"protobuf::protobuf",
])

Expand Down Expand Up @@ -432,7 +481,16 @@ def package_info(self):
"opentelemetry_exporter_otlp_grpc_client"
])

if self.options.with_logs_preview:
if Version(self.version) >= "1.9":
self.cpp_info.components["opentelemetry_proto_grpc"].requires.extend([
"opentelemetry_proto",
])

self.cpp_info.components["opentelemetry_exporter_otlp_grpc_client"].requires.extend([
"opentelemetry_proto_grpc",
])

if Version(self.version) >= "1.11.0" or self.options.with_logs_preview:
self.cpp_info.components["opentelemetry_exporter_otlp_grpc_log"].requires.extend([
"opentelemetry_otlp_recordable",
"opentelemetry_exporter_otlp_grpc_client",
Expand Down Expand Up @@ -463,7 +521,7 @@ def package_info(self):
"opentelemetry_exporter_otlp_http_client"
])

if self.options.with_logs_preview:
if Version(self.version) >= "1.11" or self.options.with_logs_preview:
self.cpp_info.components["opentelemetry_exporter_otlp_http_log"].requires.extend([
"opentelemetry_otlp_recordable",
"opentelemetry_exporter_otlp_http_client",
Expand Down
6 changes: 6 additions & 0 deletions recipes/opentelemetry-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
versions:
"1.12.0":
folder: all
"1.11.0":
folder: all
"1.10.0":
folder: all
"1.9.1":
folder: all
"1.8.1":
Expand Down