open-telemetry / opentelemetry-cpp-contrib

https://opentelemetry.io/
Apache License 2.0
125 stars 138 forks source link

otel_ngx_module.cpp:1:10: fatal error: opentelemetry/sdk/trace/processor.h: No such file or directory #146

Open zx8086 opened 2 years ago

zx8086 commented 2 years ago

Describe your environment

nginx 1.20.2 Raspberry Pi 4 Bullseye Linux 5.15.33-v8+ #1540 SMP PREEMPT Mon Apr 11 13:18:30 BST 2022 aarch64 GNU/Linux

Steps to reproduce Ran ./configure --with-compat --add-dynamic-module=/home/pi/opentelemetry-cpp-contrib/instrumentation/nginx

Tail end of the log as below :

`configuring additional dynamic modules adding module in /home/pi/opentelemetry-cpp-contrib/instrumentation/nginx

Configuration summary

After ran the following:

make modules

What is the expected behavior?

Expected to see the module created

What is the actual behavior?

make -f objs/Makefile modules make[1]: Entering directory '/home/pi/nginx-1.20.2' cc -c -fPIC -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/addon/src/agent_config.o \ /home/pi/opentelemetry-cpp-contrib/instrumentation/nginx/src/agent_config.cpp cc -c -fPIC -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/addon/src/nginx_config.o \ /home/pi/opentelemetry-cpp-contrib/instrumentation/nginx/src/nginx_config.cpp cc -c -fPIC -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \ -o objs/addon/src/otel_ngx_module.o \ /home/pi/opentelemetry-cpp-contrib/instrumentation/nginx/src/otel_ngx_module.cpp /home/pi/opentelemetry-cpp-contrib/instrumentation/nginx/src/otel_ngx_module.cpp:1:10: fatal error: opentelemetry/sdk/trace/processor.h: No such file or directory 1 | #include <opentelemetry/sdk/trace/processor.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make[1]: *** [objs/Makefile:1246: objs/addon/src/otel_ngx_module.o] Error 1 make[1]: Leaving directory '/home/pi/nginx-1.20.2' make: *** [Makefile:16: modules] Error 2

Additional context Add any other context about the problem here.

owent commented 2 years ago

I think you should build opentelemetry-cpp first and add the include directories and libraries by CFLAGS and LDFLAGS if you use configure but not the cmake build system in our repository.

zx8086 commented 2 years ago

opentelemetry-cpp

Any steps / instructions on this ?

rcjsuen commented 2 years ago

opentelemetry-cpp

Any steps / instructions on this ?

Perhaps this document may be of use to you.

zx8086 commented 2 years ago

@rcjsuen @owent Step 5 & Incorporating into an existing CMake Project, is where i am getting stuck... where and what parameters needed to ensure the headers are installed in the right place to otel_ngx_module.cpp to pick up all the headers created via the opentelemetry-cpp instructions, which i completed without issues.

owent commented 2 years ago

@rcjsuen @owent Step 5 & Incorporating into an existing CMake Project, is where i am getting stuck... where and what parameters needed to ensure the headers are installed in the right place to otel_ngx_module.cpp to pick up all the headers created via the opentelemetry-cpp instructions, which i completed without issues.

You should add <install_root> of opentelemetry-cpp to cmake search path when building otel_ngx_module. For example:

cd <where to build opentelemetry>
cmake --install . --prefix /opt/opentelemetry-cpp

cd <where to build otel_ngx_module>
cmake <the directory contains CMakeLists.txt of otel_ngx_module> -Dopentelemetry-cpp_ROOT=/opt/opentelemetry-cpp
# or using -DCMAKE_PREFIX_PATH=/opt/opentelemetry-cpp to replace -Dopentelemetry-cpp_ROOT=/opt/opentelemetry-cpp when using cmake 3.11 or lower
cmake --build . -j

See https://cmake.org/cmake/help/latest/command/find_package.html for details.