Skip to content

Commit

Permalink
Add otel-plugin-nginx, otel-cpp
Browse files Browse the repository at this point in the history
- Adds opentelemetry-cpp: c++ client for otel (dependency for
  otel-plugin-nginx).
- Adds otel-plugin-nginx
  • Loading branch information
wlynch committed Oct 9, 2024
1 parent a45af21 commit 48b1fdf
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 0 deletions.
56 changes: 56 additions & 0 deletions opentelemetry-cpp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package:
name: opentelemetry-cpp
version: 1.17.0
epoch: 0
description: The OpenTelemetry C++ Client
copyright:
- license: Apache-2.0

environment:
contents:
packages:
- abseil-cpp-dev
- benchmark-dev
- busybox
- c-ares-dev
- cmake
- gcc
- glibc-dev
- grpc-dev
- gtest-dev
- icu-dev
- make
- openssl-dev
- pkgconf
- protobuf-dev
- re2-dev
- systemd-dev

pipeline:
- uses: git-checkout
with:
repository: https://github.com/open-telemetry/opentelemetry-cpp
tag: v${{package.version}}
expected-commit: fa0a5200ddbe9ae6f487a228e658aedc102dab56

- runs: |
mkdir build
cd build
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DWITH_OTLP_GRPC=ON -DWITH_ABSEIL=ON ..
cmake --build . --target all
cmake --install . --prefix ${{targets.contextdir}}/usr
- uses: strip

update:
enabled: true
github:
identifier: open-telemetry/opentelemetry-cpp
strip-prefix: v

test:
pipeline:
# AUTOGENERATED
- runs: |
otelcol --version
otelcol --help
125 changes: 125 additions & 0 deletions opentelemetry-plugin-nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#nolint:valid-pipeline-git-checkout-tag
package:
name: opentelemetry-plugin-nginx
version: 0_git20241008
epoch: 0
description: Adds OpenTelemetry distributed tracing support to nginx.
copyright:
- license: Apache-2.0
dependencies:
runtime:
- opentelemetry-cpp

environment:
contents:
packages:
- abseil-cpp-dev
- busybox
- c-ares-dev
- cmake
- curl-dev
- gcc
- glibc-dev
- grpc-dev
- icu-dev
- make
- nginx
- opentelemetry-cpp
- pcre-dev
- protobuf-c-dev
- protobuf-dev
- re2-dev
- systemd-dev

pipeline:
- uses: git-checkout
with:
repository: https://github.com/open-telemetry/opentelemetry-cpp-contrib
branch: main
expected-commit: f6d29426ee9b4d6b476c09ca3cb9bed3cf23906f

- runs: |
cd instrumentation/nginx
mkdir build
cd build
cmake ..
make
mkdir -p ${{targets.contextdir}}/usr/share/nginx/modules
cp -p otel_ngx_module.so ${{targets.contextdir}}/usr/share/nginx/modules/
- uses: strip

update:
enabled: true
git: {}
schedule:
period: weekly
reason: shared contrib repo that doesn't maintain tags for this component

test:
environment:
contents:
packages:
- nginx
pipeline:
- uses: git-checkout
with:
repository: https://github.com/open-telemetry/opentelemetry-cpp-contrib
branch: main
expected-commit: f6d29426ee9b4d6b476c09ca3cb9bed3cf23906f
- runs: |
cat <<EOF > /etc/nginx/nginx.conf
load_module /usr/share/nginx/modules/otel_ngx_module.so;
user nobody;
http {
opentelemetry_config /etc/nginx/otel-nginx.toml;
server {
listen 80;
server_name otel_example;
root /var/www/html;
location = / {
opentelemetry_operation_name my_example_backend;
opentelemetry_propagate;
proxy_pass http://localhost:3500/;
}
}
}
events {}
EOF
cat <<EOF > /etc/nginx/otel-nginx.toml
exporter = "otlp"
processor = "batch"
[exporters.otlp]
# Alternatively the OTEL_EXPORTER_OTLP_ENDPOINT environment variable can also be used.
host = "localhost"
port = 4317
[processors.batch]
max_queue_size = 2048
schedule_delay_millis = 5000
max_export_batch_size = 512
[service]
# Can also be set by the OTEL_SERVICE_NAME environment variable.
name = "nginx-proxy" # Opentelemetry resource name
[sampler]
name = "AlwaysOn" # Also: AlwaysOff, TraceIdRatioBased
ratio = 0.1
parent_based = false
EOF
# Not sure why this isn't included in main package.
mkdir -p /var/lib/nginx/tmp/
# -T: test the configuration file: nginx checks the configuration for correct syntax, and then tries to open files referred in the configuration.
# additionally dump configuration files to standard output (1.9.2).
- runs: nginx -T

0 comments on commit 48b1fdf

Please sign in to comment.