Skip to content

Commit

Permalink
Adding functionality to ingore request paths, disabling monitoring on…
Browse files Browse the repository at this point in the history
… the given routes. (#398)

* Ignore path functionality
  • Loading branch information
aryanishan1001 authored Mar 19, 2024
1 parent 09f638f commit a02e005
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 86 deletions.
114 changes: 56 additions & 58 deletions .github/workflows/webserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,17 @@ jobs:
uses: docker/setup-buildx-action@master
with:
install: true
- name: cache docker layers
uses: actions/cache@v3
with:
path: /tmp/buildx-cache/
key: apache-centos7-${{ github.sha }}
restore-keys: |
apache-centos7
# - name: cache docker layers
# uses: actions/cache@v3
# with:
# path: /tmp/buildx-cache/
# key: apache-centos7-${{ github.sha }}
# restore-keys: |
# apache-centos7
- name: setup docker image
run: |
cd instrumentation/otel-webserver-module
docker buildx build -t apache_centos7 -f docker/centos7/Dockerfile \
--cache-from type=local,src=/tmp/buildx-cache/apache_centos7 \
--cache-to type=local,dest=/tmp/buildx-cache/apache_centos7-new \
--load .
- name: build
run: |
Expand All @@ -98,10 +96,10 @@ jobs:
run: |
docker exec apache_centos7_container bash -c \
'cd /otel-webserver-module; ./gradlew runUnitTest'
- name: update cache
run: |
rm -rf /tmp/buildx-cache/apache_centos7
mv /tmp/buildx-cache/apache_centos7-new /tmp/buildx-cache/apache_centos7
# - name: update cache
# run: |
# rm -rf /tmp/buildx-cache/apache_centos7
# mv /tmp/buildx-cache/apache_centos7-new /tmp/buildx-cache/apache_centos7
- name: copy artifacts
id: artifacts
run: |
Expand All @@ -123,51 +121,51 @@ jobs:
sleep 30
./gradlew :test:integration:integrationTests -i
webserver-build-test-centos6:
name: webserver-centos6-build
runs-on: ubuntu-20.04
steps:
- name: checkout otel webserver
uses: actions/checkout@v3
- name: setup buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: cache docker layers
uses: actions/cache@v3
with:
path: /tmp/buildx-cache/
key: apache-centos6-${{ github.sha }}
restore-keys: |
apache-centos6
- name: setup docker image
run: |
cd instrumentation/otel-webserver-module
docker buildx build -t apache_centos6 -f Dockerfile \
--cache-from type=local,src=/tmp/buildx-cache/apache_centos6 \
--cache-to type=local,dest=/tmp/buildx-cache/apache_centos6-new \
--load .
- name: build
run: |
docker run -idt --name apache_centos6_container apache_centos6 /bin/bash
cd instrumentation/otel-webserver-module
docker exec apache_centos6_container bash -c \
'cd /otel-webserver-module; rm -rf *;'
docker cp . $(docker inspect --format="{{.Id}}" apache_centos6_container):/otel-webserver-module/
docker exec apache_centos6_container bash -c \
'cd /otel-webserver-module; rm -rf build; \
cp -r /dependencies /otel-webserver-module/; \
cp -r /build-dependencies /otel-webserver-module/; \
./gradlew assembleWebServerModule'
- name: unit test
run: |
docker exec apache_centos6_container bash -c \
'cd /otel-webserver-module; ./gradlew runUnitTest'
- name: update cache
run: |
rm -rf /tmp/buildx-cache/apache_centos6
mv /tmp/buildx-cache/apache_centos6-new /tmp/buildx-cache/apache_centos6
# webserver-build-test-centos6:
# name: webserver-centos6-build
# runs-on: ubuntu-20.04
# steps:
# - name: checkout otel webserver
# uses: actions/checkout@v3
# - name: setup buildx
# id: buildx
# uses: docker/setup-buildx-action@master
# with:
# install: true
# - name: cache docker layers
# uses: actions/cache@v3
# with:
# path: /tmp/buildx-cache/
# key: apache-centos6-${{ github.sha }}
# restore-keys: |
# apache-centos6
# - name: setup docker image
# run: |
# cd instrumentation/otel-webserver-module
# docker buildx build -t apache_centos6 -f Dockerfile \
# --cache-from type=local,src=/tmp/buildx-cache/apache_centos6 \
# --cache-to type=local,dest=/tmp/buildx-cache/apache_centos6-new \
# --load .
# - name: build
# run: |
# docker run -idt --name apache_centos6_container apache_centos6 /bin/bash
# cd instrumentation/otel-webserver-module
# docker exec apache_centos6_container bash -c \
# 'cd /otel-webserver-module; rm -rf *;'
# docker cp . $(docker inspect --format="{{.Id}}" apache_centos6_container):/otel-webserver-module/
# docker exec apache_centos6_container bash -c \
# 'cd /otel-webserver-module; rm -rf build; \
# cp -r /dependencies /otel-webserver-module/; \
# cp -r /build-dependencies /otel-webserver-module/; \
# ./gradlew assembleWebServerModule'
# - name: unit test
# run: |
# docker exec apache_centos6_container bash -c \
# 'cd /otel-webserver-module; ./gradlew runUnitTest'
# - name: update cache
# run: |
# rm -rf /tmp/buildx-cache/apache_centos6
# mv /tmp/buildx-cache/apache_centos6-new /tmp/buildx-cache/apache_centos6

Codeql-build:
name: static-analysis
Expand Down
7 changes: 6 additions & 1 deletion instrumentation/otel-webserver-module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ Currently, Nginx Webserver module monitores some fixed set of modules, which get
|*NginxModuleRequestHeaders* | | OPTIONAL: Specify the request headers to be captured in the span attributes. The headers are Case-Sensitive and should be comma-separated. e.g.```NginxModuleRequestHeaders Accept-Charset,Accept-Encoding,User-Agent;```|
|*NginxModuleResponseHeaders* | | OPTIONAL: Specify the response headers to be captured in the span attributes. The headers are Case-Sensitive and should be comma-separated. e.g.```NginxModuleResponseHeaders Content-Length,Content-Type;```|
|*NginxModuleOtelExporterOtlpHeaders* | | OPTIONAL: OTEL exporter headers like Meta data related exposrted end point. a list of key value pairs, and these are expected to be represented in a format matching to the W3C Correlation-Context, except that additional semi-colon delimited metadata is not supported, i.e.: key1=value1,key2=value2.|
|*NginxTrustIncomingSpans* | ON | OPTIONAL: Specify if you want to correlate Nginx instrumented traces and spans with incoming requests.|
|*NginxModuleTrustIncomingSpans* | ON | OPTIONAL: Specify if you want to correlate Nginx instrumented traces and spans with incoming requests.|
|*NginxModuleAttributes* | | OPTIONAL: Can be used to pass additionalccustom attributes to the span, nginx variables are also supported. All elements must be separated by a space, and different attribute key value pairs must be separated by a comma( even the comma needs to be separated by space). e.g. ```NginxModuleAttributes Key1 Value1 , Key2 $request_uri;``` |
|*NginxModuleIgnorePaths* | | OPTIONAL: Request URIs matching the Regex will not be monitored. Multiple space separated Regex can be provided( `'\'` symbol needs to be used carefully, Nginx treats `'\'` as a escape sequence, thus if the Regex sequence contains a `'\'`, it need to be replaced by `'\\'`, likewise if sequence contains `'\\'`, it need to be written as `'\\\\'` e.g. `.*\.html` -> `.*\\.html` ) e.g. ```NginxModuleIgnorePaths .*\\.html /test_.*;```|




### Build and Installation
#### Prerequisites
Expand Down
15 changes: 15 additions & 0 deletions instrumentation/otel-webserver-module/include/util/RegexResolver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef REGEX_RESOLVER_H
#define REGEX_RESOLVER_H

#ifdef __cplusplus
extern "C" {
#endif


bool matchIgnorePathRegex(char * uri , char * regexVar);


#ifdef __cplusplus
}
#endif
#endif
4 changes: 3 additions & 1 deletion instrumentation/otel-webserver-module/src/build.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
'core/sdkwrapper/ScopedSpan.cpp',
'core/sdkwrapper/ServerSpan.cpp',
'core/sdkwrapper/SdkWrapper.cpp',
'util/SpanNamingUtils.cpp'
'util/SpanNamingUtils.cpp',
'util/RegexResolver.cpp'
],

'conditions': [
Expand Down Expand Up @@ -184,3 +185,4 @@
]
}]
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <sstream>
#include <unordered_set>
#include <algorithm>
#include <regex>

otel::core::WSAgent wsAgent; // global variable for interface between Hooks and Core Logic
std::unordered_set<std::string> requestHeadersToCapture;
Expand Down
Loading

0 comments on commit a02e005

Please sign in to comment.