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

nginx: add test matrix, release builds #10

Merged
merged 41 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4af5fb8
cache grpc build, use different install location
seemk Mar 29, 2021
97f7e7d
attempt buildx
seemk Mar 29, 2021
759b052
fix buildx action path
seemk Mar 29, 2021
6cb5937
attempt at express backend context fix
seemk Mar 29, 2021
424b941
buildx paths
seemk Mar 29, 2021
07a20c6
docker build context
seemk Mar 29, 2021
cf32e01
push tags
seemk Mar 29, 2021
49098d9
use buildx explicitly
seemk Mar 29, 2021
3c998ce
release builds, load docker images
seemk Mar 29, 2021
eca0865
docker debug
seemk Mar 29, 2021
d6546cf
copy output artifacts
seemk Mar 29, 2021
8bbb745
update cache as a last step
seemk Mar 29, 2021
19c9f17
explicit target for docker export
seemk Mar 29, 2021
30f0006
use correct cache for artifacts
seemk Mar 29, 2021
57df3be
fix copy
seemk Mar 29, 2021
21f683c
fix copy location
seemk Mar 29, 2021
786dc9b
use scratch for artifacy copy
seemk Mar 29, 2021
87b9587
remove unused CI files, use system nginx
seemk Mar 29, 2021
69f78c6
add build matrix
seemk Mar 29, 2021
15083c1
fix matrix syntax
seemk Mar 29, 2021
d5a7d8a
fix cache key
seemk Mar 29, 2021
2996f74
add mainline build, remove unused ci files
seemk Mar 29, 2021
3d191b1
pin mainline prio
seemk Mar 29, 2021
a153b8f
shorten job name
seemk Mar 29, 2021
a80718e
fix artifacy copy
seemk Mar 29, 2021
07903aa
fix package override
seemk Mar 29, 2021
bcb258f
use mainline nginx
seemk Mar 29, 2021
6d0e720
bring your own fastcgi_params
seemk Mar 29, 2021
577c887
update layer cache after build
seemk Mar 29, 2021
3cc06df
use explicit cache paths
seemk Mar 29, 2021
4ff5533
update grpc build
seemk Mar 29, 2021
c62faa1
add libcurl
seemk Mar 29, 2021
1ab8bca
use newer cmake
seemk Mar 29, 2021
fbce740
generate dockerfiles
seemk Mar 30, 2021
b6dad4e
make use of generated dockerfiles
seemk Mar 30, 2021
1694c8b
fix grpc version
seemk Mar 30, 2021
aaf6deb
test with disabled ubuntu 18 stable nginx
seemk Mar 30, 2021
f7f9b40
fix trests for 18.04 stable, update readme
seemk Mar 30, 2021
b8b246f
updat readme
seemk Mar 30, 2021
eed2432
log docker output
seemk Mar 31, 2021
b569dc3
fix traces.json file permissions
seemk Mar 31, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 59 additions & 44 deletions .github/workflows/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,85 @@ name: nginx instrumentation CI
on:
push:
branches: "*"
paths:
- 'instrumentation/nginx/**'
- '.github/workflows/nginx.yml'
pull_request:
branches: [ main ]

jobs:
test-nginx-agent:
name: Test nginx agent
nginx-build-test:
name: nginx
runs-on: ubuntu-20.04
strategy:
matrix:
os: [ubuntu-20.10, ubuntu-20.04, ubuntu-18.04]
nginx-rel: [mainline, stable]
steps:
- name: checkout otel nginx
uses: actions/checkout@v2
- name: setup
run: |
sudo ./instrumentation/nginx/ci/setup_test_environment.sh
- name: build docker images
run: |
cd instrumentation/nginx
docker build -t otel-nginx-test/nginx -f test/Dockerfile .
docker build -t otel-nginx-test/express-backend -f test/backend/simple_express/Dockerfile test/backend/simple_express
- name: run tests
sudo ./instrumentation/nginx/ci/setup_environment.sh
- name: generate dockerfile
run: |
cd instrumentation/nginx/test/instrumentation
mix local.hex --force --if-missing
mix local.rebar --force --if-missing
mix deps.get
mix test
build-nginx-agent:
name: Build nginx agent
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- name: checkout otel nginx
uses: actions/checkout@v2
- name: setup
run: |
sudo ./instrumentation/nginx/ci/setup_ci_environment.sh
- name: checkout grpc
uses: actions/checkout@v2
with:
repository: "grpc/grpc"
ref: "v1.35.0"
fetch-depth: 1
path: "instrumentation/nginx/grpc"
submodules: "recursive"
- name: build grpc
mix dockerfiles .. ${{ matrix.os }}:${{ matrix.nginx-rel }}
- name: setup buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: cache docker layers
uses: actions/cache@v2
with:
path: /tmp/buildx-cache/
key: nginx-${{ matrix.os }}-${{ matrix.nginx-rel }}-${{ github.sha }}
restore-keys: |
nginx-${{ matrix.os }}-${{ matrix.nginx-rel }}
- name: build express backend docker
run: |
cd instrumentation/nginx
./ci/grpc.sh
- name: checkout opentelemetry-cpp
uses: actions/checkout@v2
with:
repository: "open-telemetry/opentelemetry-cpp"
fetch-depth: 1
path: "instrumentation/nginx/opentelemetry-cpp"
submodules: "recursive"
- name: build opentelemetry-cpp
docker buildx build -t otel-nginx-test/express-backend \
-f test/backend/simple_express/Dockerfile \
--cache-from type=local,src=/tmp/buildx-cache/express \
--cache-to type=local,dest=/tmp/buildx-cache/express-new \
--load \
test/backend/simple_express
- name: build nginx docker
run: |
cd instrumentation/nginx
./ci/otel-cpp.sh
- name: build nginx module
docker buildx build -t otel-nginx-test/nginx \
--build-arg image=$(echo ${{ matrix.os }} | sed s/-/:/) \
-f test/Dockerfile.${{ matrix.os }}.${{ matrix.nginx-rel }} \
--cache-from type=local,src=/tmp/buildx-cache/nginx \
--cache-to type=local,dest=/tmp/buildx-cache/nginx-new \
--load \
.
- name: update cache
run: |
rm -rf /tmp/buildx-cache/express
rm -rf /tmp/buildx-cache/nginx
mv /tmp/buildx-cache/express-new /tmp/buildx-cache/express
mv /tmp/buildx-cache/nginx-new /tmp/buildx-cache/nginx
- name: run tests
run: |
cd instrumentation/nginx/test/instrumentation
mix test
- name: copy artifacts
id: artifacts
run: |
cd instrumentation/nginx
./ci/build_module.sh
- name: Upload module artifact
mkdir -p /tmp/otel_ngx/
docker buildx build -f test/Dockerfile.${{ matrix.os }}.${{ matrix.nginx-rel}} \
--target export \
--cache-from type=local,src=/tmp/.buildx-cache \
--output type=local,dest=/tmp/otel_ngx .
- name: upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-nginx
path: ./instrumentation/nginx/build/otel_ngx_module.so
name: otel_ngx_module-${{ matrix.os }}-${{ matrix.nginx-rel }}.so
path: /tmp/otel_ngx/otel_ngx_module.so
54 changes: 31 additions & 23 deletions instrumentation/nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,34 @@ Supported propagation types:

## Requirements

* OS: Linux
* Nginx
* latest stable - [1.18.0](http://nginx.org/en/download.html)
* OS: Linux. Test suite currently runs on Ubuntu 18.04, 20.04, 20.10.
* [Nginx](http://nginx.org/en/download.html)
* both stable (`1.18.0`) and mainline (`1.19.8`)
* Nginx modules
* ngx_http_upstream_module (proxy_pass)
* ngx_http_fastcgi_module (fastcgi_pass)

Additional platforms and/or versions coming soon.

## Dependencies (for building)

1. [gRPC](https://github.com/grpc/grpc) - currently the only supported exporter is OTLP. This requirement will be lifted
once more exporters become available.
2. [opentelemetry-cpp](https://github.com/open-telemetry/opentelemetry-cpp) - opentelemetry-cpp needs to be built with
position independent code and OTLP support, e.g.:
```
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_OTLP=ON ..
```

## Building

```
mkdir build
cd build
cmake ..
make
```

## Usage

Modify nginx.conf, or see the [example](test/conf/nginx.conf)
Expand Down Expand Up @@ -133,25 +152,6 @@ List of exported attributes and their corresponding nginx variables if applicabl
- `http.scheme` - `$scheme`
- `http.server_name` - From the `server_name` directive

## Dependencies

1. [gRPC](https://github.com/grpc/grpc) - currently the only supported exporter is OTLP. This requirement will be lifted
once more exporters become available.
2. [opentelemetry-cpp](https://github.com/open-telemetry/opentelemetry-cpp) - opentelemetry-cpp needs to be built with
position independent code and OTLP support, e.g.:
```
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DWITH_OTLP=ON ..
```

## Building

```
mkdir build
cd build
cmake ..
make
```

## Testing

Dependencies:
Expand All @@ -160,8 +160,16 @@ Dependencies:
* [Docker Compose](https://docs.docker.com/compose/install/)

```
docker build -t otel-nginx-test/nginx -f test/Dockerfile .
cd test/instrumentation
mix .. dockerfiles ubuntu-20.04:mainline
cd ../..
docker build -t otel-nginx-test/nginx -f test/Dockerfile.ubuntu-20.04.mainline .
docker build -t otel-nginx-test/express-backend -f test/backend/simple_express/Dockerfile test/backend/simple_express
cd test/instrumentation
mix test
```

## Troubleshooting

### `otel_ngx_module.so is not binary compatible`
- Make sure your nginx is compiled with `--with-compat` (`nginx -V`). On Ubuntu 18.04 the default nginx (`1.14.0`) from apt does not have compatibility enabled. nginx provides [repositories](https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#prebuilt_ubuntu) to install more up to date versions.
8 changes: 0 additions & 8 deletions instrumentation/nginx/ci/build_module.sh

This file was deleted.

20 changes: 0 additions & 20 deletions instrumentation/nginx/ci/grpc.sh

This file was deleted.

13 changes: 0 additions & 13 deletions instrumentation/nginx/ci/otel-cpp.sh

This file was deleted.

10 changes: 0 additions & 10 deletions instrumentation/nginx/ci/setup_ci_environment.sh

This file was deleted.

27 changes: 24 additions & 3 deletions instrumentation/nginx/nginx.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
include(ExternalProject)

set(NGINX_VER "1.18.0" CACHE STRING "Nginx version to compile against")
if (NOT NGINX_VERSION)
find_program(NGINX_BIN nginx REQUIRED)
execute_process(COMMAND ${NGINX_BIN} -v
ERROR_VARIABLE NGINX_VERSION_STRING
)

string(REGEX MATCH "[0-9]+\\.\[0-9]+\\.[0-9]+" NGINX_VER ${NGINX_VERSION_STRING})
else()
set(NGINX_VER "1.18.0")
endif()

set(NGINX_VERSION ${NGINX_VER} CACHE STRING "Nginx version to compile against")
message(STATUS "nginx: using version ${NGINX_VERSION}")

option(NGINX_WITH_COMPAT "Enable --with-compat for the nginx module" ON)

if (NGINX_WITH_COMPAT)
message(STATUS "nginx: --with-compat enabled")
set(NGINX_CONFIGURE_ARGS "--with-compat")
else()
message(STATUS "nginx: --with-compat disabled")
endif()

ExternalProject_Add(project_nginx
URL "http://nginx.org/download/nginx-${NGINX_VER}.tar.gz"
URL "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"
PREFIX "nginx"
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ./configure --with-compat
CONFIGURE_COMMAND ./configure ${NGINX_CONFIGURE_ARGS}
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
Expand Down
35 changes: 0 additions & 35 deletions instrumentation/nginx/test/Dockerfile

This file was deleted.

17 changes: 17 additions & 0 deletions instrumentation/nginx/test/conf/fastcgi_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
4 changes: 2 additions & 2 deletions instrumentation/nginx/test/conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load_module modules/otel_ngx_module.so;
load_module /usr/share/nginx/modules/otel_ngx_module.so;

events {}

Expand Down Expand Up @@ -49,11 +49,11 @@ http {
}

location ~ \.php$ {
include /etc/nginx/fastcgi_params;
root /var/www/html/php;
opentelemetry_operation_name php_fpm_backend;
opentelemetry_propagate;
fastcgi_pass php-backend:9000;
include fastcgi.conf;
}
}
}
1 change: 1 addition & 0 deletions instrumentation/nginx/test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
image: otel-nginx-test/nginx:latest
volumes:
- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./conf/fastcgi_params:/etc/nginx/fastcgi_params
- ./conf/otel-nginx.toml:/conf/otel-nginx.toml
- ./backend/files:/var/www/html/files
ports:
Expand Down
Loading