This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new b72dacb0cc work on otel_tracer plugin (#11061)
b72dacb0cc is described below
commit b72dacb0cc9039bdd460ef0063a377ad96b4ea3a
Author: Chris McFarlen <[email protected]>
AuthorDate: Tue Feb 13 08:02:01 2024 -0600
work on otel_tracer plugin (#11061)
* work on otel_tracer plugin
* work on finding deps
* restore ccache setting
---
CMakePresets.json | 3 +-
cmake/ExperimentalPlugins.cmake | 13 +++++
cmake/Findopentelemetry.cmake | 72 ++++++++++++++++++++++++
plugins/experimental/CMakeLists.txt | 6 +-
plugins/experimental/otel_tracer/otel_tracer.cc | 1 +
plugins/experimental/otel_tracer/tracer_common.h | 2 +-
6 files changed, 93 insertions(+), 4 deletions(-)
diff --git a/CMakePresets.json b/CMakePresets.json
index ff50df2e36..fd7ccb39ee 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -156,7 +156,8 @@
"description": "CI Pipeline config for Fedora Linux",
"inherits": ["ci"],
"cacheVariables": {
- "OPENSSL_ROOT_DIR": "/opt/openssl-quic"
+ "OPENSSL_ROOT_DIR": "/opt/openssl-quic",
+ "opentelemetry_ROOT": "/opt"
}
},
{
diff --git a/cmake/ExperimentalPlugins.cmake b/cmake/ExperimentalPlugins.cmake
index 97f3ab0036..637635d400 100644
--- a/cmake/ExperimentalPlugins.cmake
+++ b/cmake/ExperimentalPlugins.cmake
@@ -61,5 +61,18 @@ auto_option(
DEFAULT
${_DEFAULT}
)
+auto_option(
+ OTEL_TRACER
+ FEATURE_VAR
+ BUILD_OTEL_TRACER
+ WITH_SUBDIRECTORY
+ plugins/experimental/otel_tracer
+ PACKAGE_DEPENDS
+ opentelemetry
+ Protobuf
+ curl
+ DEFAULT
+ ${_DEFAULT}
+)
unset(_DEFAULT)
diff --git a/cmake/Findopentelemetry.cmake b/cmake/Findopentelemetry.cmake
new file mode 100644
index 0000000000..b3ad49a572
--- /dev/null
+++ b/cmake/Findopentelemetry.cmake
@@ -0,0 +1,72 @@
+#######################
+#
+# 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.
+#
+#######################
+
+# Findopentelemetry.cmake
+#
+# This will define the following variables
+#
+# opentelemetry_FOUND
+# opentelemetry_LIBRARY
+# opentelemetry_INCLUDE_DIRS
+#
+# and the following imported targets
+#
+# opentelemetry::opentelemetry
+#
+
+#opentelemetry has a lot of libraries
+set(OTEL_LIBS
+ opentelemetry_exporter_ostream_span
+ opentelemetry_exporter_otlp_http
+ opentelemetry_exporter_otlp_http_client
+ opentelemetry_http_client_curl
+ opentelemetry_metrics
+ opentelemetry_otlp_recordable
+ opentelemetry_proto
+ opentelemetry_resources
+ opentelemetry_trace
+ opentelemetry_version
+ opentelemetry_common
+)
+
+find_path(opentelemetry_INCLUDE_DIR NAMES opentelemetry/version.h)
+
+foreach(OTLIB ${OTEL_LIBS})
+ set(OTLIB_NAME ${OTLIB}_LIBRARY)
+ find_library(${OTLIB_NAME} NAMES ${OTLIB})
+ list(APPEND OTEL_LIBRARIES ${OTLIB_NAME})
+endforeach()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(opentelemetry REQUIRED_VARS
opentelemetry_INCLUDE_DIR ${OTEL_LIBRARIES})
+
+if(opentelemetry_FOUND)
+ mark_as_advanced(opentelemetry_FOUND ${OTEL_LIBRARIES})
+ set(opentelemetry_INCLUDE_DIRS "${opentelemetry_INCLUDE_DIR}")
+
+ foreach(OTELLIB ${OTEL_LIBRARIES})
+ list(APPEND opentelemetry_LIBRARIES ${${OTELLIB}})
+ endforeach()
+ message(STATUS "Opentelemetry found: ${opentelemetry_LIBRARIES}")
+ message(STATUS "Opentelemetry include: ${opentelemetry_INCLUDE_DIRS}")
+
+ if(NOT TARGET opentelemetry::opentelemetry)
+ add_library(opentelemetry::opentelemetry INTERFACE IMPORTED)
+ target_include_directories(opentelemetry::opentelemetry INTERFACE
${opentelemetry_INCLUDE_DIRS})
+ target_link_libraries(opentelemetry::opentelemetry INTERFACE
${opentelemetry_LIBRARIES})
+ endif()
+endif()
diff --git a/plugins/experimental/CMakeLists.txt
b/plugins/experimental/CMakeLists.txt
index f451116f4b..f539d1911c 100644
--- a/plugins/experimental/CMakeLists.txt
+++ b/plugins/experimental/CMakeLists.txt
@@ -44,8 +44,10 @@ add_subdirectory(url_sig)
if(USE_MAGICK)
add_subdirectory(magick)
endif()
+#add_subdirectory(wasm)
+
+# These are included via cmake/ExperimentalPlugins.cmake
#add_subdirectory(maxmind_acl)
-#add_subdirectory(otel_tracer)
#add_subdirectory(stek_share)
#add_subdirectory(uri_signing)
-#add_subdirectory(wasm)
+#add_subdirectory(otel_tracer)
diff --git a/plugins/experimental/otel_tracer/otel_tracer.cc
b/plugins/experimental/otel_tracer/otel_tracer.cc
index 52c4e250ca..352990ba1b 100644
--- a/plugins/experimental/otel_tracer/otel_tracer.cc
+++ b/plugins/experimental/otel_tracer/otel_tracer.cc
@@ -27,6 +27,7 @@
#include "ts/ts.h"
#define PLUGIN_NAME "otel_tracer"
+DbgCtl dbg_ctl{PLUGIN_NAME};
constexpr std::string_view ua_key = {"User-Agent"};
constexpr std::string_view host_key = {"Host"};
diff --git a/plugins/experimental/otel_tracer/tracer_common.h
b/plugins/experimental/otel_tracer/tracer_common.h
index e853456c73..2889c64444 100644
--- a/plugins/experimental/otel_tracer/tracer_common.h
+++ b/plugins/experimental/otel_tracer/tracer_common.h
@@ -61,7 +61,7 @@ constexpr const char *attrHttpScheme = {"http.scheme"};
template <typename T> class HttpTextMapCarrier : public
context::propagation::TextMapCarrier
{
public:
- HttpTextMapCarrier<T>(T &headers) : headers_(headers) {}
+ HttpTextMapCarrier(T &headers) : headers_(headers) {}
HttpTextMapCarrier() = default;
virtual nostd::string_view
Get(nostd::string_view key) const noexcept override