This is an automated email from the ASF dual-hosted git repository.

jasonmfehr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit fe1a78d16e728843f9b0bd28367e7ced03bc9264
Author: jasonmfehr <jf...@cloudera.com>
AuthorDate: Fri Jun 27 12:39:07 2025 -0700

    IMPALA-13235: [Patch 3 of 5] - Consume OpenTelemetry C++ SDK
    
    Adds the OpenTelemetry C++ SDK version 1.20.0 from the toolchain into
    the cmake files for consumption during builds.
    
    Testing was accomplished by building locally and in Jenkins.
    
    Generated-by: Github Copilot (GPT-4.1)
    Change-Id: Ib30123f79270e3f11233e28a2a34725e7d455f5e
    Reviewed-on: http://gerrit.cloudera.org:8080/23101
    Reviewed-by: Jason Fehr <jf...@cloudera.com>
    Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
---
 CMakeLists.txt                           |  6 +++
 be/CMakeLists.txt                        |  2 +
 bin/bootstrap_toolchain.py               |  4 +-
 bin/impala-config.sh                     |  2 +
 cmake_modules/FindOpentelemetryCpp.cmake | 77 ++++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0b34fb43d..11f19a87e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,6 +145,7 @@ set_dep_root(CCTZ)
 set_dep_root(CURL)
 set_dep_root(CALLONCEHACK)
 set_dep_root(CLOUDFLAREZLIB)
+set_dep_root(OPENTELEMETRY_CPP)
 
 # The boost-cmake project hasn't been maintained for years. Let's make sure we
 # don't accidentally use it if it can be found.
@@ -424,6 +425,11 @@ find_package(CallOnceHack REQUIRED)
 IMPALA_ADD_THIRDPARTY_LIB(calloncehack ${CALLONCEHACK_INCLUDE_DIR} ""
   ${CALLONCEHACK_SHARED_LIB})
 
+# find opentelemetry-cpp sdk
+find_package(OpentelemetryCpp REQUIRED)
+add_compile_definitions(ENABLE_THREAD_INSTRUMENTATION_PREVIEW)
+include_directories(${OPENTELEMETRY_CPP_INCLUDE_DIR})
+
 # Tests that run any security related tests need to link this in to override 
the
 # krb5_realm_override() implementation in krb5.
 # See be/src/kudu/security/krb5_realm_override.cc for more information.
diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 541f2ae77..d2dfe4c3b 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -450,6 +450,7 @@ set(CLANG_INCLUDE_FLAGS
   "-I${PROTOBUF_INCLUDE_DIR}"
   "-I${CCTZ_INCLUDE_DIR}"
   "-I${CURL_INCLUDE_DIR}"
+  "-I${OPENTELEMETRY_CPP_INCLUDE_DIR}"
 )
 
 # allow linking of static libs into dynamic lib
@@ -658,6 +659,7 @@ set (IMPALA_DEPENDENCIES
   ThriftSaslTransport
   openssl_ssl
   openssl_crypto
+  ${OPENTELEMETRY_CPP_LIBS}
   crcutil
   gutil
   glog
diff --git a/bin/bootstrap_toolchain.py b/bin/bootstrap_toolchain.py
index 593744abd..b3dda414b 100755
--- a/bin/bootstrap_toolchain.py
+++ b/bin/bootstrap_toolchain.py
@@ -475,8 +475,8 @@ def get_toolchain_downloads():
       ["avro", "binutils", "boost", "breakpad", "bzip2", "calloncehack", 
"cctz",
        "cloudflarezlib", "cmake", "crcutil", "curl", "flatbuffers", "gdb", 
"gflags",
        "glog", "gperftools", "jwt-cpp", "libev", "libunwind", "lz4", "mold",
-       "openldap", "orc", "protobuf", "python", "rapidjson", "re2", "snappy", 
"tpc-h",
-       "tpc-ds", "zlib", "zstd"]]
+       "openldap", "opentelemetry-cpp", "orc", "protobuf", "python", 
"rapidjson", "re2",
+       "snappy", "tpc-h", "tpc-ds", "zlib", "zstd"]]
   python3_package = ToolchainPackage(
       "python", explicit_version=os.environ.get("IMPALA_PYTHON3_VERSION"))
   gtest_package = ToolchainPackage(
diff --git a/bin/impala-config.sh b/bin/impala-config.sh
index 20e46d83c..519cafef0 100755
--- a/bin/impala-config.sh
+++ b/bin/impala-config.sh
@@ -149,6 +149,8 @@ export IMPALA_LLVM_VERSION=5.0.1-p8
 unset IMPALA_LLVM_URL
 export IMPALA_LLVM_ASAN_VERSION=5.0.1-p8
 unset IMPALA_LLVM_ASAN_URL
+export IMPALA_OPENTELEMETRY_CPP_VERSION=1.20.0
+unset IMPALA_OPENTELEMTRY_CPP_URL
 
 # To limit maximum memory available for the mini-cluster and CDH cluster, add 
the
 # following in $IMPALA_HOME/bin/impala-config-local.sh
diff --git a/cmake_modules/FindOpentelemetryCpp.cmake 
b/cmake_modules/FindOpentelemetryCpp.cmake
new file mode 100644
index 000000000..b6c64aae7
--- /dev/null
+++ b/cmake_modules/FindOpentelemetryCpp.cmake
@@ -0,0 +1,77 @@
+##############################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+##############################################################################
+
+# - Find OpentelemetryCpp static libraries for the OpenTelemetry C++ SDK.
+# OPENTELEMETRY_CPP_ROOT hints the location
+#
+# This module defines
+# OPENTELEMETRY_CPP_INCLUDE_DIR, directory containing headers
+#
+# See https://github.com/open-telemetry/opentelemetry-cpp/blob/main/INSTALL.md 
for
+# documentation on the OpenTelemetry C++ SDK installation.
+
+set(OPENTELEMETRY_CPP_SEARCH_HEADER_PATHS ${OPENTELEMETRY_CPP_ROOT}/include)
+
+set(OPENTELEMETRY_CPP_SEARCH_LIB_PATH ${OPENTELEMETRY_CPP_ROOT}/lib)
+
+find_path(OPENTELEMETRY_CPP_INCLUDE_DIR
+  NAMES opentelemetry/sdk/resource/resource.h
+  PATHS ${OPENTELEMETRY_CPP_SEARCH_HEADER_PATHS}
+  NO_DEFAULT_PATH)
+
+# The following libraries are the minimum set of libraries required to use the 
OTLP HTTP
+# and file exporters. Order is important, as some libraries depend on others.
+set(LIB_LIST
+  libopentelemetry_exporter_otlp_file
+  libopentelemetry_exporter_otlp_file_client
+  libopentelemetry_exporter_otlp_http
+  libopentelemetry_exporter_otlp_http_client
+  libopentelemetry_http_client_curl
+  libopentelemetry_otlp_recordable
+  libopentelemetry_logs
+  libopentelemetry_proto
+  libopentelemetry_resources
+  libopentelemetry_trace
+  libopentelemetry_version
+  libopentelemetry_common
+)
+
+set(OPENTELEMETRY_CPP_LIBS "")
+
+set(OPENTELEMETRY_CPP_FOUND TRUE)
+
+foreach(LIB ${LIB_LIST})
+  find_library(OPENTELEMETRY_CPP_${LIB} ${LIB}.a
+    PATHS ${OPENTELEMETRY_CPP_SEARCH_LIB_PATH}
+    NO_DEFAULT_PATH
+    DOC "OpenTelemetry ${LIB}"
+    )
+  if (NOT OPENTELEMETRY_CPP_${LIB})
+    message(FATAL_ERROR "OpenTelemetry includes and libraries NOT found.")
+    set(OPENTELEMETRY_CPP_FOUND FALSE)
+  endif()
+  set(OPENTELEMETRY_CPP_LIBS ${OPENTELEMETRY_CPP_LIBS} 
"${OPENTELEMETRY_CPP_${LIB}}")
+endforeach(LIB)
+
+message(STATUS "OpenTelemetry libs: ${OPENTELEMETRY_CPP_LIBS}")
+
+mark_as_advanced(
+  OPENTELEMETRY_CPP_LIBS
+  OPENTELEMETRY_CPP_INCLUDE_DIR
+)

Reply via email to