Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/main' into otlp_file_exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Mar 14, 2024
2 parents 046ba78 + 19f0dc7 commit a3900bc
Show file tree
Hide file tree
Showing 97 changed files with 1,022 additions and 232 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ Increment the:

* [EXPORTER] Add OTLP File exporters
[#2540](https://github.com/open-telemetry/opentelemetry-cpp/pull/2540)
* [EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter
[#2530](https://github.com/open-telemetry/opentelemetry-cpp/pull/2530)
* [EXPORTER] Support URL-encoded values for `OTEL_EXPORTER_OTLP_HEADERS`
[#2579](https://github.com/open-telemetry/opentelemetry-cpp/pull/2579)

Important changes:

* [EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter
[#2530](https://github.com/open-telemetry/opentelemetry-cpp/pull/2530)
* In the `OtlpHttpExporterOptions` and `OtlpGrpcExporterOptions`, a new
field called compression has been introduced. This field can be set
to "gzip” to enable gzip compression.
* The CMake option `WITH_OTLP_HTTP_COMPRESSION` is introduced to enable
gzip compression support for the OTLP HTTP Exporter and includes a
dependency on zlib.
* [SDK] Change OTLP HTTP content_type default to binary
[#2558](https://github.com/open-telemetry/opentelemetry-cpp/pull/2558)

## [1.14.2] 2024-02-27

* [SDK] Fix observable attributes drop
[#2557](https://github.com/open-telemetry/opentelemetry-cpp/pull/2557)

## [1.14.1] 2024-02-23

Expand Down
50 changes: 35 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)

# See https://cmake.org/cmake/help/v3.3/policy/CMP0057.html required by certain
# versions of gtest
Expand Down Expand Up @@ -207,6 +207,10 @@ option(WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK"
option(WITH_OTLP_FILE_PREVIOUS
"Whether to include the OTLP file exporter in the SDK" OFF)
set(WITH_OTLP_FILE ${WITH_OTLP_FILE_PREVIOUS})
option(
WITH_OTLP_HTTP_COMPRESSION
"Whether to include gzip compression for the OTLP http exporter in the SDK"
OFF)

option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)

Expand Down Expand Up @@ -300,15 +304,16 @@ function(install_windows_deps)
set(VCPKG_TARGET_ARCHITECTURE
${ARCH}
PARENT_SCOPE)
message("Installing build tools and dependencies...")
message(STATUS "Installing build tools and dependencies...")
set(ENV{ARCH} ${ARCH})
execute_process(
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/setup-buildtools.cmd)
set(CMAKE_TOOLCHAIN_FILE
${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake
CACHE FILEPATH "")
message(
"Make sure that vcpkg.cmake is set as the CMAKE_TOOLCHAIN_FILE at the START of the cmake build process!
STATUS
"Make sure that vcpkg.cmake is set as the CMAKE_TOOLCHAIN_FILE at the START of the cmake build process!
Can be command-line arg (cmake -DCMAKE_TOOLCHAIN_FILE=...) or set in your editor of choice."
)

Expand Down Expand Up @@ -346,7 +351,7 @@ include(GNUInstallDirs)
if(WITH_PROMETHEUS)
find_package(prometheus-cpp CONFIG QUIET)
if(NOT prometheus-cpp_FOUND)
message("Trying to use local prometheus-cpp from submodule")
message(STATUS "Trying to use local prometheus-cpp from submodule")
if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git)
set(SAVED_ENABLE_TESTING ${ENABLE_TESTING})
set(ENABLE_TESTING OFF)
Expand All @@ -360,7 +365,7 @@ if(WITH_PROMETHEUS)
"git submodule update --init --recursive")
endif()
else()
message("Using external prometheus-cpp")
message(STATUS "Using external prometheus-cpp")
endif()
endif()

Expand Down Expand Up @@ -390,7 +395,7 @@ if(WITH_OTLP_GRPC
endif()

if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE))
message(STATUS_FATAL "Windows dependency installation failed!")
message(FATAL_ERROR "Windows dependency installation failed!")
endif()
if(WIN32)
include(${CMAKE_TOOLCHAIN_FILE})
Expand Down Expand Up @@ -454,6 +459,18 @@ if((NOT WITH_API_ONLY) AND WITH_HTTP_CLIENT_CURL)
message(STATUS "Found CURL: ${CURL_LIBRARIES}, version ${CURL_VERSION}")
endif()

#
# Do we need ZLIB ?
#

if((NOT WITH_API_ONLY)
AND WITH_HTTP_CLIENT_CURL
AND WITH_OTLP_HTTP_COMPRESSION)
# No specific version required.
find_package(ZLIB REQUIRED)
message(STATUS "Found ZLIB: ${ZLIB_LIBRARIES}, version ${ZLIB_VERSION}")
endif()

#
# Do we need NLOHMANN_JSON ?
#
Expand All @@ -475,15 +492,15 @@ endif()

if(OTELCPP_MAINTAINER_MODE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message("Building with gcc in maintainer mode.")
message(STATUS "Building with gcc in maintainer mode.")

add_compile_options(-Wall)
add_compile_options(-Werror)
add_compile_options(-Wextra)

# Tested with GCC 9.4 on github.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.4)
message("Building with additional warnings for gcc.")
message(STATUS "Building with additional warnings for gcc.")

# Relaxed warnings

Expand All @@ -495,6 +512,8 @@ if(OTELCPP_MAINTAINER_MODE)
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Woverloaded-virtual>)
add_compile_options(
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Wsuggest-override>)
add_compile_options(
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Wold-style-cast>)

# C and C++
add_compile_options(-Wcast-qual)
Expand All @@ -506,15 +525,15 @@ if(OTELCPP_MAINTAINER_MODE)
add_compile_options(-Wvla)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message("Building with clang in maintainer mode.")
message(STATUS "Building with clang in maintainer mode.")

add_compile_options(-Wall)
add_compile_options(-Werror)
add_compile_options(-Wextra)

# Tested with Clang 11.0 on github.
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
message("Building with additional warnings for clang.")
message(STATUS "Building with additional warnings for clang.")

# Relaxed warnings
add_compile_options(-Wno-error=unused-private-field)
Expand All @@ -534,9 +553,10 @@ if(OTELCPP_MAINTAINER_MODE)
add_compile_options(-Wundef)
add_compile_options(-Wundefined-reinterpret-cast)
add_compile_options(-Wvla)
add_compile_options(-Wold-style-cast)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
message("Building with msvc in maintainer mode.")
message(STATUS "Building with msvc in maintainer mode.")

add_compile_options(/WX)
add_compile_options(/W4)
Expand Down Expand Up @@ -606,8 +626,8 @@ if(BUILD_TESTING)
if(GTEST_INCLUDE_DIRS)
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
endif()
message("GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}")
message("GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}")
message(STATUS "GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}")
message(STATUS "GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}")
enable_testing()
if(WITH_BENCHMARK)
# Benchmark respects the CMAKE_PREFIX_PATH
Expand Down Expand Up @@ -639,7 +659,7 @@ if(WITH_OPENTRACING)
find_package(OpenTracing CONFIG QUIET)
if(NOT OpenTracing_FOUND)
set(OPENTRACING_DIR "third_party/opentracing-cpp")
message("Trying to use local ${OPENTRACING_DIR} from submodule")
message(STATUS "Trying to use local ${OPENTRACING_DIR} from submodule")
if(EXISTS "${PROJECT_SOURCE_DIR}/${OPENTRACING_DIR}/.git")
set(SAVED_BUILD_TESTING ${BUILD_TESTING})
set(BUILD_TESTING OFF)
Expand All @@ -653,7 +673,7 @@ if(WITH_OPENTRACING)
"git submodule update --init --recursive")
endif()
else()
message("Using external opentracing-cpp")
message(STATUS "Using external opentracing-cpp")
endif()
add_subdirectory(opentracing-shim)
endif()
Expand Down
5 changes: 5 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ if(WITH_METRICS_EXEMPLAR_PREVIEW)
INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW)
endif()

if(WITH_OTLP_HTTP_COMPRESSION)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW)
endif()

include(${PROJECT_SOURCE_DIR}/cmake/pkgconfig.cmake)

if(OPENTELEMETRY_INSTALL)
Expand Down
110 changes: 100 additions & 10 deletions api/include/opentelemetry/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,112 @@

#pragma once

#if !defined(OPENTELEMETRY_LIKELY_IF) && defined(__cplusplus)
/*
Expected usage pattern:
if OPENTELEMETRY_LIKELY_CONDITION (ptr != nullptr)
{
do_something_likely();
} else {
do_something_unlikely();
}
This pattern works with gcc/clang and __builtin_expect(),
as well as with C++20.
It is unclear if __builtin_expect() will be deprecated
in favor of C++20 [[likely]] or not.
OPENTELEMETRY_LIKELY_CONDITION is preferred over OPENTELEMETRY_LIKELY,
to be revisited when C++20 is required.
*/

#if !defined(OPENTELEMETRY_LIKELY_CONDITION) && defined(__cplusplus)
// Only use likely with C++20
# if __cplusplus >= 202002L
// GCC 9 has likely attribute but do not support declare it at the beginning of statement
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
# if __has_cpp_attribute(likely)
# define OPENTELEMETRY_LIKELY_IF(...) \
if (__VA_ARGS__) \
[[likely]]
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
# if __has_cpp_attribute(likely)
# define OPENTELEMETRY_LIKELY_CONDITION(C) (C) [[likely]]
# endif
# endif
# endif
#endif
#if !defined(OPENTELEMETRY_LIKELY_CONDITION) && (defined(__clang__) || defined(__GNUC__))
// Only use if supported by the compiler
# define OPENTELEMETRY_LIKELY_CONDITION(C) (__builtin_expect(!!(C), true))
#endif
#ifndef OPENTELEMETRY_LIKELY_CONDITION
// Do not use likely annotations
# define OPENTELEMETRY_LIKELY_CONDITION(C) (C)
#endif

#if !defined(OPENTELEMETRY_UNLIKELY_CONDITION) && defined(__cplusplus)
// Only use unlikely with C++20
# if __cplusplus >= 202002L
// GCC 9 has unlikely attribute but do not support declare it at the beginning of statement
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
# if __has_cpp_attribute(unlikely)
# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (C) [[unlikely]]
# endif
# endif
# endif
#endif
#if !defined(OPENTELEMETRY_LIKELY_IF) && (defined(__clang__) || defined(__GNUC__))
# define OPENTELEMETRY_LIKELY_IF(...) if (__builtin_expect(!!(__VA_ARGS__), true))
#if !defined(OPENTELEMETRY_UNLIKELY_CONDITION) && (defined(__clang__) || defined(__GNUC__))
// Only use if supported by the compiler
# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (__builtin_expect(!!(C), false))
#endif
#ifndef OPENTELEMETRY_LIKELY_IF
# define OPENTELEMETRY_LIKELY_IF(...) if (__VA_ARGS__)
#ifndef OPENTELEMETRY_UNLIKELY_CONDITION
// Do not use unlikely annotations
# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (C)
#endif

/*
Expected usage pattern:
if (ptr != nullptr)
OPENTELEMETRY_LIKELY
{
do_something_likely();
} else {
do_something_unlikely();
}
This pattern works starting with C++20.
See https://en.cppreference.com/w/cpp/language/attributes/likely
Please use OPENTELEMETRY_LIKELY_CONDITION instead for now.
*/

#if !defined(OPENTELEMETRY_LIKELY) && defined(__cplusplus)
// Only use likely with C++20
# if __cplusplus >= 202002L
// GCC 9 has likely attribute but do not support declare it at the beginning of statement
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
# if __has_cpp_attribute(likely)
# define OPENTELEMETRY_LIKELY [[likely]]
# endif
# endif
# endif
#endif

#ifndef OPENTELEMETRY_LIKELY
# define OPENTELEMETRY_LIKELY
#endif

#if !defined(OPENTELEMETRY_UNLIKELY) && defined(__cplusplus)
// Only use unlikely with C++20
# if __cplusplus >= 202002L
// GCC 9 has unlikely attribute but do not support declare it at the beginning of statement
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
# if __has_cpp_attribute(unlikely)
# define OPENTELEMETRY_UNLIKELY [[unlikely]]
# endif
# endif
# endif
#endif

#ifndef OPENTELEMETRY_UNLIKELY
# define OPENTELEMETRY_UNLIKELY
#endif

/// \brief Declare variable as maybe unused
Expand Down
10 changes: 8 additions & 2 deletions api/include/opentelemetry/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,19 @@ class Logger

inline bool Enabled(Severity severity, const EventId &event_id) const noexcept
{
OPENTELEMETRY_LIKELY_IF(Enabled(severity) == false) { return false; }
if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity))
{
return false;
}
return EnabledImplementation(severity, event_id);
}

inline bool Enabled(Severity severity, int64_t event_id) const noexcept
{
OPENTELEMETRY_LIKELY_IF(Enabled(severity) == false) { return false; }
if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity))
{
return false;
}
return EnabledImplementation(severity, event_id);
}

Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/trace/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SpanContext final
SpanContext(bool sampled_flag, bool is_remote) noexcept
: trace_id_(),
span_id_(),
trace_flags_(trace::TraceFlags((uint8_t)sampled_flag)),
trace_flags_(trace::TraceFlags(static_cast<uint8_t>(sampled_flag))),
is_remote_(is_remote),
trace_state_(TraceState::GetDefault())
{}
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# define OPENTELEMETRY_ABI_VERSION_NO 1
#endif

#define OPENTELEMETRY_VERSION "1.14.1"
#define OPENTELEMETRY_VERSION "1.14.2"
#define OPENTELEMETRY_VERSION_MAJOR 1
#define OPENTELEMETRY_VERSION_MINOR 14
#define OPENTELEMETRY_VERSION_PATCH 1
#define OPENTELEMETRY_VERSION_PATCH 2

#define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO)

Expand Down
Loading

0 comments on commit a3900bc

Please sign in to comment.