Skip to content

Commit

Permalink
Resolve compilation issue with Abseil namespaced struct definition co…
Browse files Browse the repository at this point in the history
…ming before no-namespace definition
  • Loading branch information
maxgolov committed Jun 29, 2021
1 parent e7a749a commit 2b3d5e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,18 @@ default. This can be changed with first argument from command-line, for example:
Once you have the Collector running, see
[CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and
running the example.

## Additional notes regarding Abseil library

gRPC internally uses a different version of Abseil than OpenTelemetry C++ SDK.

One option to optimize your code is to build the SDK with system-provided
Abseil library. If you are using CMake, then `-DWITH_ABSEIL=ON` may be passed
during the build of SDK to reuse the same Abseil library as gRPC.

If you do not want to pursue the above option, and in case if you run into
conflict between Abseil library and OpenTelemetry C++ `absl::variant`
implementation, please include either `grpcpp/grpcpp.h` or
`opentelemetry/exporters/otlp/otlp_grpc_exporter.h` BEFORE any other API
headers. This approach efficiently avoids the conflict between the two different
versions of Abseil.
3 changes: 3 additions & 0 deletions examples/otlp/grpc_main.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

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

0 comments on commit 2b3d5e9

Please sign in to comment.