Skip to content

Commit 2b3d5e9

Browse files
committed
Resolve compilation issue with Abseil namespaced struct definition coming before no-namespace definition
1 parent e7a749a commit 2b3d5e9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

examples/otlp/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,18 @@ default. This can be changed with first argument from command-line, for example:
4949
Once you have the Collector running, see
5050
[CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and
5151
running the example.
52+
53+
## Additional notes regarding Abseil library
54+
55+
gRPC internally uses a different version of Abseil than OpenTelemetry C++ SDK.
56+
57+
One option to optimize your code is to build the SDK with system-provided
58+
Abseil library. If you are using CMake, then `-DWITH_ABSEIL=ON` may be passed
59+
during the build of SDK to reuse the same Abseil library as gRPC.
60+
61+
If you do not want to pursue the above option, and in case if you run into
62+
conflict between Abseil library and OpenTelemetry C++ `absl::variant`
63+
implementation, please include either `grpcpp/grpcpp.h` or
64+
`opentelemetry/exporters/otlp/otlp_grpc_exporter.h` BEFORE any other API
65+
headers. This approach efficiently avoids the conflict between the two different
66+
versions of Abseil.

examples/otlp/grpc_main.cc

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
// Make sure to include GRPC exporter first because otherwise Abseil may create
5+
// ambiguity with `nostd::variant`. See issue:
6+
// https://github.com/open-telemetry/opentelemetry-cpp/issues/880
47
#include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h"
58
#include "opentelemetry/sdk/trace/simple_processor.h"
69
#include "opentelemetry/sdk/trace/tracer_provider.h"

0 commit comments

Comments
 (0)