Skip to content

Commit ab81479

Browse files
authored
[BUILD] Remove WITH_ABSEIL (open-telemetry#3318)
1 parent 6175aa0 commit ab81479

File tree

18 files changed

+41
-107
lines changed

18 files changed

+41
-107
lines changed

.devcontainer/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ environment variables (for evaluation in `devcontainer.json`).
1212

1313
* **abseil-cpp version:**
1414
This is the version of abseil-cpp that will be used to build protobuf, gRPC,
15-
and opentelemetry-cpp (when WITH_ABSEIL is set).
15+
and opentelemetry-cpp.
1616
* Docker ARG:
1717
`ABSEIL_CPP_VERSION`
1818
* Host Environment Variable:

.github/workflows/ci.yml

-10
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ jobs:
3030
# sudo -E ./ci/setup_googletest.sh
3131
# sudo -E ./ci/install_abseil.sh
3232
# sudo -E ./ci/install_protobuf.sh
33-
# - name: run otlp exporter tests
34-
# env:
35-
# CC: /usr/bin/gcc-10
36-
# CXX: /usr/bin/g++-10
37-
# WITH_ABSEIL: 'ON'
38-
# CXX_STANDARD: '14'
39-
# run: |
40-
# sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp
41-
# ./ci/do_ci.sh cmake.exporter.otprotocol.test
4233

4334
cmake_test:
4435
name: CMake test (prometheus, elasticsearch, zipkin)
@@ -528,7 +519,6 @@ jobs:
528519
sudo -E ./ci/install_protobuf.sh
529520
- name: run otlp exporter tests
530521
env:
531-
WITH_ABSEIL: 'ON'
532522
CXX_STANDARD: '14'
533523
run: |
534524
sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp

.github/workflows/clang-tidy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ jobs:
7878
COUNT=$(grep -c "warning:" clang-tidy.log)
7979
echo "clang-tidy reported ${COUNT} warning(s)"
8080
81-
# TODO: include WITH_OTLP_GRPC and WITH_ABSEIL flags.
81+
# TODO: include WITH_OTLP_GRPC flags.

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Increment the:
1515

1616
## [Unreleased]
1717

18+
* [API] Remove `WITH_ABSEIL` and `HAVE_ABSEIL`
19+
[#3318](https://github.com/open-telemetry/opentelemetry-cpp/pull/3318)
20+
1821
## [1.20 2025-04-01]
1922

2023
* [BUILD] Update opentelemetry-proto version

CMakeLists.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ set(WITH_STL
188188
option(WITH_GSL
189189
"Whether to use Guidelines Support Library for C++ latest features" OFF)
190190

191-
option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)
192-
193191
set(OPENTELEMETRY_INSTALL_default ON)
194192
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
195193
set(OPENTELEMETRY_INSTALL_default OFF)
@@ -400,10 +398,8 @@ if(WITH_PROMETHEUS)
400398
endif()
401399
endif()
402400

403-
if(WITH_ABSEIL)
404-
if(NOT TARGET absl::strings)
405-
find_package(absl CONFIG REQUIRED)
406-
endif()
401+
if(WITH_OTLP_GRPC)
402+
find_package(absl CONFIG REQUIRED)
407403
endif()
408404

409405
if(WITH_OTLP_GRPC

api/BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ string_flag(
2323
cc_library(
2424
name = "api",
2525
hdrs = glob(["include/**/*.h"]),
26-
defines = ["HAVE_ABSEIL"] + select({
26+
defines = select({
2727
":set_cxx_stdlib_none": [],
2828
### automatic selection
2929
":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"],

api/CMakeLists.txt

-15
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,6 @@ if(WITH_NO_DEPRECATED_CODE)
3535
INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE)
3636
endif()
3737

38-
if(WITH_ABSEIL)
39-
target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL)
40-
target_link_libraries(
41-
opentelemetry_api INTERFACE absl::bad_variant_access absl::any absl::base
42-
absl::bits absl::city)
43-
list(
44-
APPEND
45-
TARGET_DEPS
46-
"absl_bad_variant_access"
47-
"absl_any"
48-
"absl_base"
49-
"absl_bits"
50-
"absl_city")
51-
endif()
52-
5338
if(WITH_STL STREQUAL "OFF")
5439
message(STATUS "Building WITH_STL=OFF")
5540
elseif(WITH_STL STREQUAL "CXX11")

api/include/opentelemetry/nostd/variant.h

+7-25
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414

1515
#if !defined(OPENTELEMETRY_HAVE_STD_VARIANT)
1616

17-
# ifndef HAVE_ABSEIL
1817
// We use a LOCAL snapshot of Abseil that is known to compile with Visual Studio 2015.
1918
// Header-only. Without compiling the actual Abseil binary. As Abseil moves on to new
2019
// toolchains, it may drop support for Visual Studio 2015 in future versions.
2120

22-
# if defined(__EXCEPTIONS)
23-
# include <exception>
21+
# if defined(__EXCEPTIONS)
22+
# include <exception>
2423
OPENTELEMETRY_BEGIN_NAMESPACE
2524
namespace nostd
2625
{
@@ -37,10 +36,9 @@ class bad_variant_access : public std::exception
3736
}
3837
} // namespace nostd
3938
OPENTELEMETRY_END_NAMESPACE
40-
# define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access()
41-
# else
42-
# define THROW_BAD_VARIANT_ACCESS std::terminate()
43-
# endif
39+
# define THROW_BAD_VARIANT_ACCESS opentelemetry::nostd::throw_bad_variant_access()
40+
# else
41+
# define THROW_BAD_VARIANT_ACCESS std::terminate()
4442
# endif
4543

4644
# ifdef _MSC_VER
@@ -51,10 +49,7 @@ OPENTELEMETRY_END_NAMESPACE
5149
# pragma warning(disable : 4127) // conditional expression is constant
5250
# endif
5351

54-
# ifdef HAVE_ABSEIL
55-
# include "absl/types/variant.h"
56-
# else
57-
# include "opentelemetry/nostd/internal/absl/base/options.h"
52+
# include "opentelemetry/nostd/internal/absl/base/options.h"
5853

5954
namespace absl
6055
{
@@ -67,8 +62,7 @@ class variant;
6762
} // namespace OTABSL_OPTION_NAMESPACE_NAME
6863
} // namespace absl
6964

70-
# include "opentelemetry/nostd/internal/absl/types/variant.h"
71-
# endif
65+
# include "opentelemetry/nostd/internal/absl/types/variant.h"
7266

7367
# ifdef _MSC_VER
7468
# pragma warning(pop)
@@ -77,17 +71,6 @@ class variant;
7771
OPENTELEMETRY_BEGIN_NAMESPACE
7872
namespace nostd
7973
{
80-
# ifdef HAVE_ABSEIL
81-
using absl::bad_variant_access;
82-
using absl::get;
83-
using absl::get_if;
84-
using absl::holds_alternative;
85-
using absl::monostate;
86-
using absl::variant;
87-
using absl::variant_alternative_t;
88-
using absl::variant_size;
89-
using absl::visit;
90-
# else
9174
using absl::OTABSL_OPTION_NAMESPACE_NAME::get;
9275
using absl::OTABSL_OPTION_NAMESPACE_NAME::get_if;
9376
using absl::OTABSL_OPTION_NAMESPACE_NAME::holds_alternative;
@@ -96,7 +79,6 @@ using absl::OTABSL_OPTION_NAMESPACE_NAME::variant;
9679
using absl::OTABSL_OPTION_NAMESPACE_NAME::variant_alternative_t;
9780
using absl::OTABSL_OPTION_NAMESPACE_NAME::variant_size;
9881
using absl::OTABSL_OPTION_NAMESPACE_NAME::visit;
99-
# endif
10082
} // namespace nostd
10183
OPENTELEMETRY_END_NAMESPACE
10284

cmake/opentelemetry-cpp-config.cmake.in

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4+
#[[
45
#.rst:
56
# opentelemetry-cpp-config.cmake
67
# --------
78
#
89
# Find the native opentelemetry-cpp includes and library.
910
#
10-
# Result Variables
11-
# ^^^^^^^^^^^^^^^^
12-
#
13-
# This module defines the following variables:
14-
#
1511
# ::
1612
#
1713
# OPENTELEMETRY_CPP_INCLUDE_DIRS - Include directories of opentelemetry-cpp.
@@ -52,10 +48,9 @@
5248
# opentelemetry-cpp::http_client_curl - Imported target of opentelemetry-cpp::http_client_curl
5349
# opentelemetry-cpp::opentracing_shim - Imported target of opentelemetry-cpp::opentracing_shim
5450
#
55-
51+
]]
5652
# =============================================================================
57-
# Copyright The OpenTelemetry Authors
58-
# SPDX-License-Identifier: Apache-2.0
53+
# Copyright The OpenTelemetry Authors SPDX-License-Identifier: Apache-2.0
5954
# =============================================================================
6055

6156
set(OPENTELEMETRY_ABI_VERSION_NO
@@ -73,10 +68,6 @@ include(CMakeFindDependencyMacro)
7368

7469
find_dependency(Threads)
7570

76-
if(@WITH_ABSEIL@)
77-
find_dependency(absl)
78-
endif()
79-
8071
if(@WITH_OTLP_GRPC@)
8172
find_dependency(gRPC)
8273
endif()
@@ -93,7 +84,7 @@ if("@Protobuf_FOUND@" OR "@PROTOBUF_FOUND@")
9384
find_dependency(Protobuf)
9485
endif()
9586

96-
if (@WITH_HTTP_CLIENT_CURL@ AND NOT @BUILD_SHARED_LIBS@)
87+
if(@WITH_HTTP_CLIENT_CURL@ AND NOT @BUILD_SHARED_LIBS@)
9788
if("@CURL_FOUND@")
9889
find_dependency(CURL)
9990
endif()
@@ -103,7 +94,7 @@ if (@WITH_HTTP_CLIENT_CURL@ AND NOT @BUILD_SHARED_LIBS@)
10394
endif()
10495
endif()
10596

106-
if(@WITH_ABSEIL@ OR @WITH_OTLP_GRPC@)
97+
if(@WITH_OTLP_GRPC@)
10798
find_package(absl CONFIG)
10899
elseif(@WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@)
109100
if("@Protobuf_VERSION@" VERSION_GREATER_EQUAL "3.22.0")

cmake/opentelemetry-proto.cmake

+4-6
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,9 @@ add_custom_command(
286286
${PROTOBUF_PROTOC_EXECUTABLE} ${PROTOBUF_COMMON_FLAGS}
287287
${PROTOBUF_INCLUDE_FLAGS} ${COMMON_PROTO} ${RESOURCE_PROTO} ${TRACE_PROTO}
288288
${LOGS_PROTO} ${METRICS_PROTO} ${TRACE_SERVICE_PROTO} ${LOGS_SERVICE_PROTO}
289-
${METRICS_SERVICE_PROTO} ${PROFILES_PROTO}
290-
${PROFILES_SERVICE_PROTO}
289+
${METRICS_SERVICE_PROTO} ${PROFILES_PROTO} ${PROFILES_SERVICE_PROTO}
291290
COMMENT "[Run]: ${PROTOBUF_RUN_PROTOC_COMMAND}"
292-
DEPENDS ${PROTOBUF_PROTOC_EXECUTABLE}
293-
)
291+
DEPENDS ${PROTOBUF_PROTOC_EXECUTABLE})
294292

295293
include_directories("${GENERATED_PROTOBUF_PATH}")
296294

@@ -343,7 +341,8 @@ if(WITH_OTLP_GRPC)
343341
set_target_version(opentelemetry_proto_grpc)
344342

345343
# Disable include-what-you-use on generated code.
346-
set_target_properties(opentelemetry_proto_grpc PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "")
344+
set_target_properties(opentelemetry_proto_grpc
345+
PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "")
347346

348347
list(APPEND OPENTELEMETRY_PROTO_TARGETS opentelemetry_proto_grpc)
349348
target_link_libraries(opentelemetry_proto_grpc PUBLIC opentelemetry_proto)
@@ -392,7 +391,6 @@ else() # cmake 3.8 or lower
392391
endif()
393392

394393
if(WITH_OTLP_GRPC)
395-
find_package(absl CONFIG)
396394
if(TARGET absl::synchronization)
397395
target_link_libraries(opentelemetry_proto_grpc
398396
PRIVATE absl::synchronization)

cmake/patch-imported-config.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if(TARGET CURL::libcurl
2929
endif()
3030

3131
# abseil targets
32-
if(WITH_ABSEIL OR WITH_OTLP_GRPC)
32+
if(TARGET absl::bad_variant_access)
3333
project_build_tools_patch_default_imported_config(
3434
absl::bad_variant_access
3535
absl::raw_logging_internal

docs/dependencies.md

-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ Both these dependencies are listed here:
3434
.We don't use the std::span in this situation.Users can also define
3535
`OPENTELEMETRY_OPTION_USE_STD_SPAN=0` to indicate nostd:span will always
3636
not be a alias for std::span.
37-
- Uses Abseil C++ Library for `absl::variant` as default `nostd::variant` if
38-
`WITH_ABSEIL` cmake option (always enabled with bazel)
39-
License: `Apache License 2.0`
4037

4138
- [OTLP/HTTP+JSON](/exporters/otlp)
4239
exporter:

examples/grpc/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ else()
4242
target_link_libraries(example_grpc_proto PUBLIC gRPC::grpc++
4343
${Protobuf_LIBRARIES})
4444
endif()
45-
if(WITH_ABSEIL OR WITH_OTLP_GRPC)
45+
if(WITH_OTLP_GRPC)
4646
target_link_libraries(example_grpc_proto PUBLIC absl::bad_variant_access)
4747
endif()
4848

exporters/otlp/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ if(WITH_OTLP_GRPC)
4141
PUBLIC opentelemetry_sdk opentelemetry_common opentelemetry_ext
4242
# gRPC::grpc++ must be linked before opentelemetry_proto_grpc.
4343
opentelemetry_proto_grpc
44-
PRIVATE gRPC::grpc++)
44+
PRIVATE gRPC::grpc++ absl::bad_variant_access absl::any absl::base
45+
absl::bits absl::city)
4546

4647
get_target_property(GRPC_INCLUDE_DIRECTORY gRPC::grpc++
4748
INTERFACE_INCLUDE_DIRECTORIES)

exporters/otlp/test/otlp_file_exporter_test.cc

+9-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ class OtlpFileExporterTestPeer : public ::testing::Test
108108
std::string report_trace_id;
109109

110110
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
111-
auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url",
112-
{{ "scope_key",
113-
"scope_value" }});
111+
std::unordered_map<std::string, common::AttributeValue> scope_attributes;
112+
scope_attributes["scope_key"] = common::AttributeValue("scope_value");
113+
auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url", scope_attributes);
114114
#else
115115
auto tracer = provider->GetTracer("scope_name", "scope_version", "scope_url");
116116
#endif
@@ -139,6 +139,12 @@ class OtlpFileExporterTestPeer : public ::testing::Test
139139
auto check_json_text = output.str();
140140
if (!check_json_text.empty())
141141
{
142+
// If the exporting is splited to two standalone resource_span, just checking the first one.
143+
std::string::size_type eol = check_json_text.find('\n');
144+
if (eol != std::string::npos)
145+
{
146+
check_json_text = check_json_text.substr(0, eol);
147+
}
142148
auto check_json = nlohmann::json::parse(check_json_text, nullptr, false);
143149
if (!check_json.is_discarded())
144150
{

sdk/src/common/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ target_link_libraries(
1818
opentelemetry_common PUBLIC opentelemetry_api opentelemetry_sdk
1919
Threads::Threads)
2020

21-
if(WITH_ABSEIL OR WITH_OTLP_GRPC)
21+
if(WITH_OTLP_GRPC)
2222
target_link_libraries(opentelemetry_common PUBLIC absl::strings)
2323
endif()
2424

0 commit comments

Comments
 (0)