nginxinc / nginx-otel

Apache License 2.0
168 stars 19 forks source link

How to build the nginx-otel-module using configure with add-dynamic-module #49

Open royteeuwen opened 7 months ago

royteeuwen commented 7 months ago

Describe the bug

We build NGINX from source code and add nginx-otel as dynamic module, but the following error is thrown:

adding module in /tmp/nginx/nginx-otel
-- The C compiler identification is GNU 8.5.0
-- The CXX compiler identification is GNU 8.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:64 (find_package):
  By not providing "Findopentelemetry-cpp.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "opentelemetry-cpp", but CMake did not find one.

  Could not find a package configuration file provided by "opentelemetry-cpp"
  with any of the following names:

    opentelemetry-cppConfig.cmake
    opentelemetry-cpp-config.cmake

  Add the installation prefix of "opentelemetry-cpp" to CMAKE_PREFIX_PATH or
  set "opentelemetry-cpp_DIR" to a directory containing one of the above
  files.  If "opentelemetry-cpp" provides a separate development package or
  SDK, be sure it has been installed.

I don't find it anywhere in the docs that another library should be required to build the module?

The commands we are executing:

# Download Nginx source
wget -nv https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -O nginx.tar.gz
tar -xzf nginx.tar.gz && mv -f nginx-$NGINX_VERSION nginx

# Download nginx-otel
wget -nv https://github.com/nginxinc/nginx-otel/archive/refs/tags/v$NGINX_OTEL_VERSION.tar.gz -O nginx-otel.tar.gz
mkdir nginx-otel
tar -xzf nginx-otel.tar.gz -C nginx-otel --strip-components 1

cd nginx
# Process configuration to compile Nginx, based on parameters from RHEL:8 nginx version
# (using nginx -V, which returns the arguments for ./configure).
./configure --prefix=/etc/nginx \
    --sbin-path=/usr/local/sbin/nginx \
    --modules-path=modules \
    --conf-path=/etc/nginx/conf/nginx.conf \
    --error-log-path=/dev/stderr \
    --http-log-path=/dev/stdout \
    --http-client-body-temp-path=/var/tmp/nginx/client_body \
    --http-proxy-temp-path=/var/tmp/nginx/proxy \
    --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
    --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
    --http-scgi-temp-path=/var/tmp/nginx/scgi \
    --pid-path=/var/run/nginx/nginx.pid \
    --lock-path=/var/run/nginx/nginx.lock \
    --user=nginx \
    --group=nginx \
    --with-file-aio \
    --with-ipv6 \
    --with-http_ssl_module \
    --with-http_v2_module \
    --with-http_auth_request_module \
    --with-http_realip_module \
    --with-stream_ssl_preread_module \
    --with-http_addition_module \
    --with-http_xslt_module=dynamic \
    --with-http_image_filter_module=dynamic \
    --with-http_sub_module \
    --with-http_dav_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_random_index_module \
    --with-http_secure_link_module \
    --with-http_degradation_module \
    --with-http_slice_module \
    --with-http_stub_status_module \
    --with-http_perl_module=dynamic \
    --with-http_stub_status_module \
    --with-mail=dynamic \
    --with-mail_ssl_module \
    --with-pcre= \
    --with-pcre-jit \
    --with-stream=dynamic \
    --with-stream_ssl_module \
    --with-debug \
    --with-cc-opt="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic" \
    --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E" \
    --with-pcre="${cwd}/pcre2" \
    --with-pcre-opt="-fPIC" \
    --with-zlib="${cwd}/zlib" \
    --with-zlib-opt="-fPIC" \
    --with-openssl="${cwd}/openssl" \
    --with-openssl-opt="enable-ec_nistp_64_gcc_128 enable-tls1_3 no-ssl2 no-ssl3 no-weak-ssl-ciphers -DOPENSSL_NO_HEARTBEATS" \
    --add-dynamic-module="${cwd}/ngx_brotli" \
    --add-dynamic-module="${cwd}/ngx_devel_kit" \
    --add-dynamic-module="${cwd}/set-misc-nginx-module" \
    --add-dynamic-module="${cwd}/nginx-otel"

# Prepared, so make the puppy
make && make install
mtbChef commented 7 months ago

Hello, the nginx-otel module does have some 3rd-party dependencies and needs to be compiled separately using cmake, as described in the README.

royteeuwen commented 7 months ago

The readme doesnt mention any package related to those opentelemetry mentioned? Or am I reading over it?

mtbChef commented 7 months ago

The dependencies are on 3rd-party opentelemetry code. They're pulled and compiled into the module during the build process. Here's the particular example you're referring to:

https://github.com/nginxinc/nginx-otel/blob/main/CMakeLists.txt#L37

thresheek commented 7 months ago

...And if you follow a typical nginx-style build process, you probably to do something similar to https://hg.nginx.org/pkg-oss/file/26ae41eb0f32/rpm/SPECS/Makefile.module-otel to ship and build the prerequisites before building an actual module.