diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 00eabf2f42..2844f58341 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -12,7 +12,7 @@ environment variables (for evaluation in `devcontainer.json`). * **abseil-cpp version:** This is the version of abseil-cpp that will be used to build protobuf, gRPC, - and opentelemetry-cpp (when WITH_ABSEIL is set). + and opentelemetry-cpp. * Docker ARG: `ABSEIL_CPP_VERSION` * Host Environment Variable: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc8fde8bbc..61f7a97db5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,15 +30,6 @@ jobs: # sudo -E ./ci/setup_googletest.sh # sudo -E ./ci/install_abseil.sh # sudo -E ./ci/install_protobuf.sh -# - name: run otlp exporter tests -# env: -# CC: /usr/bin/gcc-10 -# CXX: /usr/bin/g++-10 -# WITH_ABSEIL: 'ON' -# CXX_STANDARD: '14' -# run: | -# sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp -# ./ci/do_ci.sh cmake.exporter.otprotocol.test cmake_test: name: CMake test (prometheus, elasticsearch, zipkin) @@ -528,7 +519,6 @@ jobs: sudo -E ./ci/install_protobuf.sh - name: run otlp exporter tests env: - WITH_ABSEIL: 'ON' CXX_STANDARD: '14' run: | sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index b467c56d44..599d09bd44 100644 --- a/.github/workflows/clang-tidy.yaml +++ b/.github/workflows/clang-tidy.yaml @@ -78,4 +78,4 @@ jobs: COUNT=$(grep -c "warning:" clang-tidy.log) echo "clang-tidy reported ${COUNT} warning(s)" -# TODO: include WITH_OTLP_GRPC and WITH_ABSEIL flags. +# TODO: include WITH_OTLP_GRPC flags. diff --git a/CHANGELOG.md b/CHANGELOG.md index d9d23ceb24..2c5668f161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ Increment the: ## [Unreleased] +* [API] Remove `WITH_ABSEIL` and `HAVE_ABSEIL` + [#3318](https://github.com/open-telemetry/opentelemetry-cpp/pull/3318) + ## [1.20 2025-04-01] * [BUILD] Update opentelemetry-proto version diff --git a/CMakeLists.txt b/CMakeLists.txt index dc0a3af9db..0bee414678 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,8 +188,6 @@ set(WITH_STL option(WITH_GSL "Whether to use Guidelines Support Library for C++ latest features" OFF) -option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF) - set(OPENTELEMETRY_INSTALL_default ON) if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(OPENTELEMETRY_INSTALL_default OFF) @@ -400,10 +398,8 @@ if(WITH_PROMETHEUS) endif() endif() -if(WITH_ABSEIL) - if(NOT TARGET absl::strings) - find_package(absl CONFIG REQUIRED) - endif() +if(WITH_OTLP_GRPC) + find_package(absl CONFIG REQUIRED) endif() if(WITH_OTLP_GRPC diff --git a/api/BUILD b/api/BUILD index dfc7d3c645..fb31393569 100644 --- a/api/BUILD +++ b/api/BUILD @@ -23,7 +23,7 @@ string_flag( cc_library( name = "api", hdrs = glob(["include/**/*.h"]), - defines = ["HAVE_ABSEIL"] + select({ + defines = select({ ":set_cxx_stdlib_none": [], ### automatic selection ":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"], diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 78b924681f..4d7e4542b0 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -35,21 +35,6 @@ if(WITH_NO_DEPRECATED_CODE) INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE) endif() -if(WITH_ABSEIL) - target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL) - target_link_libraries( - opentelemetry_api INTERFACE absl::bad_variant_access absl::any absl::base - absl::bits absl::city) - list( - APPEND - TARGET_DEPS - "absl_bad_variant_access" - "absl_any" - "absl_base" - "absl_bits" - "absl_city") -endif() - if(WITH_STL STREQUAL "OFF") message(STATUS "Building WITH_STL=OFF") elseif(WITH_STL STREQUAL "CXX11") diff --git a/api/include/opentelemetry/nostd/variant.h b/api/include/opentelemetry/nostd/variant.h index b03a9b844b..4abac7766a 100644 --- a/api/include/opentelemetry/nostd/variant.h +++ b/api/include/opentelemetry/nostd/variant.h @@ -14,13 +14,12 @@ #if !defined(OPENTELEMETRY_HAVE_STD_VARIANT) -# ifndef HAVE_ABSEIL // We use a LOCAL snapshot of Abseil that is known to compile with Visual Studio 2015. // Header-only. Without compiling the actual Abseil binary. As Abseil moves on to new // toolchains, it may drop support for Visual Studio 2015 in future versions. -# if defined(__EXCEPTIONS) -# include +# if defined(__EXCEPTIONS) +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { @@ -37,10 +36,9 @@ class bad_variant_access : public std::exception } } // namespace nostd OPENTELEMETRY_END_NAMESPACE -# define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() -# else -# define THROW_BAD_VARIANT_ACCESS std::terminate() -# endif +# define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access() +# else +# define THROW_BAD_VARIANT_ACCESS std::terminate() # endif # ifdef _MSC_VER @@ -51,10 +49,7 @@ OPENTELEMETRY_END_NAMESPACE # pragma warning(disable : 4127) // conditional expression is constant # endif -# ifdef HAVE_ABSEIL -# include "absl/types/variant.h" -# else -# include "opentelemetry/nostd/internal/absl/base/options.h" +# include "opentelemetry/nostd/internal/absl/base/options.h" namespace absl { @@ -67,8 +62,7 @@ class variant; } // namespace OTABSL_OPTION_NAMESPACE_NAME } // namespace absl -# include "opentelemetry/nostd/internal/absl/types/variant.h" -# endif +# include "opentelemetry/nostd/internal/absl/types/variant.h" # ifdef _MSC_VER # pragma warning(pop) @@ -77,17 +71,6 @@ class variant; OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { -# ifdef HAVE_ABSEIL -using absl::bad_variant_access; -using absl::get; -using absl::get_if; -using absl::holds_alternative; -using absl::monostate; -using absl::variant; -using absl::variant_alternative_t; -using absl::variant_size; -using absl::visit; -# else using absl::OTABSL_OPTION_NAMESPACE_NAME::get; using absl::OTABSL_OPTION_NAMESPACE_NAME::get_if; using absl::OTABSL_OPTION_NAMESPACE_NAME::holds_alternative; @@ -96,7 +79,6 @@ using absl::OTABSL_OPTION_NAMESPACE_NAME::variant; using absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t; using absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size; using absl::OTABSL_OPTION_NAMESPACE_NAME::visit; -# endif } // namespace nostd OPENTELEMETRY_END_NAMESPACE diff --git a/cmake/opentelemetry-cpp-config.cmake.in b/cmake/opentelemetry-cpp-config.cmake.in index 254bcc662b..db801b7499 100644 --- a/cmake/opentelemetry-cpp-config.cmake.in +++ b/cmake/opentelemetry-cpp-config.cmake.in @@ -1,17 +1,13 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +#[[ #.rst: # opentelemetry-cpp-config.cmake # -------- # # Find the native opentelemetry-cpp includes and library. # -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# # :: # # OPENTELEMETRY_CPP_INCLUDE_DIRS - Include directories of opentelemetry-cpp. @@ -52,10 +48,9 @@ # opentelemetry-cpp::http_client_curl - Imported target of opentelemetry-cpp::http_client_curl # opentelemetry-cpp::opentracing_shim - Imported target of opentelemetry-cpp::opentracing_shim # - +]] # ============================================================================= -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 +# Copyright The OpenTelemetry Authors SPDX-License-Identifier: Apache-2.0 # ============================================================================= set(OPENTELEMETRY_ABI_VERSION_NO @@ -73,10 +68,6 @@ include(CMakeFindDependencyMacro) find_dependency(Threads) -if(@WITH_ABSEIL@) - find_dependency(absl) -endif() - if(@WITH_OTLP_GRPC@) find_dependency(gRPC) endif() @@ -93,7 +84,7 @@ if("@Protobuf_FOUND@" OR "@PROTOBUF_FOUND@") find_dependency(Protobuf) endif() -if (@WITH_HTTP_CLIENT_CURL@ AND NOT @BUILD_SHARED_LIBS@) +if(@WITH_HTTP_CLIENT_CURL@ AND NOT @BUILD_SHARED_LIBS@) if("@CURL_FOUND@") find_dependency(CURL) endif() @@ -103,7 +94,7 @@ if (@WITH_HTTP_CLIENT_CURL@ AND NOT @BUILD_SHARED_LIBS@) endif() endif() -if(@WITH_ABSEIL@ OR @WITH_OTLP_GRPC@) +if(@WITH_OTLP_GRPC@) find_package(absl CONFIG) elseif(@WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@) if("@Protobuf_VERSION@" VERSION_GREATER_EQUAL "3.22.0") diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 06d6f76f69..d30e8d2293 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -286,11 +286,9 @@ add_custom_command( ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTOBUF_COMMON_FLAGS} ${PROTOBUF_INCLUDE_FLAGS} ${COMMON_PROTO} ${RESOURCE_PROTO} ${TRACE_PROTO} ${LOGS_PROTO} ${METRICS_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO} - ${METRICS_SERVICE_PROTO} ${PROFILES_PROTO} - ${PROFILES_SERVICE_PROTO} + ${METRICS_SERVICE_PROTO} ${PROFILES_PROTO} ${PROFILES_SERVICE_PROTO} COMMENT "[Run]: ${PROTOBUF_RUN_PROTOC_COMMAND}" - DEPENDS ${PROTOBUF_PROTOC_EXECUTABLE} - ) + DEPENDS ${PROTOBUF_PROTOC_EXECUTABLE}) include_directories("${GENERATED_PROTOBUF_PATH}") @@ -343,7 +341,8 @@ if(WITH_OTLP_GRPC) 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 "") + 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) @@ -392,7 +391,6 @@ else() # cmake 3.8 or lower endif() if(WITH_OTLP_GRPC) - find_package(absl CONFIG) if(TARGET absl::synchronization) target_link_libraries(opentelemetry_proto_grpc PRIVATE absl::synchronization) diff --git a/cmake/patch-imported-config.cmake b/cmake/patch-imported-config.cmake index 25d6b2f78f..b49903eb29 100644 --- a/cmake/patch-imported-config.cmake +++ b/cmake/patch-imported-config.cmake @@ -29,7 +29,7 @@ if(TARGET CURL::libcurl endif() # abseil targets -if(WITH_ABSEIL OR WITH_OTLP_GRPC) +if(TARGET absl::bad_variant_access) project_build_tools_patch_default_imported_config( absl::bad_variant_access absl::raw_logging_internal diff --git a/docs/dependencies.md b/docs/dependencies.md index 6375ec79e2..8d19b6490b 100644 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -34,9 +34,6 @@ Both these dependencies are listed here: .We don't use the std::span in this situation.Users can also define `OPENTELEMETRY_OPTION_USE_STD_SPAN=0` to indicate nostd:span will always not be a alias for std::span. - - Uses Abseil C++ Library for `absl::variant` as default `nostd::variant` if - `WITH_ABSEIL` cmake option (always enabled with bazel) - License: `Apache License 2.0` - [OTLP/HTTP+JSON](/exporters/otlp) exporter: diff --git a/examples/grpc/CMakeLists.txt b/examples/grpc/CMakeLists.txt index 015f4a2287..ea34e58364 100644 --- a/examples/grpc/CMakeLists.txt +++ b/examples/grpc/CMakeLists.txt @@ -42,7 +42,7 @@ else() target_link_libraries(example_grpc_proto PUBLIC gRPC::grpc++ ${Protobuf_LIBRARIES}) endif() -if(WITH_ABSEIL OR WITH_OTLP_GRPC) +if(WITH_OTLP_GRPC) target_link_libraries(example_grpc_proto PUBLIC absl::bad_variant_access) endif() diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index bccc15a8f8..126a62310c 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -41,7 +41,8 @@ if(WITH_OTLP_GRPC) PUBLIC opentelemetry_sdk opentelemetry_common opentelemetry_ext # gRPC::grpc++ must be linked before opentelemetry_proto_grpc. opentelemetry_proto_grpc - PRIVATE gRPC::grpc++) + PRIVATE gRPC::grpc++ absl::bad_variant_access absl::any absl::base + absl::bits absl::city) get_target_property(GRPC_INCLUDE_DIRECTORY gRPC::grpc++ INTERFACE_INCLUDE_DIRECTORIES) diff --git a/exporters/otlp/test/otlp_file_exporter_test.cc b/exporters/otlp/test/otlp_file_exporter_test.cc index ab67d1a478..d0c530f55a 100644 --- a/exporters/otlp/test/otlp_file_exporter_test.cc +++ b/exporters/otlp/test/otlp_file_exporter_test.cc @@ -108,9 +108,9 @@ class OtlpFileExporterTestPeer : public ::testing::Test std::string report_trace_id; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 - auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url", - {{ "scope_key", - "scope_value" }}); + std::unordered_map scope_attributes; + scope_attributes["scope_key"] = common::AttributeValue("scope_value"); + auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url", scope_attributes); #else auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url"); #endif @@ -139,6 +139,12 @@ class OtlpFileExporterTestPeer : public ::testing::Test auto check_json_text = output.str(); if (!check_json_text.empty()) { + // If the exporting is splited to two standalone resource_span, just checking the first one. + std::string::size_type eol = check_json_text.find('\n'); + if (eol != std::string::npos) + { + check_json_text = check_json_text.substr(0, eol); + } auto check_json = nlohmann::json::parse(check_json_text, nullptr, false); if (!check_json.is_discarded()) { diff --git a/sdk/src/common/CMakeLists.txt b/sdk/src/common/CMakeLists.txt index 06b3c88c1e..db36266a4f 100644 --- a/sdk/src/common/CMakeLists.txt +++ b/sdk/src/common/CMakeLists.txt @@ -18,7 +18,7 @@ target_link_libraries( opentelemetry_common PUBLIC opentelemetry_api opentelemetry_sdk Threads::Threads) -if(WITH_ABSEIL OR WITH_OTLP_GRPC) +if(WITH_OTLP_GRPC) target_link_libraries(opentelemetry_common PUBLIC absl::strings) endif() diff --git a/sdk/src/common/base64.cc b/sdk/src/common/base64.cc index a78b88ad68..b6da954677 100644 --- a/sdk/src/common/base64.cc +++ b/sdk/src/common/base64.cc @@ -11,16 +11,11 @@ #include #include -#if defined(HAVE_ABSEIL) -# include "absl/strings/escaping.h" -#endif - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { namespace common { -#if !defined(HAVE_ABSEIL) namespace { using Base64EscapeChars = const unsigned char[64]; @@ -145,11 +140,11 @@ static inline int Base64EscapeInternal(std::string &dest, int ret = Base64EscapeInternal(reinterpret_cast(&dest[0]), dest.size(), &olen, src, slen, base64_enc_map, padding_char); -# if defined(HAVE_GSL) +#if defined(HAVE_GSL) Expects(0 != ret || dest.size() == olen + 1); -# else +#else assert(0 != ret || dest.size() == olen + 1); -# endif +#endif // pop back last zero if (!dest.empty() && *dest.rbegin() == 0) { @@ -278,7 +273,6 @@ static int Base64UnescapeInternal(unsigned char *dst, } } // namespace -#endif // Base64Escape() // @@ -292,12 +286,8 @@ OPENTELEMETRY_EXPORT void Base64Escape(opentelemetry::nostd::string_view src, st return; } -#if defined(HAVE_ABSEIL) - absl::Base64Escape(absl::string_view{src.data(), src.size()}, dest); -#else Base64EscapeInternal(*dest, reinterpret_cast(src.data()), src.size(), kBase64EscapeCharsBasic, '='); -#endif } OPENTELEMETRY_EXPORT std::string Base64Escape(opentelemetry::nostd::string_view src) @@ -315,9 +305,6 @@ OPENTELEMETRY_EXPORT bool Base64Unescape(opentelemetry::nostd::string_view src, return false; } -#if defined(HAVE_ABSEIL) - return absl::Base64Unescape(absl::string_view{src.data(), src.size()}, dest); -#else if (src.empty()) { return true; @@ -337,7 +324,6 @@ OPENTELEMETRY_EXPORT bool Base64Unescape(opentelemetry::nostd::string_view src, reinterpret_cast(src.data()), src.size(), kBase64UnescapeCharsBasic, '='); return true; -#endif } } // namespace common diff --git a/tools/ports/opentelemetry/portfile.cmake b/tools/ports/opentelemetry/portfile.cmake index 7c10e1a48f..23a8b87994 100644 --- a/tools/ports/opentelemetry/portfile.cmake +++ b/tools/ports/opentelemetry/portfile.cmake @@ -13,7 +13,6 @@ message("VCPKG_LIBRARY_LINKAGE = ${VCPKG_LIBRARY_LINKAGE}") vcpkg_check_features( OUT_FEATURE_OPTIONS FEATURE_OPTIONS stdlib WITH_STDLIB - abseil WITH_ABSEIL ) # TODO: if building dynamic, use portable ABI. if building static, use STDLIB