Skip to content
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
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,45 @@ jobs:
run: |
(cd ./functional/otlp; ./run_test.sh)

cmake_clang_yaml_config:
name: CMake clang 18 (maintainer mode, yaml config)
runs-on: ubuntu-24.04
env:
CC: /usr/bin/clang-18
CXX: /usr/bin/clang++-18
CXX_STANDARD: '14'
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: 'recursive'
- name: setup
run: |
sudo -E ./ci/setup_ci_environment.sh
- name: install dependencies
run: |
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release
- name: run cmake clang (maintainer mode, sync)
run: |
./ci/do_ci.sh cmake.maintainer.yaml.test
- name: install shelltest
run: sudo apt update && sudo apt-get install -y shelltestrunner
- name: generate test cert
env:
CFSSL_VERSION: 1.6.3
run: |
sudo -E ./tools/setup-cfssl.sh
(cd ./functional/cert; ./generate_cert.sh)
- name: run otlp func test
run: |
(cd ./functional/otlp; ./run_test.sh)
- name: run configuration func test
run: |
(cd ./functional/configuration; ./run_test.sh)

cmake_clang_maintainer_async_test:
name: CMake clang 18 (maintainer mode, async)
runs-on: ubuntu-24.04
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
matrix:
include:
- cmake_options: all-options-abiv1-preview
warning_limit: 61
warning_limit: 63
- cmake_options: all-options-abiv2-preview
warning_limit: 61
warning_limit: 63
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
Expand Down Expand Up @@ -49,6 +49,12 @@ jobs:
libgtest-dev \
libbenchmark-dev

- name: Install rapidyaml
run: |
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml"

- name: Check clang-tidy
run: |
if ! command -v clang-tidy &> /dev/null; then
echo "clang-tidy could not be found"
exit 1
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@ jobs:
llvm-dev \
libclang-dev \
cmake

- name: Install rapidyaml
run: |
sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml"

- name: Install include-what-you-use
run: |
sudo ./ci/install_iwyu.sh

- name: Prepare CMake
env:
CC: clang
Expand Down
11 changes: 11 additions & 0 deletions .iwyu.imp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
{ "include": ["<bits/types/struct_tm.h>", "private", "<time.h>", "public"] },
{ "include": ["<bits/types/struct_FILE.h>", "private", "<stdio.h>", "public"] },

# Work around for ryml
{ "include": ["<c4/std/string.hpp>", "private", "<ryml_std.hpp>", "public"] },

{ "include": ["<c4/yml/node.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/yml/parse.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/yml/parse_engine.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/yml/tree.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/yml/event_handler_tree.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/substr.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/substr_fwd.hpp>", "private", "<ryml.hpp>", "public"] },

# Local opentelemetry-cpp style

# We prefer to include <gtest/gtest.h> for simplicity
Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ endif()
option(WITH_ABI_VERSION_1 "ABI version 1" ON)
option(WITH_ABI_VERSION_2 "EXPERIMENTAL: ABI version 2 preview" OFF)

option(WITH_CONFIGURATION "EXPERIMENTAL: YAML configuration file" OFF)

#
# We do not want to have WITH_ABI_VERSION = "1" or "2", and instead prefer two
# distinct flags, WITH_ABI_VERSION_1 and WITH_ABI_VERSION_2.
Expand Down Expand Up @@ -349,6 +351,14 @@ if((NOT WITH_API_ONLY) AND USE_NLOHMANN_JSON)
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/nlohmann-json.cmake")
endif()

#
# Do we need RapidYaml ?
#

if((NOT WITH_API_ONLY) AND WITH_CONFIGURATION)
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/ryml.cmake")
endif()

#
# Do we need OpenTracing ?
#
Expand Down Expand Up @@ -499,6 +509,7 @@ message(STATUS "WITH_ELASTICSEARCH: ${WITH_ELASTICSEARCH}")
message(STATUS "WITH_OPENTRACING: ${WITH_OPENTRACING}")
message(STATUS "WITH_ETW: ${WITH_ETW}")
message(STATUS "OPENTELEMETRY_BUILD_DLL: ${OPENTELEMETRY_BUILD_DLL}")
message(STATUS "WITH_CONFIGURATION: ${WITH_CONFIGURATION}")

message(STATUS "---------------------------------------------")
message(STATUS "feature preview options")
Expand Down Expand Up @@ -580,6 +591,9 @@ if(WITH_OPENTRACING)
message(
STATUS "opentracing-cpp: ${OpenTracing_VERSION} (${OpenTracing_PROVIDER})")
endif()
if(ryml_VERSION)
message(STATUS "ryml: ${ryml_VERSION} (${ryml_PROVIDER})")
endif()
message(STATUS "---------------------------------------------")

include("${opentelemetry-cpp_SOURCE_DIR}/cmake/otel-install-functions.cmake")
Expand Down
25 changes: 25 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,31 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then
eval "$MAKE_COMMAND"
make test
exit 0
elif [[ "$1" == "cmake.maintainer.yaml.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
cmake "${CMAKE_OPTIONS[@]}" \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_GRPC=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_PROMETHEUS=ON \
-DWITH_EXAMPLES=ON \
-DWITH_EXAMPLES_HTTP=ON \
-DWITH_ZIPKIN=ON \
-DBUILD_W3CTRACECONTEXT_TEST=ON \
-DWITH_ELASTICSEARCH=ON \
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
-DWITH_ASYNC_EXPORT_PREVIEW=OFF \
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
-DWITH_CONFIGURATION=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
exit 0
elif [[ "$1" == "cmake.with_async_export.test" ]]; then
cd "${BUILD_DIR}"
rm -rf *
Expand Down
30 changes: 30 additions & 0 deletions cmake/ryml.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Import the rapidyaml target (ryml::ryml).
# 1. Find an installed ryml package
# 2. Use FetchContent to fetch and build ryml from GitHub

find_package(ryml QUIET)
set(ryml_PROVIDER "find_package")

if(NOT ryml_FOUND)
FetchContent_Declare(
"ryml"
GIT_REPOSITORY "https://github.com/biojppm/rapidyaml.git"
GIT_TAG "${ryml_GIT_TAG}"
)
set(ryml_PROVIDER "fetch_repository")

set(RYML_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(RYML_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the follow up PR with install tests we should also change this to

set(RYML_ENABLE_INSTALL ${OPENTELEMETRY_INSTALL} CACHE BOOL "" FORCE)

This should allow the install to complete if ryml is fetched.


FetchContent_MakeAvailable(ryml)

# Set the ryml_VERSION variable from the git tag.
string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" ryml_VERSION "${ryml_GIT_TAG}")
endif()

if(NOT TARGET ryml::ryml)
message(FATAL_ERROR "The required ryml::ryml target was not imported")
endif()
6 changes: 4 additions & 2 deletions cmake/thirdparty-dependency-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(OTEL_THIRDPARTY_DEPENDENCIES_SUPPORTED
gRPC
prometheus-cpp
OpenTracing
ryml
)

#-----------------------------------------------------------------------
Expand All @@ -26,7 +27,7 @@ set(OTEL_THIRDPARTY_DEPENDENCIES_SUPPORTED
set(OTEL_Protobuf_TARGET_NAMESPACE "protobuf")

#-----------------------------------------------------------------------
# Set the find_dependecy search mode - empty is default. Options: cmake default (empty string ""), "MODULE", or "CONFIG"
# Set the find_dependency search mode - empty is default. Options: cmake default (empty string ""), "MODULE", or "CONFIG"
# # set(OTEL_<dependency>_SEARCH_MODE "<search mode>")
#-----------------------------------------------------------------------
set(OTEL_Threads_SEARCH_MODE "")
Expand All @@ -37,6 +38,7 @@ set(OTEL_nlohmann_json_SEARCH_MODE "CONFIG")
set(OTEL_gRPC_SEARCH_MODE "CONFIG")
set(OTEL_prometheus-cpp_SEARCH_MODE "CONFIG")
set(OTEL_OpenTracing_SEARCH_MODE "CONFIG")
set(OTEL_ryml_SEARCH_MODE "")

# The search mode is set to "CONFIG" for Protobuf versions >= 3.22.0
# to find Protobuf's abseil dependency properly until the FindProtobuf module is updated support the upstream protobuf-config.cmake.
Expand All @@ -45,4 +47,4 @@ if(DEFINED Protobuf_VERSION AND Protobuf_VERSION VERSION_GREATER_EQUAL 3.22.0)
set(OTEL_Protobuf_SEARCH_MODE "CONFIG")
else()
set(OTEL_Protobuf_SEARCH_MODE "")
endif()
endif()
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ add_subdirectory(multi_processor)
if(WITH_EXAMPLES_HTTP)
add_subdirectory(http)
endif()

if(WITH_CONFIGURATION)
add_subdirectory(configuration)
endif()
81 changes: 81 additions & 0 deletions examples/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

if(DEFINED OPENTELEMETRY_BUILD_DLL)
add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL)
endif()

add_executable(
example_yaml
main.cc
custom_sampler.cc
custom_sampler_builder.cc
custom_span_exporter.cc
custom_span_exporter_builder.cc
custom_span_processor.cc
custom_span_processor_builder.cc
custom_push_metric_exporter.cc
custom_push_metric_exporter_builder.cc
custom_pull_metric_exporter.cc
custom_pull_metric_exporter_builder.cc
custom_log_record_exporter.cc
custom_log_record_exporter_builder.cc
custom_log_record_processor.cc
custom_log_record_processor_builder.cc)

target_link_libraries(
example_yaml ${CMAKE_THREAD_LIBS_INIT}
PRIVATE common_metrics_foo_library
common_logs_foo_library
opentelemetry-cpp::ostream_span_exporter_builder
opentelemetry-cpp::ostream_metrics_exporter_builder
opentelemetry-cpp::ostream_log_record_exporter_builder)

if(WITH_OTLP_HTTP)
add_definitions(-DOTEL_HAVE_OTLP_HTTP)
target_link_libraries(
example_yaml
PRIVATE opentelemetry-cpp::otlp_http_exporter_builder
opentelemetry-cpp::otlp_http_log_record_exporter_builder
opentelemetry-cpp::otlp_http_metric_exporter_builder)
endif()

if(WITH_OTLP_GRPC)
add_definitions(-DOTEL_HAVE_OTLP_GRPC)
target_link_libraries(
example_yaml
PRIVATE opentelemetry-cpp::otlp_grpc_exporter_builder
opentelemetry-cpp::otlp_grpc_log_record_exporter_builder
opentelemetry-cpp::otlp_grpc_metrics_exporter_builder)
endif()

if(WITH_OTLP_FILE)
add_definitions(-DOTEL_HAVE_OTLP_FILE)
target_link_libraries(
example_yaml
PRIVATE opentelemetry-cpp::otlp_file_exporter_builder
opentelemetry-cpp::otlp_file_log_record_exporter_builder
opentelemetry-cpp::otlp_file_metric_exporter_builder)
endif()

if(WITH_ZIPKIN)
add_definitions(-DOTEL_HAVE_ZIPKIN)
target_link_libraries(
example_yaml PRIVATE opentelemetry-cpp::zipkin_trace_exporter_builder)
endif()

if(WITH_PROMETHEUS)
add_definitions(-DOTEL_HAVE_PROMETHEUS)
target_link_libraries(example_yaml
PRIVATE opentelemetry-cpp::prometheus_exporter_builder)
endif()

if(DEFINED OPENTELEMETRY_BUILD_DLL)
target_link_libraries(example_yaml
PRIVATE opentelemetry-cpp::opentelemetry_cpp)
else()
target_link_libraries(
example_yaml
PRIVATE opentelemetry-cpp::configuration opentelemetry-cpp::common
opentelemetry-cpp::trace opentelemetry-cpp::logs)
endif()
Loading
Loading