Skip to content

Commit

Permalink
Update nginx instrumentation (#494)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
seemk authored Nov 29, 2024
1 parent 8933841 commit 0bf4ec5
Show file tree
Hide file tree
Showing 27 changed files with 726 additions and 3,221 deletions.
54 changes: 27 additions & 27 deletions .github/workflows/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,47 @@ on:
jobs:
nginx-build-test:
name: nginx
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-18.04, debian-10.11, debian-11.3]
nginx-rel: [mainline, stable]
image: ["ubuntu:24.04", "debian:11", "alpine:3.20", "amazonlinux:2", "amazonlinux:2023"]
nginx: ["1.27.3", "1.27.1", "1.26.2", "1.24.0", "1.22.1"]
steps:
- name: checkout otel nginx
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: setup
run: |
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 dockerfiles .. ${{ matrix.os }}:${{ matrix.nginx-rel }}
- name: setup buildx
id: buildx
uses: docker/setup-buildx-action@master
uses: docker/setup-buildx-action@v3
with:
install: true
- name: cache docker layers
uses: actions/cache@v3
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
docker buildx build -t otel-nginx-test/express-backend \
docker 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: Choose Dockerfile
run: |
if [[ "${{ matrix.image }}" == "alpine"* ]]; then
echo "dockerfile=Dockerfile_alpine" >> $GITHUB_ENV
elif [[ "${{ matrix.image }}" == "amazonlinux"* ]]; then
echo "dockerfile=Dockerfile_amazonlinux" >> $GITHUB_ENV
else
echo "dockerfile=Dockerfile" >> $GITHUB_ENV
fi
- name: build nginx docker
run: |
cd instrumentation/nginx
docker buildx build -t otel-nginx-test/nginx \
--build-arg image=$(echo ${{ matrix.os }} | sed s/-/:/) \
-f test/Dockerfile.${{ matrix.os }}.${{ matrix.nginx-rel }} \
docker build -t otel-nginx-test/nginx \
--build-arg image=${{ matrix.image }} \
-f test/${{ env.dockerfile }} \
--cache-from type=local,src=/tmp/buildx-cache/nginx \
--cache-to type=local,dest=/tmp/buildx-cache/nginx-new \
--load \
Expand All @@ -73,18 +69,22 @@ jobs:
- name: run tests
run: |
cd instrumentation/nginx/test/instrumentation
mix local.hex --force --if-missing
mix local.rebar --force --if-missing
mix deps.get
mix test
- name: copy artifacts
id: artifacts
run: |
cd instrumentation/nginx
mkdir -p /tmp/otel_ngx/
docker buildx build -f test/Dockerfile.${{ matrix.os }}.${{ matrix.nginx-rel}} \
docker build -f test/${{ env.dockerfile }} \
--build-arg image=${{ matrix.image }} \
--target export \
--cache-from type=local,src=/tmp/.buildx-cache \
--output type=local,dest=/tmp/otel_ngx .
echo "artifactName=otel_ngx_module-$(echo ${{ matrix.image }} | sed s/:/-/)-${{ matrix.nginx }}.so" >> $GITHUB_ENV
- name: upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: otel_ngx_module-${{ matrix.os }}-${{ matrix.nginx-rel }}.so
name: ${{ env.artifactName }}
path: /tmp/otel_ngx/otel_ngx_module.so
1 change: 1 addition & 0 deletions instrumentation/nginx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
13 changes: 8 additions & 5 deletions instrumentation/nginx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ cmake_minimum_required(VERSION 3.12)

project(opentelemetry-nginx)

find_package(opentelemetry-cpp REQUIRED)
option(WITH_ABSEIL "Use abseil" OFF)

find_package(opentelemetry-cpp CONFIG REQUIRED)
find_package(nlohmann_json)
find_package(Threads REQUIRED)
find_package(Protobuf REQUIRED)
find_package(gRPC REQUIRED)
find_package(CURL REQUIRED)

if (WITH_ABSEIL)
find_package(absl REQUIRED)
endif()

include(${CMAKE_CURRENT_SOURCE_DIR}/nginx.cmake)

add_library(otel_ngx_module SHARED
src/nginx_config.cpp
src/toml.c
src/agent_config.cpp
src/trace_context.cpp
src/otel_ngx_module.cpp
src/otel_ngx_module_modules.c
Expand Down Expand Up @@ -42,6 +46,5 @@ target_include_directories(otel_ngx_module
target_link_libraries(otel_ngx_module
PRIVATE
${OPENTELEMETRY_CPP_LIBRARIES}
gRPC::grpc++
CURL::libcurl
)
Loading

0 comments on commit 0bf4ec5

Please sign in to comment.