Skip to content

Commit 0bf4ec5

Browse files
authored
Update nginx instrumentation (open-telemetry#494)
* Upgrade to latest OpenTelemetry. Switch to OTLP over HTTP * remove toml config compile with latest nginx add new configuration options to replace toml * update ci * remove mainline / stable distinction from ci * reduce the ci matrix temporarily * update docker image * readd caching * update export step * better artifact naming * fix artifact naming * additional ci images * add alpine builds * dockerfile selection * fix dockerfile selection * add amazon linux to ci * add amazon linux 2023 * update readme * update readme, don't use vla
1 parent 8933841 commit 0bf4ec5

27 files changed

+726
-3221
lines changed

.github/workflows/nginx.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,47 @@ on:
1515
jobs:
1616
nginx-build-test:
1717
name: nginx
18-
runs-on: ubuntu-20.04
18+
runs-on: ubuntu-24.04
1919
strategy:
20+
fail-fast: false
2021
matrix:
21-
os: [ubuntu-20.04, ubuntu-18.04, debian-10.11, debian-11.3]
22-
nginx-rel: [mainline, stable]
22+
image: ["ubuntu:24.04", "debian:11", "alpine:3.20", "amazonlinux:2", "amazonlinux:2023"]
23+
nginx: ["1.27.3", "1.27.1", "1.26.2", "1.24.0", "1.22.1"]
2324
steps:
2425
- name: checkout otel nginx
25-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2627
- name: setup
2728
run: |
2829
sudo ./instrumentation/nginx/ci/setup_environment.sh
29-
- name: generate dockerfile
30-
run: |
31-
cd instrumentation/nginx/test/instrumentation
32-
mix local.hex --force --if-missing
33-
mix local.rebar --force --if-missing
34-
mix deps.get
35-
mix dockerfiles .. ${{ matrix.os }}:${{ matrix.nginx-rel }}
3630
- name: setup buildx
3731
id: buildx
38-
uses: docker/setup-buildx-action@master
32+
uses: docker/setup-buildx-action@v3
3933
with:
4034
install: true
41-
- name: cache docker layers
42-
uses: actions/cache@v3
43-
with:
44-
path: /tmp/buildx-cache/
45-
key: nginx-${{ matrix.os }}-${{ matrix.nginx-rel }}-${{ github.sha }}
46-
restore-keys: |
47-
nginx-${{ matrix.os }}-${{ matrix.nginx-rel }}
4835
- name: build express backend docker
4936
run: |
5037
cd instrumentation/nginx
51-
docker buildx build -t otel-nginx-test/express-backend \
38+
docker build -t otel-nginx-test/express-backend \
5239
-f test/backend/simple_express/Dockerfile \
5340
--cache-from type=local,src=/tmp/buildx-cache/express \
5441
--cache-to type=local,dest=/tmp/buildx-cache/express-new \
5542
--load \
5643
test/backend/simple_express
44+
- name: Choose Dockerfile
45+
run: |
46+
if [[ "${{ matrix.image }}" == "alpine"* ]]; then
47+
echo "dockerfile=Dockerfile_alpine" >> $GITHUB_ENV
48+
elif [[ "${{ matrix.image }}" == "amazonlinux"* ]]; then
49+
echo "dockerfile=Dockerfile_amazonlinux" >> $GITHUB_ENV
50+
else
51+
echo "dockerfile=Dockerfile" >> $GITHUB_ENV
52+
fi
5753
- name: build nginx docker
5854
run: |
5955
cd instrumentation/nginx
60-
docker buildx build -t otel-nginx-test/nginx \
61-
--build-arg image=$(echo ${{ matrix.os }} | sed s/-/:/) \
62-
-f test/Dockerfile.${{ matrix.os }}.${{ matrix.nginx-rel }} \
56+
docker build -t otel-nginx-test/nginx \
57+
--build-arg image=${{ matrix.image }} \
58+
-f test/${{ env.dockerfile }} \
6359
--cache-from type=local,src=/tmp/buildx-cache/nginx \
6460
--cache-to type=local,dest=/tmp/buildx-cache/nginx-new \
6561
--load \
@@ -73,18 +69,22 @@ jobs:
7369
- name: run tests
7470
run: |
7571
cd instrumentation/nginx/test/instrumentation
72+
mix local.hex --force --if-missing
73+
mix local.rebar --force --if-missing
74+
mix deps.get
7675
mix test
7776
- name: copy artifacts
7877
id: artifacts
7978
run: |
8079
cd instrumentation/nginx
8180
mkdir -p /tmp/otel_ngx/
82-
docker buildx build -f test/Dockerfile.${{ matrix.os }}.${{ matrix.nginx-rel}} \
81+
docker build -f test/${{ env.dockerfile }} \
82+
--build-arg image=${{ matrix.image }} \
8383
--target export \
84-
--cache-from type=local,src=/tmp/.buildx-cache \
8584
--output type=local,dest=/tmp/otel_ngx .
85+
echo "artifactName=otel_ngx_module-$(echo ${{ matrix.image }} | sed s/:/-/)-${{ matrix.nginx }}.so" >> $GITHUB_ENV
8686
- name: upload artifacts
87-
uses: actions/upload-artifact@v3
87+
uses: actions/upload-artifact@v4
8888
with:
89-
name: otel_ngx_module-${{ matrix.os }}-${{ matrix.nginx-rel }}.so
89+
name: ${{ env.artifactName }}
9090
path: /tmp/otel_ngx/otel_ngx_module.so

instrumentation/nginx/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build/

instrumentation/nginx/CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ cmake_minimum_required(VERSION 3.12)
22

33
project(opentelemetry-nginx)
44

5-
find_package(opentelemetry-cpp REQUIRED)
5+
option(WITH_ABSEIL "Use abseil" OFF)
6+
7+
find_package(opentelemetry-cpp CONFIG REQUIRED)
8+
find_package(nlohmann_json)
69
find_package(Threads REQUIRED)
710
find_package(Protobuf REQUIRED)
8-
find_package(gRPC REQUIRED)
911
find_package(CURL REQUIRED)
1012

13+
if (WITH_ABSEIL)
14+
find_package(absl REQUIRED)
15+
endif()
16+
1117
include(${CMAKE_CURRENT_SOURCE_DIR}/nginx.cmake)
1218

1319
add_library(otel_ngx_module SHARED
1420
src/nginx_config.cpp
15-
src/toml.c
16-
src/agent_config.cpp
1721
src/trace_context.cpp
1822
src/otel_ngx_module.cpp
1923
src/otel_ngx_module_modules.c
@@ -42,6 +46,5 @@ target_include_directories(otel_ngx_module
4246
target_link_libraries(otel_ngx_module
4347
PRIVATE
4448
${OPENTELEMETRY_CPP_LIBRARIES}
45-
gRPC::grpc++
4649
CURL::libcurl
4750
)

0 commit comments

Comments
 (0)