Skip to content

Commit

Permalink
POC - CI
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Feb 17, 2024
1 parent df13b50 commit eb1155d
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
sudo -E ./ci/setup_cmake.sh
sudo -E ./ci/setup_ci_environment.sh
sudo -E ./ci/install_protobuf.sh
sudo -E ./ci/install_yaml_cpp.sh
sudo -E ./ci/install_ryml.sh
- name: run cmake clang (maintainer mode, sync)
env:
CC: /usr/bin/clang-15
Expand Down
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ 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: configuration model" OFF)
option(WITH_CONFIGURATION_YAML "EXPERIMENTAL: YAML configuration file" OFF)
option(WITH_CONFIGURATION "EXPERIMENTAL: YAML configuration file" OFF)

file(READ "${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h"
OPENTELEMETRY_CPP_HEADER_VERSION_H)
Expand Down Expand Up @@ -287,10 +286,6 @@ option(WITH_METRICS_EXEMPLAR_PREVIEW
# Verify options dependencies
#

if(WITH_CONFIGURATION_YAML AND NOT WITH_CONFIGURATION)
message(FATAL_ERROR "CONFIGURATION_YAML=ON requires WITH_CONFIGURATION=ON")
endif()

if(WITH_EXAMPLES_HTTP AND NOT WITH_EXAMPLES)
message(FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON")
endif()
Expand Down Expand Up @@ -473,8 +468,18 @@ if((NOT WITH_API_ONLY) AND USE_NLOHMANN_JSON)
include(cmake/nlohmann-json.cmake)
endif()

find_package(yaml-cpp REQUIRED)
find_package(ryml REQUIRED)
#
# Do we need RapidYaml ?
#

if((NOT WITH_API_ONLY) AND WITH_CONFIGURATION)
# No specific version required.
find_package(ryml REQUIRED)
message(STATUS "Found ryml: include ${RYML_INCLUDE_DIR}, lib ${RYML_LIB_DIR}, version ${ryml_VERSION}")
endif()

# DEAD
# find_package(yaml-cpp REQUIRED)

if(OTELCPP_MAINTAINER_MODE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
31 changes: 31 additions & 0 deletions ci/install_ryml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

set -ex
export DEBIAN_FRONTEND=noninteractive
[ -z "${RYML_VERSION}" ] && export RYML_VERSION="0.5.0"

BUILD_DIR=/tmp/
INSTALL_DIR=/usr/local/
pushd $BUILD_DIR
git clone --recursive -b ${RYML_VERSION} https://github.com/biojppm/rapidyaml.git
cd yaml-cpp
RYML_BUILD_OPTIONS=(
"-DBUILD_TESTING=OFF"
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
"-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR"
)

if [ ! -z "${CXX_STANDARD}" ]; then
RYML_BUILD_OPTIONS=(${RYML_BUILD_OPTIONS[@]} "-DCMAKE_CXX_STANDARD=${CXX_STANDARD}")
fi

mkdir build && pushd build
cmake ${RYML_BUILD_OPTIONS[@]} ..
make -j $(nproc)
make install
popd
popd
export PATH=${INSTALL_DIR}/bin:$PATH # ensure to use the installed ryml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#pragma once

#include <yaml-cpp/yaml.h>
#include <string>

#include "opentelemetry/sdk/configuration/document.h"
Expand Down
7 changes: 5 additions & 2 deletions sdk/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ add_subdirectory(metrics)
add_subdirectory(logs)
add_subdirectory(version)
add_subdirectory(resource)
add_subdirectory(configuration)
add_subdirectory(init)

if(WITH_CONFIGURATION)
add_subdirectory(configuration)
add_subdirectory(init)
endif()
12 changes: 7 additions & 5 deletions sdk/src/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# DEAD
# yaml_document.cc yaml_document_node.cc

add_library(
opentelemetry_configuration
configuration_factory.cc
yaml_configuration_factory.cc yaml_document.cc yaml_document_node.cc
yaml_configuration_factory.cc
ryml_document.cc ryml_document_node.cc)

set_target_properties(opentelemetry_configuration PROPERTIES EXPORT_NAME configuration)
Expand All @@ -18,10 +21,9 @@ target_link_libraries(
opentelemetry_configuration
PUBLIC opentelemetry_api opentelemetry_common)

target_link_libraries(
opentelemetry_configuration
PUBLIC yaml-cpp::yaml-cpp)

# target_link_libraries(
# opentelemetry_configuration
# PUBLIC yaml-cpp::yaml-cpp)

target_link_libraries(
opentelemetry_configuration
Expand Down
2 changes: 0 additions & 2 deletions sdk/src/configuration/configuration_factory.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <yaml-cpp/yaml.h>
#include <fstream>

#include "opentelemetry/sdk/common/global_log_handler.h"
Expand All @@ -27,7 +26,6 @@
#include "opentelemetry/sdk/configuration/simple_propagator_configuration.h"
#include "opentelemetry/sdk/configuration/simple_span_processor_configuration.h"
#include "opentelemetry/sdk/configuration/trace_id_ratio_based_sampler_configuration.h"
#include "opentelemetry/sdk/configuration/yaml_document.h"
#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h"
#include "opentelemetry/version.h"

Expand Down
18 changes: 9 additions & 9 deletions sdk/src/configuration/yaml_configuration_factory.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <yaml-cpp/yaml.h>
#include <fstream>

// #define WITH_YAML_CPP

#include "opentelemetry/sdk/common/global_log_handler.h"

#include "opentelemetry/sdk/configuration/configuration.h"
#include "opentelemetry/sdk/configuration/configuration_factory.h"
#include "opentelemetry/sdk/configuration/ryml_document.h"
#include "opentelemetry/sdk/configuration/ryml_document_node.h"
#include "opentelemetry/sdk/configuration/yaml_configuration_factory.h"
#include "opentelemetry/sdk/configuration/yaml_document.h"
#include "opentelemetry/sdk/configuration/yaml_document_node.h"
#include "opentelemetry/version.h"

#ifdef WITH_YAML_CPP
# include "opentelemetry/sdk/configuration/yaml_document.h"
# include "opentelemetry/sdk/configuration/yaml_document_node.h"
#endif

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
Expand All @@ -39,6 +43,7 @@ std::unique_ptr<Configuration> YamlConfigurationFactory::ParseFile(std::string f
return conf;
}

#ifdef WITH_YAML_CPP
static std::unique_ptr<Document> YamlCppParse(const std::string &content)
{
std::unique_ptr<Document> doc;
Expand All @@ -60,6 +65,7 @@ static std::unique_ptr<Document> YamlCppParse(const std::string &content)

return doc;
}
#endif

static std::unique_ptr<Document> RymlParse(const std::string &content)
{
Expand All @@ -84,8 +90,6 @@ std::unique_ptr<Configuration> YamlConfigurationFactory::ParseString(std::string
std::unique_ptr<DocumentNode> root;
std::unique_ptr<Configuration> config;

// #define WITH_YAML_CPP

#ifdef WITH_YAML_CPP
doc = YamlCppParse(content);
#else
Expand All @@ -100,10 +104,6 @@ std::unique_ptr<Configuration> YamlConfigurationFactory::ParseString(std::string
config = ConfigurationFactory::ParseConfiguration(root);
}
}
catch (const YAML::Exception &e)
{
OTEL_INTERNAL_LOG_ERROR("Failed to interpret yaml, " << e.what());
}
catch (...)
{
OTEL_INTERNAL_LOG_ERROR("Failed to interpret yaml.");
Expand Down
1 change: 0 additions & 1 deletion sdk/src/init/sdk_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "opentelemetry/sdk/configuration/span_exporter_configuration_visitor.h"
#include "opentelemetry/sdk/configuration/span_processor_configuration_visitor.h"
#include "opentelemetry/sdk/configuration/trace_id_ratio_based_sampler_configuration.h"
#include "opentelemetry/sdk/configuration/yaml_document.h"
#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h"
#include "opentelemetry/sdk/init/configured_sdk.h"
#include "opentelemetry/sdk/init/console_span_exporter_builder.h"
Expand Down

0 comments on commit eb1155d

Please sign in to comment.