Skip to content

[BUILD] Old style cast warnings in opentelemetry_api headers #2556

@shiponcs

Description

@shiponcs

Title: Attempt to use opentelemetry_api headers cause envoy build fails

Description:

I need a help regarding using opentelemetry_api in envoy project. The otel api was added in Envoy in this commit.
/source/extensions/tracers/opentelemetry has opentelemetry_api as external_deps, in opentelemetry_tracer_impl.h file I have included a otel header file as:

#include "opentelemetry/logs/provider.h"

I used to build envoy with docker-clang option, but this time it fails:

$ bazel build envoy --config=docker-clang
INFO: Analyzed target //:envoy (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
INFO: Docker sandboxing is supported
ERROR: /home/matin/envoy-build/envoy/source/extensions/tracers/opentelemetry/BUILD:14:19: Compiling source/extensions/tracers/opentelemetry/config.cc failed: (Exit 1): clang-14 failed: error executing command (from target //source/extensions/tracers/opentelemetry:config) /opt/llvm/bin/clang-14 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++0x' ... (remaining 246 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from source/extensions/tracers/opentelemetry/config.cc:8:
In file included from ./source/extensions/tracers/opentelemetry/opentelemetry_tracer_impl.h:16:
In file included from bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/trace/provider.h:11:
In file included from bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/trace/noop.h:16:
In file included from bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/trace/span.h:13:
bazel-out/k8-fastbuild/bin/external/io_opentelemetry_cpp/api/_virtual_includes/api/opentelemetry/trace/span_context.h:33:40: error: use of old-style cast [-Werror,-Wold-style-cast]
        trace_flags_(trace::TraceFlags((uint8_t)sampled_flag)),
                                       ^        ~~~~~~~~~~~~
1 error generated.
Target //source/exe:envoy-static failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 15.400s, Critical Path: 14.38s
INFO: 4 processes: 4 internal.
FAILED: Build did NOT complete successfully

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions