Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'SpanContext' is not a member of 'opentelemetry::v1::sdk::trace' #2417

Closed
qinyeli opened this issue Nov 29, 2023 · 1 comment · Fixed by #2422 or #2424
Closed

'SpanContext' is not a member of 'opentelemetry::v1::sdk::trace' #2417

qinyeli opened this issue Nov 29, 2023 · 1 comment · Fixed by #2422 or #2424
Assignees
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@qinyeli
Copy link

qinyeli commented Nov 29, 2023

I am trying to add the OpenTelemetry SDK as a dependency into our project, and I am consistently hitting this compile issue.

Describe your environment Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch.

  • CentOS in Parallel 18
  • The latest release opentelemetry-cpp-1.12.0.tar.gz downloaded

Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.

When I include certain dependencies from metrics SDK, for example any of the following

#include <opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h>
#include <opentelemetry/sdk/metrics/meter.h>
#include <opentelemetry/sdk/metrics/meter_provider.h>
#include <opentelemetry/sdk/metrics/meter_provider_factory.h>

and compile with either Bazel or CMake, I get compile error.

My Makefile:

build: download-src
	${MKDIR_P} build
	cd build && \
	${CMAKE} -DCMAKE_INSTALL_PREFIX=../installed \
		-DCMAKE_CXX_STANDARD=17 \
		-DWITH_STL=CXX17 \
		-DWITH_ABSEIL=ON \
		-Dabsl_ROOT=../../abseil/installed \
		-DBUILD_TESTING=OFF \
		../src

Bazel targets includes the following targets in the dependency

        "@io_opentelemetry_cpp//api",
        "@io_opentelemetry_cpp//exporters/ostream:ostream_metric_exporter",
        "@io_opentelemetry_cpp//exporters/ostream:ostream_span_exporter",
        "@io_opentelemetry_cpp//sdk:headers",
        "@io_opentelemetry_cpp//sdk/src/metrics",
        "@io_opentelemetry_cpp//sdk/src/trace",
        "@opentelemetry-protos//:otel_exporter_protos",

What is the expected behavior?
That it compiles.

What is the actual behavior?
What did you see instead?

bazel-out/aarch64-fastbuild/bin/external/io_opentelemetry_cpp/sdk/_virtual_includes/headers/opentelemetry/sdk/metrics/data/exemplar_data.h:29:53: error: 'SpanContext' is not a member of 'opentelemetry::v1::sdk::trace'
   29 |   static ExemplarData Create(std::shared_ptr<trace::SpanContext> context,
      |                                                     ^~~~~~~~~~~
bazel-out/aarch64-fastbuild/bin/external/io_opentelemetry_cpp/sdk/_virtual_includes/headers/opentelemetry/sdk/metrics/data/exemplar_data.h:29:64: error: template argument 1 is invalid
   29 |   static ExemplarData Create(std::shared_ptr<trace::SpanContext> context,
      |                                                                ^
bazel-out/aarch64-fastbuild/bin/external/io_opentelemetry_cpp/sdk/_virtual_includes/headers/opentelemetry/sdk/metrics/data/exemplar_data.h:50:16: error: 'SpanContext' in namespace 'opentelemetry::v1::sdk::trace' does not name a type
   50 |   const trace::SpanContext &GetSpanContext() const noexcept { return context_; }

Additional context

Compiling with these header files would work properly

#include <opentelemetry/exporters/ostream/metric_exporter_factory.h>
#include <opentelemetry/exporters/ostream/span_exporter_factory.h>
#include <opentelemetry/metrics/provider.h>
#include <opentelemetry/sdk/metrics/aggregation/default_aggregation.h>
#include <opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h>
#include <opentelemetry/sdk/metrics/push_metric_exporter.h>
#include <opentelemetry/sdk/metrics/view/instrument_selector_factory.h>
#include <opentelemetry/sdk/metrics/view/meter_selector_factory.h>
#include <opentelemetry/sdk/metrics/view/view_factory.h>
#include <opentelemetry/sdk/trace/exporter.h>
#include <opentelemetry/sdk/trace/processor.h>
#include <opentelemetry/sdk/trace/simple_processor_factory.h>
#include <opentelemetry/sdk/trace/tracer_provider_factory.h>
#include <opentelemetry/trace/provider.h>
#include <opentelemetry/trace/span_context.h>

I can even compile with a declaration of SpanContext

   std::shared_ptr<opentelemetry::v1::trace::SpanContext> context;

I have been wrestling with it for a while and I'd appreciate some help.

@qinyeli qinyeli added the bug Something isn't working label Nov 29, 2023
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 29, 2023
@sfc-gh-sgiesecke
Copy link

This seems to be a bug in several opentelemetry/sdk headers which fail to use fully qualified namespaces when referencing opentelemetry::trace::SpanContext.

@marcalff marcalff self-assigned this Nov 29, 2023
@ThomsonTan ThomsonTan added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Nov 29, 2023
@marcalff marcalff removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
4 participants