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

OTEL_CPP_GET_ATTR macro should fully qualify its usage of attr #1139

Closed
lidavidm opened this issue Dec 14, 2021 · 0 comments · Fixed by #1140
Closed

OTEL_CPP_GET_ATTR macro should fully qualify its usage of attr #1139

lidavidm opened this issue Dec 14, 2021 · 0 comments · Fixed by #1140
Assignees
Labels
bug Something isn't working

Comments

@lidavidm
Copy link
Contributor

Describe your environment

Platform: Linux
OpenTelemetry version: v1.1.0
Build system: CMake
Compiler:

> g++ --version
g++ (GCC) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Steps to reproduce

Compile this snippet:

#include <opentelemetry/sdk/resource/experimental_semantic_conventions.h>

#include <iostream>

int main(int, char**) {
  std::cout << OTEL_CPP_GET_ATTR(AttrServiceName) << std::endl;
  return 0;
}
$ g++ -I$CONDA_PREFIX/include test.cc -o test

What is the expected behavior?
The snippet should compile.

What is the actual behavior?
The snippet fails to compile:

> g++ -I$CONDA_PREFIX/include test.cc -o test 
In file included from test.cc:1:
test.cc: In function 'int main(int, char**)':
~/miniconda3/envs/astronaut-cpp/include/opentelemetry/sdk/resource/experimental_semantic_conventions.h:24:33: error: 'attr' was not declared in this scope
   24 | #define OTEL_CPP_GET_ATTR(name) attr(OTEL_CPP_CONST_HASHCODE(name))
      |                                 ^~~~
test.cc:6:16: note: in expansion of macro 'OTEL_CPP_GET_ATTR'
    6 |   std::cout << OTEL_CPP_GET_ATTR(AttrServiceName) << std::endl;
      |                ^~~~~~~~~~~~~~~~~

Additional context

The use of the attr helper should be fully qualified here, so it can be used even when not inside an OpenTelemetry namespace or without having to add using opentelemetry::sdk::resource::attr;.

#define OTEL_CPP_GET_ATTR(name) attr(OTEL_CPP_CONST_HASHCODE(name))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants