Skip to content

Cloud Foundry buildpack that provides NGINX with OpenTelemetry support

License

Notifications You must be signed in to change notification settings

springernature/nginx-opentelemetry-buildpack

 
 

Repository files navigation

Cloud Foundry NGINX Buildpack

CF Slack Join us on Slack

A Cloud Foundry buildpack for apps requiring NGINX.

Open-telemetry fork

This fork adds the OpenTelemetry nginx plugin.

The libraries are built on an Ubuntu 22.04 VM (after apt-get update && apt-get upgrade to sync to latest libraries):

sudo apt install cmake build-essential autoconf libtool libpcre++-dev libssl-dev zlib1g-dev clang libcurl4-openssl-dev nlohmann-json3-dev nginx git

git clone https://github.com/open-telemetry/opentelemetry-cpp-contrib.git -b webserver/v1.0.3
git clone --shallow-submodules --depth 1 --recurse-submodules -b v1.49.2 https://github.com/grpc/grpc
git clone --shallow-submodules --depth 1 --recurse-submodules -b v1.8.1 https://github.com/open-telemetry/opentelemetry-cpp.git

cd grpc/
mkdir -p cmake/build
cd cmake/build/
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF -DCMAKE_CXX_STANDARD=17 ../..
make -j 8
sudo make install
cd ~/

cd opentelemetry-cpp
mkdir build 
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_OTLP=ON  -DWITH_OTLP_GRPC=ON  -DWITH_OTLP_HTTP=OFF  -DBUILD_TESTING=OFF  -DWITH_EXAMPLES=OFF  -DCMAKE_CXX_STANDARD=17  -DCMAKE_POSITION_INDEPENDENT_CODE=ON  -DWITH_ABSEIL=ON ..
make -j 8
sudo make install
cd ~/

cd opentelemetry-cpp-contrib/instrumentation/nginx/
mkdir build
cd build/
cmake -DNGINX_VERSION=1.21.4 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/share/nginx/modules  -DCMAKE_CXX_STANDARD=17 ..
make -j 8
sudo make install

# The "otel_ngx_module.so" is now in the current (build) directory

strip otel_ngx_module.so # the binary is massive (optional)
tar czf otel_ngx_module_nginx1.21.4_5c0cc9c8.tar.gz otel_ngx_module.so
cd ..

# It should be tar-gzipped and copied into the dist folder in the buildpack. The manifest should be updated accordingly

Buildpack User Documentation

Official buildpack documentation can be found at here.

To use this buildpack, you will need to include an nginx.conf file in your app. Here's an example.

Building the Buildpack

To build this buildpack, run the following command from the buildpack's directory:

  1. Source the .envrc file in the buildpack directory.

    source .envrc

    To simplify the process in the future, install direnv which will automatically source .envrc when you change directories.

  2. Install buildpack-packager

    ./scripts/install_tools.sh
  3. Build the buildpack

    buildpack-packager build [ -cached=(true|false) ] -any-stack
  4. Use in Cloud Foundry

    Upload the buildpack to your Cloud Foundry and optionally specify it by name

    cf create-buildpack [BUILDPACK_NAME] [BUILDPACK_ZIP_FILE_PATH] 1
    cf push my_app [-b BUILDPACK_NAME]

Testing

Buildpacks use the Cutlass framework for running integration tests.

To test this buildpack, run the following command from the buildpack's directory:

  1. Source the .envrc file in the buildpack directory.

    source .envrc

    To simplify the process in the future, install direnv which will automatically source .envrc when you change directories.

  2. Run unit tests

    ./scripts/unit.sh
  3. Run integration tests

    ./scripts/integration.sh

More information can be found on Github cutlass.

Contributing

Find our guidelines here.

Help and Support

Join the #buildpacks channel in our Slack community

Reporting Issues

Open an issue on this project

Active Development

The project backlog is on Pivotal Tracker

About

Cloud Foundry buildpack that provides NGINX with OpenTelemetry support

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • Go 77.3%
  • Shell 22.1%
  • HTML 0.6%