Skip to content

Commit

Permalink
Merge branch 'main' into poc_config_yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Jan 14, 2025
2 parents 8679b5e + 62b7197 commit f010853
Show file tree
Hide file tree
Showing 108 changed files with 2,251 additions and 247 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
libbenchmark-dev
sudo ./ci/install_ryml.sh
- name: setup grpc
run: |
sudo ./ci/setup_grpc.sh
- name: Prepare CMake
run: |
TOPDIR=`pwd`
Expand All @@ -43,12 +47,14 @@ jobs:
-DWITH_CONFIGURATION=ON \
-DBUILD_TESTING=ON \
-DBUILD_W3CTRACECONTEXT_TEST=ON \
-DWITH_OTLP_GRPC=OFF \
-DWITH_OTLP_GRPC=ON \
-DWITH_OTLP_HTTP=ON \
-DWITH_OTLP_FILE=ON \
-DWITH_OPENTRACING=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_THREAD_INSTRUMENTATION=ON \
-DWITH_ZIPKIN=ON \
-DWITH_PROMETHEUS=OFF \
-DWITH_PROMETHEUS=ON \
..
- name: iwyu_tool
Expand All @@ -69,7 +75,7 @@ jobs:
readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log`
echo "include-what-you-use reported ${WARNING_COUNT} warning(s)"
# Acceptable limit, to decrease over time down to 0
readonly WARNING_LIMIT=180
readonly WARNING_LIMIT=10
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
exit 1
Expand Down
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,69 @@ Increment the:
* [EXPORTER] Fix scope attributes missing from otlp traces metrics
[#3185](https://github.com/open-telemetry/opentelemetry-cpp/pull/3185)

* [EXPORTER] Fix throw in OtlpGrpcMetricExporter with shared grpc client
[#3243](https://github.com/open-telemetry/opentelemetry-cpp/pull/3243)

* [SDK] Better control of threads executed by opentelemetry-cpp
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)

New features:

* [SDK] Better control of threads executed by opentelemetry-cpp
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)

* This feature provides a way for applications,
when configuring the SDK and exporters,
to participate in the execution path
of internal opentelemetry-cpp threads.

* The opentelemetry-cpp library provides the following:

* a new ThreadInstrumentation interface,
* new runtime options structures, to optionally configure the SDK:
* BatchSpanProcessorRuntimeOptions
* PeriodicExportingMetricReaderRuntimeOptions
* BatchLogRecordProcessorRuntimeOptions
* new runtime options structures,
to optionally configure the OTLP HTTP exporters:
* OtlpHttpExporterRuntimeOptions
* OtlpHttpMetricExporterRuntimeOptions
* OtlpHttpLogRecordExporterRuntimeOptions
* new ThreadInstrumentation parameters,
to optionally configure the CURL HttpClient
* new runtime options structures,
to optionally configure the OTLP FILE exporters:
* OtlpFileExporterRuntimeOptions
* OtlpFileMetricExporterRuntimeOptions
* OtlpFileLogRecordExporterRuntimeOptions
* new runtime options structure,
to optionally configure the OTLP FILE client:
* OtlpFileClientRuntimeOptions

* Using the optional runtime options structures,
an application can subclass the ThreadInstrumentation interface,
and be notified of specific events of interest during the execution
of an internal opentelemetry-cpp thread.

* This allows an application to call, for example:

* pthread_setaffinity_np(), for better performances,
* setns(), to control the network namespace used by HTTP CURL connections
* pthread_setname_np(), for better observability from the operating system
* many more specific apis, as needed

* See the documentation for ThreadInstrumentation for details.

* A new example program, example_otlp_instrumented_http,
shows how to use the feature,
and add application logic in the thread execution code path.

* Note that this feature is experimental,
protected by a WITH_THREAD_INSTRUMENTATION_PREVIEW
flag in CMake. Various runtime options structures,
as well as the thread instrumentation interface,
may change without notice before this feature is declared stable.

## [1.18 2024-11-25]

* [EXPORTER] Fix crash in ElasticsearchLogRecordExporter
Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF)
option(WITH_METRICS_EXEMPLAR_PREVIEW
"Whether to enable exemplar within metrics" OFF)

# Experimental, so behind feature flag by default
option(WITH_THREAD_INSTRUMENTATION_PREVIEW
"Whether to enable thread instrumentation" OFF)

option(OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS
"Whether to build test libraries that are always linked as shared libs"
OFF)
Expand Down Expand Up @@ -367,11 +371,16 @@ if(WITH_PROMETHEUS)
if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git)
set(SAVED_ENABLE_TESTING ${ENABLE_TESTING})
set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY})
set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
set(ENABLE_TESTING OFF)
set(CMAKE_CXX_CLANG_TIDY "")
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "")
add_subdirectory(third_party/prometheus-cpp)
set(ENABLE_TESTING ${SAVED_ENABLE_TESTING})
set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
else()
message(
FATAL_ERROR
Expand Down Expand Up @@ -725,8 +734,13 @@ if(WITH_OPENTRACING)
if(EXISTS "${PROJECT_SOURCE_DIR}/${OPENTRACING_DIR}/.git")
set(SAVED_BUILD_TESTING ${BUILD_TESTING})
set(BUILD_TESTING OFF)
set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "")
add_subdirectory(${OPENTRACING_DIR})
set(BUILD_TESTING ${SAVED_BUILD_TESTING})
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE})
else()
message(
FATAL_ERROR
Expand Down
5 changes: 5 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ if(WITH_METRICS_EXEMPLAR_PREVIEW)
INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW)
endif()

if(WITH_THREAD_INSTRUMENTATION_PREVIEW)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_THREAD_INSTRUMENTATION_PREVIEW)
endif()

if(WITH_OTLP_HTTP_COMPRESSION)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW)
Expand Down
2 changes: 2 additions & 0 deletions api/include/opentelemetry/logs/severity.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <cstdint>

#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

Expand Down
24 changes: 4 additions & 20 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,9 @@ mkdir -p "${BUILD_DIR}"
[ -z "${PLUGIN_DIR}" ] && export PLUGIN_DIR=$HOME/plugin
mkdir -p "${PLUGIN_DIR}"

IWYU=""
MAKE_COMMAND="make -k -j \$(nproc)"

# Temporarily disable the IWYU build.
# It fails in Ubuntu 24-04 CI with:
# Error running 'iwyu': Segmentation fault
#
# if [[ "${CXX}" == *clang* ]]; then
# MAKE_COMMAND="make -k CXX=include-what-you-use CXXFLAGS=\"-Xiwyu --error_always\" -j \$(nproc)"
# IWYU="-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=iwyu"
# fi

echo "make command: ${MAKE_COMMAND}"
echo "IWYU option: ${IWYU}"

BAZEL_OPTIONS_DEFAULT="--copt=-DENABLE_METRICS_EXEMPLAR_PREVIEW"
BAZEL_OPTIONS="$BAZEL_OPTIONS_DEFAULT"
Expand Down Expand Up @@ -131,7 +120,7 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
${IWYU} \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -153,7 +142,7 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
${IWYU} \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -176,6 +165,7 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
make -k -j $(nproc)
make test
Expand All @@ -199,7 +189,7 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then
-DWITH_ABI_VERSION_1=OFF \
-DWITH_ABI_VERSION_2=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
${IWYU} \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand Down Expand Up @@ -270,7 +260,6 @@ elif [[ "$1" == "cmake.c++20.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX20 \
${IWYU} \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -282,7 +271,6 @@ elif [[ "$1" == "cmake.c++23.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX23 \
${IWYU} \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -295,7 +283,6 @@ elif [[ "$1" == "cmake.c++14.stl.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX14 \
${IWYU} \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -308,7 +295,6 @@ elif [[ "$1" == "cmake.c++17.stl.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX17 \
${IWYU} \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -321,7 +307,6 @@ elif [[ "$1" == "cmake.c++20.stl.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX20 \
${IWYU} \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand All @@ -334,7 +319,6 @@ elif [[ "$1" == "cmake.c++23.stl.test" ]]; then
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
-DWITH_STL=CXX23 \
${IWYU} \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
make test
Expand Down
3 changes: 3 additions & 0 deletions cmake/opentelemetry-proto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ if(WITH_OTLP_GRPC)
${LOGS_SERVICE_GRPC_PB_CPP_FILE} ${METRICS_SERVICE_GRPC_PB_CPP_FILE})
set_target_version(opentelemetry_proto_grpc)

# Disable include-what-you-use on generated code.
set_target_properties(opentelemetry_proto_grpc PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "")

list(APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc)
target_link_libraries(opentelemetry_proto_grpc PUBLIC opentelemetry_proto)

Expand Down
3 changes: 3 additions & 0 deletions examples/grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ add_library(example_grpc_proto ${example_grpc_srcs} ${example_grpc_hdrs}

patch_protobuf_targets(example_grpc_proto)

# Disable include-what-you-use on generated code.
set_target_properties(example_grpc_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "")

include_directories(
${CMAKE_SOURCE_DIR}/exporters/ostream/include ${CMAKE_SOURCE_DIR}/ext/include
${CMAKE_SOURCE_DIR}/api/include/ ${CMAKE_SOURCE_DIR/})
Expand Down
24 changes: 20 additions & 4 deletions examples/grpc/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,32 @@
// ambiguity with `nostd::variant` if compiled with Visual Studio 2015. Other
// modern compilers are unaffected.
#include <grpcpp/grpcpp.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/support/status.h>

#include <stdint.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <utility>
#include "opentelemetry/context/propagation/global_propagator.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/context/runtime_context.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/trace/propagation/http_trace_context.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_metadata.h"
#include "opentelemetry/trace/span_startoptions.h"
#include "opentelemetry/trace/tracer.h"

#ifdef BAZEL_BUILD
# include "examples/grpc/protos/messages.grpc.pb.h"
# include "examples/grpc/protos/messages.pb.h"
#else
# include "messages.grpc.pb.h"
# include "messages.pb.h"
#endif

#include <iostream>
#include <memory>
#include <string>

#include "opentelemetry/semconv/incubating/rpc_attributes.h"
#include "opentelemetry/semconv/network_attributes.h"
#include "tracer_common.h"
Expand Down
46 changes: 29 additions & 17 deletions examples/grpc/server.cc
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#ifdef BAZEL_BUILD
# include "examples/grpc/protos/messages.grpc.pb.h"
#else
# include "messages.grpc.pb.h"
#endif

#include "opentelemetry/semconv/incubating/rpc_attributes.h"
#include "opentelemetry/trace/context.h"
#include "opentelemetry/trace/span_context_kv_iterable_view.h"
#include "tracer_common.h"

#include <grpcpp/grpcpp.h>
#include <grpcpp/security/server_credentials.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>

#include <chrono>
#include <fstream>
#include <grpcpp/support/status.h>
#include <grpcpp/support/string_ref.h>
#include <stdint.h>
#include <stdlib.h>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <thread>
#include <utility>

#include "opentelemetry/context/propagation/global_propagator.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/context/runtime_context.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/variant.h"
#include "opentelemetry/semconv/incubating/rpc_attributes.h"
#include "opentelemetry/trace/context.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/trace/span_metadata.h"
#include "opentelemetry/trace/span_startoptions.h"
#include "opentelemetry/trace/tracer.h"
#include "tracer_common.h"

#ifdef BAZEL_BUILD
# include "examples/grpc/protos/messages.grpc.pb.h"
# include "examples/grpc/protos/messages.pb.h"
#else
# include "messages.grpc.pb.h"
# include "messages.pb.h"
#endif

using grpc::Server;
using grpc::ServerBuilder;
Expand Down
Loading

0 comments on commit f010853

Please sign in to comment.