Skip to content

Commit e843642

Browse files
committed
remove abseil as a public dependency. update install notes on how to install abseil, protobuf, and grpc so the transitive abseil depenedency is found implicitly
1 parent 594d158 commit e843642

File tree

12 files changed

+14
-117
lines changed

12 files changed

+14
-117
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,6 @@ jobs:
302302
run: |
303303
./ci/do_ci.sh cmake.with_async_export.test
304304
305-
# cmake_abseil_stl_test:
306-
# name: CMake test (with abseil)
307-
# runs-on: ubuntu-20.04
308-
# steps:
309-
# - uses: actions/checkout@v4
310-
# with:
311-
# submodules: 'recursive'
312-
# - name: setup
313-
# run: |
314-
315-
# sudo -E ./ci/setup_ci_environment.sh
316-
# sudo -E ./ci/setup_cmake.sh
317-
# sudo -E ./ci/setup_googletest.sh
318-
# - name: run cmake tests (enable abseil-cpp)
319-
# run: |
320-
# sudo ./ci/install_abseil.sh
321-
# ./ci/do_ci.sh cmake.abseil.test
322-
323305
cmake_opentracing_shim_test:
324306
name: CMake test (with opentracing-shim)
325307
runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,6 @@ if(WITH_PROMETHEUS)
415415
endif()
416416
endif()
417417

418-
if(WITH_OTLP_GRPC)
419-
find_package(absl CONFIG REQUIRED)
420-
endif()
421-
422418
if(WITH_OTLP_GRPC
423419
OR WITH_OTLP_HTTP
424420
OR WITH_OTLP_FILE)
@@ -738,7 +734,6 @@ message(STATUS "OTELCPP_VERSIONED_LIBS: ${OTELCPP_VERSIONED_LIBS}")
738734
message(STATUS "OTELCPP_MAINTAINER_MODE: ${OTELCPP_MAINTAINER_MODE}")
739735
message(STATUS "WITH_STL: ${WITH_STL}")
740736
message(STATUS "WITH_GSL: ${WITH_GSL}")
741-
message(STATUS "WITH_ABSEIL: ${WITH_ABSEIL}")
742737
message(STATUS "WITH_NO_GETENV: ${WITH_NO_GETENV}")
743738

744739
message(STATUS "---------------------------------------------")

INSTALL.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,20 @@ You can link OpenTelemetry C++ SDK with libraries provided in
3838
[GoogleBenchmark Build
3939
Instructions](https://github.com/google/benchmark#installation).
4040
- Apart from above core requirements, the Exporters and Propagators have their
41-
build dependencies which are not covered here. E.g, the OTLP Exporter needs
42-
grpc/protobuf library, the Zipkin exporter needs nlohmann-json and libcurl,
43-
the ETW exporter needs nlohmann-json to build. This is covered in the build
44-
instructions for each of these components.
41+
build dependencies.
42+
43+
### Building dependencies for the OTLP exporters
44+
45+
The opentelemetry-cpp OTLP exporters depend on Protobuf and gRPC (in the case of the otlp grpc exporters). Protobuf (since version 3.22.0) and gRPC depend on Abseil.
46+
For cmake builds, it is best practice to build and install Abseil, Protobuf, and gPRC as independent packages - configuring cmake for Protobuf and gRPC to build against the installed packages instead of using their submodule option.
47+
48+
If building and installing Protobuf and gRPC manually with cmake the recommended approach is:
49+
1. Choose the desired tag version of grpc. Find the compatible versions of abseil and protobuf by inspecting the submodules of grpc at that tag.
50+
2. Build and install the required version of abseil
51+
3. Build and install the required version of protobuf
52+
- Set the cmake option of Protobuf to build against the installed package of Abseil (`protobuf_ABSL_PROVIDER=package`)
53+
4. Build and install the required version of grpc
54+
- Set the cmake option of grpc to build against the installed packages of Abseil and Protobuf (cmake options - `gRPC_ABSL_PROVIDER=package` and `gRPC_PROTOBUF_PROVIDER=package`)
4555

4656
### Building as standalone CMake Project
4757

ci/do_ci.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ switch ($action) {
373373
"-DCMAKE_INSTALL_PREFIX=$INSTALL_TEST_DIR" `
374374
-DWITH_ABI_VERSION_1=OFF `
375375
-DWITH_ABI_VERSION_2=ON `
376-
-DWITH_ABSEIL=OFF `
377376
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON `
378377
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON `
379378
-DWITH_ASYNC_EXPORT_PREVIEW=ON `
@@ -473,7 +472,6 @@ switch ($action) {
473472
-DOPENTELEMETRY_BUILD_DLL=1 `
474473
-DWITH_ABI_VERSION_1=ON `
475474
-DWITH_ABI_VERSION_2=OFF `
476-
-DWITH_ABSEIL=OFF `
477475
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON `
478476
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON `
479477
-DWITH_ASYNC_EXPORT_PREVIEW=ON `

ci/do_ci.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,6 @@ elif [[ "$1" == "cmake.with_async_export.test" ]]; then
232232
make -j $(nproc)
233233
make test
234234
exit 0
235-
elif [[ "$1" == "cmake.abseil.test" ]]; then
236-
cd "${BUILD_DIR}"
237-
rm -rf *
238-
cmake "${CMAKE_OPTIONS[@]}" \
239-
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
240-
-DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS" \
241-
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
242-
-DWITH_ABSEIL=ON \
243-
"${SRC_DIR}"
244-
make -j $(nproc)
245-
make test
246-
exit 0
247235
elif [[ "$1" == "cmake.opentracing_shim.test" ]]; then
248236
cd "${BUILD_DIR}"
249237
rm -rf *
@@ -387,9 +375,6 @@ elif [[ "$1" == "cmake.legacy.exporter.otprotocol.test" ]]; then
387375
elif [[ "$1" == "cmake.exporter.otprotocol.test" ]]; then
388376
cd "${BUILD_DIR}"
389377
rm -rf *
390-
if [[ ! -z "${WITH_ABSEIL}" ]]; then
391-
CMAKE_OPTIONS=(${CMAKE_OPTIONS[@]} "-DWITH_ABSEIL=${WITH_ABSEIL}")
392-
fi
393378
cmake "${CMAKE_OPTIONS[@]}" \
394379
-DWITH_OTLP_GRPC=ON \
395380
-DWITH_OTLP_HTTP=ON \
@@ -477,7 +462,6 @@ elif [[ "$1" == "cmake.install.test" ]]; then
477462
-DCMAKE_INSTALL_PREFIX=${INSTALL_TEST_DIR} \
478463
-DWITH_ABI_VERSION_1=OFF \
479464
-DWITH_ABI_VERSION_2=ON \
480-
-DWITH_ABSEIL=OFF \
481465
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON \
482466
-DWITH_ASYNC_EXPORT_PREVIEW=ON \
483467
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \

cmake/opentelemetry-proto.cmake

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,6 @@ set_target_version(opentelemetry_proto)
318318
# Disable include-what-you-use on generated code.
319319
set_target_properties(opentelemetry_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE
320320
"")
321-
322-
if(TARGET absl::bad_variant_access)
323-
target_link_libraries(opentelemetry_proto PUBLIC absl::bad_variant_access)
324-
endif()
325-
326321
if(NOT Protobuf_INCLUDE_DIRS AND TARGET protobuf::libprotobuf)
327322
get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
328323
INTERFACE_INCLUDE_DIRECTORIES)
@@ -402,13 +397,6 @@ else() # cmake 3.8 or lower
402397
target_link_libraries(opentelemetry_proto PUBLIC ${Protobuf_LIBRARIES})
403398
endif()
404399

405-
if(WITH_OTLP_GRPC)
406-
if(TARGET absl::synchronization)
407-
target_link_libraries(opentelemetry_proto_grpc
408-
PRIVATE absl::synchronization)
409-
endif()
410-
endif()
411-
412400
if(BUILD_SHARED_LIBS)
413401
foreach(proto_target ${OPENTELEMETRY_PROTO_TARGETS})
414402
set_property(TARGET ${proto_target} PROPERTY POSITION_INDEPENDENT_CODE ON)

cmake/templates/thirdparty-built-with-flags.cmake.in

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
# Initialize dependency expected flags
1212
set(BUILT_WITH_Threads TRUE)
13-
set(BUILT_WITH_absl FALSE)
1413
set(BUILT_WITH_CURL FALSE)
1514
set(BUILT_WITH_ZLIB FALSE)
1615
set(BUILT_WITH_nlohmann_json FALSE)
@@ -19,17 +18,6 @@ set(BUILT_WITH_gRPC FALSE)
1918
set(BUILT_WITH_prometheus-cpp FALSE)
2019
set(BUILT_WITH_OpenTracing FALSE)
2120

22-
# absl:
23-
if(@WITH_ABSEIL@)
24-
set(BUILT_WITH_absl TRUE)
25-
elseif(@WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@ OR @WITH_OTLP_GRPC@)
26-
if( @WITH_OTLP_GRPC@ )
27-
set(BUILT_WITH_absl TRUE)
28-
elseif(@Protobuf_VERSION@ VERSION_GREATER_EQUAL 3.22.0)
29-
set(BUILT_WITH_absl TRUE)
30-
endif()
31-
endif()
32-
3321
# CURL and ZLIB:
3422
if(@WITH_HTTP_CLIENT_CURL@)
3523
if("@CURL_FOUND@")
@@ -69,10 +57,6 @@ endif()
6957
#-----------------------------------------------------------------------
7058
# Third party dependency versions
7159
#-----------------------------------------------------------------------
72-
if(BUILT_WITH_absl)
73-
set(BUILT_WITH_absl_VERSION @absl_VERSION@)
74-
endif()
75-
7660
if(BUILT_WITH_CURL)
7761
set(BUILT_WITH_CURL_VERSION @CURL_VERSION_STRING@)
7862
endif()
@@ -104,7 +88,6 @@ endif()
10488
#-----------------------------------------------------------------------
10589
# Flags to determine if CONFIG search mode should be used in find_dependency(...)
10690
#-----------------------------------------------------------------------
107-
set(FIND_DEPENDENCY_absl_USE_CONFIG TRUE)
10891
set(FIND_DEPENDENCY_Threads_USE_CONFIG FALSE)
10992
set(FIND_DEPENDENCY_ZLIB_USE_CONFIG FALSE)
11093
set(FIND_DEPENDENCY_CURL_USE_CONFIG FALSE)

cmake/thirdparty-dependency-definitions.cmake

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# Dependencies will be found in this order when find_package(opentelemetry-cpp ...) is called.
77
#-----------------------------------------------------------------------
88
set(THIRD_PARTY_DEPENDENCIES_SUPPORTED
9-
absl
109
Threads
1110
ZLIB
1211
CURL
@@ -22,14 +21,6 @@ set(THIRD_PARTY_DEPENDENCIES_SUPPORTED
2221
# These are the components that may require the third party dependency
2322
#-----------------------------------------------------------------------
2423

25-
# Components that may require absl
26-
set(THIRD_PARTY_absl_DEPENDENT_COMPONENTS
27-
api
28-
sdk
29-
exporters_otlp_common
30-
exporters_otlp_grpc
31-
)
32-
3324
# Components that require Threads
3425
set(THIRD_PARTY_Threads_DEPENDENT_COMPONENTS
3526
sdk
@@ -55,9 +46,6 @@ set(THIRD_PARTY_nlohmann_json_DEPENDENT_COMPONENTS
5546
# Components that require Protobuf
5647
set(THIRD_PARTY_Protobuf_DEPENDENT_COMPONENTS
5748
exporters_otlp_common
58-
exporters_otlp_file
59-
exporters_otlp_http
60-
exporters_otlp_grpc
6149
)
6250

6351
# Components that require gRPC

examples/grpc/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ else()
4242
target_link_libraries(example_grpc_proto PUBLIC gRPC::grpc++
4343
${Protobuf_LIBRARIES})
4444
endif()
45-
if(WITH_OTLP_GRPC)
46-
target_link_libraries(example_grpc_proto PUBLIC absl::bad_variant_access)
47-
endif()
4845

4946
foreach(_target client server)
5047
add_executable(${_target} "${_target}.cc")

examples/otlp/README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,3 @@ Once you have the Collector running, see
6767
[CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and
6868
running the example.
6969

70-
## Additional notes regarding Abseil library
71-
72-
gRPC internally uses a different version of Abseil than OpenTelemetry C++ SDK.
73-
74-
One option to optimize your code is to build the SDK with system-provided
75-
Abseil library. If you are using CMake, then `-DWITH_ABSEIL=ON` may be passed
76-
during the build of SDK to reuse the same Abseil library as gRPC. If you are
77-
using Bazel, then `--@io_opentelemetry_cpp/api:with_abseil=true` may be passed
78-
to reuse your Abseil library in your project.
79-
80-
If you do not want to pursue the above option, and in case if you run into
81-
conflict between Abseil library and OpenTelemetry C++ `absl::variant`
82-
implementation, please include either `grpcpp/grpcpp.h` or
83-
`opentelemetry/exporters/otlp/otlp_grpc_exporter.h` BEFORE any other API
84-
headers. This approach efficiently avoids the conflict between the two different
85-
versions of Abseil.

0 commit comments

Comments
 (0)