opentelemetry-cpp-contrib icon indicating copy to clipboard operation
opentelemetry-cpp-contrib copied to clipboard

Error loading module in Nginx

Open FullStackIndie opened this issue 3 years ago • 3 comments

Describe your environment I am running Ubuntu 20.04 LTS Stable and I downloaded the latest stable release of OpenTelemetry nginx module from the Github Actions artificats section.

I am using "nginx:latest" in docker container. I am running "otel/opentelemetry-collector:latest" as well in docker container and both are started with Docker compose. All config files here https://gist.github.com/FullStackIndie/d3fd2234e34348226b696758ba7bdbba

Steps to reproduce I use my docker compose up -d and my webserver(Nginx) crashes almost instantly with the error below.

What is the expected behavior? I expect Nginx to load the open telemtry module for nginx properly so I can start tracing requests.

What is the actual behavior? I keep getting an error everytime I nginx tries to laod the Module for open telemetry.

2022/02/22 06:03:46 [emerg] 1#1: dlopen() "/etc/nginx/modules/otel_ngx_module.so" failed (/etc/nginx/modules/otel_ngx_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:1

nginx: [emerg] dlopen() "/etc/nginx/modules/otel_ngx_module.so" failed (/etc/nginx/modules/otel_ngx_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:1**

Any help is greatly appreciated, thanks!!!

FullStackIndie avatar Feb 22 '22 06:02 FullStackIndie

Same issue here!

nicolastakashi avatar Mar 02 '22 22:03 nicolastakashi

I think the problem is, that the module is built with PCRE support, while the nginx in the image isn't.

tobiasstadler avatar Mar 16 '22 11:03 tobiasstadler

Looks like my Docker container running Nginx doesn't come with the with-pcre-jit configuration parameter. When running Nginx on host server, instead of Docker container, it does come with PCRE support built in so I will try that later. thanks for the help!!! @tobiasstadler

Update OpenTelemetry works fine with Nginx-Full on Ubuntu 20.04.4 LTS using 'sudo apt install nginx-full'. It doesn't work with most Docker Images because like Tobias mentioned they dont come with PCRE(basically Perl) support. You should be able to solve this by using the any nginx docker container with the "1.nginx.version-perl" syntax. But make sure when you cli into a conteiner 'docker exec -it nginx bash' and you use nginx -V to see what is nginx is compiled with. I dont know how to compile nginx docker images so i couldnt get it to work but what I think you need (no promises) when pressing nginx -V is ... --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit

this library requires ngx_http_upstream_module (proxy_pass) ngx_http_fastcgi_module (fastcgi_pass) and --with-compat from my understanding allows the loading of dynamic modules(i could be wrong) and --with-pcre-jit from my understanding loads the PCRE/per module to be able to parse/regex strings(i could be wrong) I hope this update helps someone until nginx has full support and easy integration for open telemetry

** Update 2/23/2023 **

Disclaimer ( I don't know nginx or linux that well, I just have done alot of research over the last year or so)

I never got it working with docker but I got it working with nginx 1.18 stable (didnt work with Nginx 1.19 mainline for some reason) and also since I asked this question the Nginx open telemetry contrib module is technically deprecated in favor of Nginx 1.22-1.23

(find out more here https://github.com/open-telemetry/opentelemetry-cpp-contrib/tree/main/instrumentation/otel-webserver-module#platform-supported-1)


I have a notion page that describes more or less how to compile Nginx 1.18 from scratch (subject to updates/deprecation) and will now close this issue. If you want to check out the Notion page click the link below. Feel free to comment on the page if you need more clarification.

https://fullstackindie.notion.site/Compile-Nginx-from-Source-95e9a5575c884dc7a74816d861eda97a

FullStackIndie avatar Mar 21 '22 14:03 FullStackIndie