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
2 changes: 1 addition & 1 deletion .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is absl only required for WITH_OTLP_GRPC, not for all cases?

Copy link
Member Author

@owent owent Mar 28, 2025

Choose a reason for hiding this comment

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

otel-cpp's API no longer depends on abseil-cpp's headers, eliminating path conflicts between internal and external versions of abseil-cpp.

Some components use protobuf, which may include abseil-cpp headers with overlapping paths from the internal version. This necessitates abseil-cpp when using a newer version of protobuf.

The protobuf package file automatically calls find_package(absl CONFIG REQUIRED) and imports it when needed. However, some gRPC versions do not import abseil-cpp, so it only needs to be imported when working with gRPC.

endif()

if(WITH_OTLP_GRPC
Expand Down
2 changes: 1 addition & 1 deletion api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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)"],
Expand Down
15 changes: 0 additions & 15 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
32 changes: 7 additions & 25 deletions api/include/opentelemetry/nostd/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <exception>
# if defined(__EXCEPTIONS)
# include <exception>
OPENTELEMETRY_BEGIN_NAMESPACE
namespace nostd
{
Expand All @@ -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
Expand All @@ -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
{
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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

Expand Down
19 changes: 5 additions & 14 deletions cmake/opentelemetry-cpp-config.cmake.in
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -73,10 +68,6 @@ include(CMakeFindDependencyMacro)

find_dependency(Threads)

if(@WITH_ABSEIL@)
find_dependency(absl)
endif()

if(@WITH_OTLP_GRPC@)
find_dependency(gRPC)
endif()
Expand All @@ -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()
Expand All @@ -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")
Expand Down
10 changes: 4 additions & 6 deletions cmake/opentelemetry-proto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/patch-imported-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions docs/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions exporters/otlp/test/otlp_file_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, common::AttributeValue> 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
Expand Down Expand Up @@ -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())
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Loading
Loading