diff --git a/.github/workflows/webserver.yml b/.github/workflows/webserver.yml index 6aa2af8b6..30056d472 100644 --- a/.github/workflows/webserver.yml +++ b/.github/workflows/webserver.yml @@ -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: | @@ -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: | @@ -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 diff --git a/instrumentation/otel-webserver-module/README.md b/instrumentation/otel-webserver-module/README.md index 42dd20b74..cb7605798 100644 --- a/instrumentation/otel-webserver-module/README.md +++ b/instrumentation/otel-webserver-module/README.md @@ -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 diff --git a/instrumentation/otel-webserver-module/include/util/RegexResolver.h b/instrumentation/otel-webserver-module/include/util/RegexResolver.h new file mode 100644 index 000000000..e4a03b46f --- /dev/null +++ b/instrumentation/otel-webserver-module/include/util/RegexResolver.h @@ -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 \ No newline at end of file diff --git a/instrumentation/otel-webserver-module/src/build.gyp b/instrumentation/otel-webserver-module/src/build.gyp index ac31bd3e3..07f8a1eb2 100644 --- a/instrumentation/otel-webserver-module/src/build.gyp +++ b/instrumentation/otel-webserver-module/src/build.gyp @@ -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': [ @@ -184,3 +185,4 @@ ] }] } + diff --git a/instrumentation/otel-webserver-module/src/core/api/opentelemetry_ngx_api.cpp b/instrumentation/otel-webserver-module/src/core/api/opentelemetry_ngx_api.cpp index 37a8be8c8..4f71f2cb0 100644 --- a/instrumentation/otel-webserver-module/src/core/api/opentelemetry_ngx_api.cpp +++ b/instrumentation/otel-webserver-module/src/core/api/opentelemetry_ngx_api.cpp @@ -21,6 +21,7 @@ #include #include #include +#include otel::core::WSAgent wsAgent; // global variable for interface between Hooks and Core Logic std::unordered_set requestHeadersToCapture; diff --git a/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c b/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c index ce98b5deb..cd278257b 100644 --- a/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c +++ b/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.c @@ -16,6 +16,7 @@ #include "ngx_http_opentelemetry_module.h" #include "ngx_http_opentelemetry_log.h" +#include "../../include/util/RegexResolver.h" #include #include #include @@ -377,19 +378,26 @@ static ngx_command_t ngx_http_opentelemetry_commands[] = { offsetof(ngx_http_opentelemetry_loc_conf_t, nginxModuleResponseHeaders), NULL}, - { ngx_string("NginxTrustIncomingSpans"), + { ngx_string("NginxModuleTrustIncomingSpans"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_opentelemetry_loc_conf_t, nginxTrustIncomingSpans), + offsetof(ngx_http_opentelemetry_loc_conf_t, nginxModuleTrustIncomingSpans), NULL}, - { ngx_string("NginxAttributes"), + { ngx_string("NginxModuleAttributes"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, ngx_otel_attributes_set, NGX_HTTP_LOC_CONF_OFFSET, 0, NULL}, + + { ngx_string("NginxModuleIgnorePaths"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, + ngx_conf_ignore_path_set, + NGX_HTTP_LOC_CONF_OFFSET, + 0, + NULL}, /* command termination */ ngx_null_command @@ -453,7 +461,7 @@ static void* ngx_http_opentelemetry_create_loc_conf(ngx_conf_t *cf) conf->nginxModuleTraceAsError = NGX_CONF_UNSET; conf->nginxModuleOtelMaxQueueSize = NGX_CONF_UNSET; conf->nginxModuleOtelSslEnabled = NGX_CONF_UNSET; - conf->nginxTrustIncomingSpans = NGX_CONF_UNSET; + conf->nginxModuleTrustIncomingSpans = NGX_CONF_UNSET; return conf; } @@ -464,6 +472,7 @@ static char* ngx_http_opentelemetry_merge_loc_conf(ngx_conf_t *cf, void *parent, ngx_http_opentelemetry_loc_conf_t *conf = child; ngx_otel_set_global_context(prev); ngx_otel_set_attributes(prev, conf); + ngx_conf_merge_ignore_paths(prev, conf); ngx_conf_merge_value(conf->nginxModuleEnabled, prev->nginxModuleEnabled, 1); ngx_conf_merge_value(conf->nginxModuleReportAllInstrumentedModules, prev->nginxModuleReportAllInstrumentedModules, 0); @@ -471,7 +480,7 @@ static char* ngx_http_opentelemetry_merge_loc_conf(ngx_conf_t *cf, void *parent, ngx_conf_merge_value(conf->nginxModuleTraceAsError, prev->nginxModuleTraceAsError, 0); ngx_conf_merge_value(conf->nginxModuleMaskCookie, prev->nginxModuleMaskCookie, 0); ngx_conf_merge_value(conf->nginxModuleMaskSmUser, prev->nginxModuleMaskSmUser, 0); - ngx_conf_merge_value(conf->nginxTrustIncomingSpans, prev->nginxTrustIncomingSpans, 1); + ngx_conf_merge_value(conf->nginxModuleTrustIncomingSpans, prev->nginxModuleTrustIncomingSpans, 1); ngx_conf_merge_str_value(conf->nginxModuleOtelSpanExporter, prev->nginxModuleOtelSpanExporter, ""); @@ -683,6 +692,7 @@ static void ngx_http_opentelemetry_exit_worker(ngx_cycle_t *cycle) ngx_log_error(NGX_LOG_ERR, cycle->log, 0, "mod_opentelemetry: ngx_http_opentelemetry_exit_worker: Exiting Nginx Worker for process with PID: %s**********", worker_conf->pid); } } + static char* ngx_otel_attributes_set(ngx_conf_t* cf, ngx_command_t* cmd, void* conf) { ngx_http_opentelemetry_loc_conf_t * my_conf=(ngx_http_opentelemetry_loc_conf_t *)conf; @@ -707,7 +717,33 @@ static char* ngx_otel_attributes_set(ngx_conf_t* cf, ngx_command_t* cmd, void* c ngx_str_set(elt, value[i].data); elt->len = ngx_strlen(value[i].data); } - my_conf->nginxAttributes = arr; + my_conf->nginxModuleAttributes = arr; + return NGX_CONF_OK; + +} + +static char* ngx_conf_ignore_path_set(ngx_conf_t* cf, ngx_command_t* cmd, void* conf) { + ngx_http_opentelemetry_loc_conf_t * my_conf=(ngx_http_opentelemetry_loc_conf_t *)conf; + + ngx_str_t *value = cf->args->elts; + ngx_array_t *arr; + ngx_str_t *elt; + ngx_int_t arg_count = cf->args->nelts; + + arr = ngx_array_create(cf->pool, arg_count, sizeof(ngx_str_t)); + if (arr == NULL) { + return NGX_CONF_ERROR; + } + + for (ngx_int_t i = 1; i < arg_count; i++) { + elt = ngx_array_push(arr); + if (elt == NULL) { + return NGX_CONF_ERROR; + } + ngx_str_set(elt, value[i].data); + elt->len = ngx_strlen(value[i].data); + } + my_conf->nginxModuleIgnorePaths = arr; return NGX_CONF_OK; } @@ -744,13 +780,27 @@ static void ngx_otel_set_global_context(ngx_http_opentelemetry_loc_conf_t * prev static void ngx_otel_set_attributes(ngx_http_opentelemetry_loc_conf_t * prev, ngx_http_opentelemetry_loc_conf_t * conf) { - if (conf->nginxAttributes && (conf->nginxAttributes->nelts) > 0) { + if (conf->nginxModuleAttributes && (conf->nginxModuleAttributes->nelts) > 0) { + return; + } + if (prev->nginxModuleAttributes && (prev->nginxModuleAttributes->nelts) > 0) { + if((conf->nginxModuleAttributes) == NULL) + { + conf->nginxModuleAttributes = prev->nginxModuleAttributes; + } + } + return; +} + +static void ngx_conf_merge_ignore_paths(ngx_http_opentelemetry_loc_conf_t * prev, ngx_http_opentelemetry_loc_conf_t * conf) +{ + if (conf->nginxModuleIgnorePaths && (conf->nginxModuleIgnorePaths->nelts) > 0) { return; } - if (prev->nginxAttributes && (prev->nginxAttributes->nelts) > 0) { - if((conf->nginxAttributes) == NULL) + if (prev->nginxModuleIgnorePaths && (prev->nginxModuleIgnorePaths->nelts) > 0) { + if((conf->nginxModuleIgnorePaths) == NULL) { - conf->nginxAttributes = prev->nginxAttributes; + conf->nginxModuleIgnorePaths = prev->nginxModuleIgnorePaths; } } return; @@ -949,10 +999,10 @@ static void resolve_attributes_variables(ngx_http_request_t* r) { ngx_http_opentelemetry_loc_conf_t *conf = ngx_http_get_module_loc_conf(r, ngx_http_opentelemetry_module); - for (ngx_uint_t j = 0; j < conf->nginxAttributes->nelts; j++) { + for (ngx_uint_t j = 0; j < conf->nginxModuleAttributes->nelts; j++) { - void *element = conf->nginxAttributes->elts + (j * conf->nginxAttributes->size); - ngx_str_t var_name = (((ngx_str_t *)(conf->nginxAttributes->elts))[j]); + void *element = conf->nginxModuleAttributes->elts + (j * conf->nginxModuleAttributes->size); + ngx_str_t var_name = (((ngx_str_t *)(conf->nginxModuleAttributes->elts))[j]); ngx_uint_t key; // The variable's hashed key. ngx_http_variable_value_t *value; // Pointer to the value object. @@ -978,6 +1028,27 @@ static void resolve_attributes_variables(ngx_http_request_t* r) } } +static ngx_flag_t check_ignore_paths(ngx_http_request_t *r) +{ + ngx_http_opentelemetry_loc_conf_t * conf = ngx_http_get_module_loc_conf(r, ngx_http_opentelemetry_module); + + ngx_uint_t uriLen = r->uri.len; + char *pathToCheck = ngx_pnalloc(r->pool, uriLen + 1); + ngx_memcpy(pathToCheck, r->uri.data, uriLen); + pathToCheck[uriLen] = '\0'; + + if (conf->nginxModuleIgnorePaths && (conf->nginxModuleIgnorePaths->nelts) > 0) { + for (ngx_uint_t j = 0; j < conf->nginxModuleIgnorePaths->nelts; j++) { + const char* data = (const char*)(((ngx_str_t *)(conf->nginxModuleIgnorePaths->elts))[j]).data; + bool ans = matchIgnorePathRegex(pathToCheck , data); + if(ans){ + return true; + } + } + } + return false; +} + static ngx_flag_t ngx_initialize_opentelemetry(ngx_http_request_t *r) { // check to see if we have already been initialized @@ -1206,6 +1277,7 @@ static void stopMonitoringRequest(ngx_http_request_t* r, if (r->pool) { res_payload = ngx_pcalloc(r->pool, sizeof(response_payload)); res_payload->response_headers_count = 0; + res_payload->otel_attributes_count = 0; fillResponsePayload(res_payload, r); } @@ -1252,6 +1324,12 @@ static void startMonitoringRequest(ngx_http_request_t* r){ ngx_writeError(r->connection->log, __func__, "Opentelemetry Agent Core did not get initialized"); return; } + else if(check_ignore_paths(r)){ + ngx_writeTrace(r->connection->log, __func__, "Monitoring has been disabled for: %s", r->uri.data); + return; + } + + ngx_http_otel_handles_t* ctx; ctx = ngx_http_get_module_ctx(r, ngx_http_opentelemetry_module); @@ -1735,7 +1813,7 @@ static void fillRequestPayload(request_payload* req_payload, ngx_http_request_t* for (ngx_uint_t j = 0; j < nelts; j++) { h = &header[j]; - for (int i = 0; i < headers_len && conf->nginxTrustIncomingSpans ; i++) { + for (int i = 0; i < headers_len && conf->nginxModuleTrustIncomingSpans ; i++) { if (strcmp(h->key.data, httpHeaders[i]) == 0) { req_payload->propagation_headers[propagation_headers_idx].name = httpHeaders[i]; @@ -1778,16 +1856,16 @@ static void fillResponsePayload(response_payload* res_payload, ngx_http_request_ res_payload->response_headers = ngx_pcalloc(r->pool, nelts * sizeof(http_headers)); ngx_uint_t headers_count = 0; - ngx_http_opentelemetry_loc_conf_t *conf = ngx_http_get_module_loc_conf(r, ngx_http_opentelemetry_module); + ngx_http_opentelemetry_loc_conf_t *conf = ngx_http_get_module_loc_conf(r, ngx_http_opentelemetry_module); - if (conf->nginxAttributes && (conf->nginxAttributes->nelts) > 0) { + if (conf->nginxModuleAttributes && (conf->nginxModuleAttributes->nelts) > 0) { - res_payload->otel_attributes = ngx_pcalloc(r->pool, ((nelts+1)/3) * sizeof(http_headers)); - int otel_attributes_idx=0; + res_payload->otel_attributes = ngx_pcalloc(r->pool, ((conf->nginxModuleAttributes->nelts + 1)/3) * sizeof(http_headers)); + ngx_uint_t otel_attributes_idx=0; resolve_attributes_variables(r); - for (ngx_uint_t j = 0, isKey = 1, isValue = 0; j < conf->nginxAttributes->nelts; j++) { - const char* data = (const char*)(((ngx_str_t *)(conf->nginxAttributes->elts))[j]).data; + for (ngx_uint_t j = 0, isKey = 1, isValue = 0; j < conf->nginxModuleAttributes->nelts; j++) { + const char* data = (const char*)(((ngx_str_t *)(conf->nginxModuleAttributes->elts))[j]).data; if(strcmp(data, ",") == 0){ otel_attributes_idx++; continue; @@ -1802,12 +1880,8 @@ static void fillResponsePayload(response_payload* res_payload, ngx_http_request_ isValue=!isValue; } res_payload->otel_attributes_count = otel_attributes_idx+1; - }else { - res_payload->otel_attributes_count = 0; } - - for (ngx_uint_t j = 0; j < nelts; j++) { h = &header[j]; diff --git a/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.h b/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.h index 7253f130e..90a6f7d89 100644 --- a/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.h +++ b/instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_module.h @@ -103,8 +103,9 @@ typedef struct { ngx_str_t nginxModuleRequestHeaders; ngx_str_t nginxModuleResponseHeaders; ngx_str_t nginxModuleOtelExporterOtlpHeaders; - ngx_flag_t nginxTrustIncomingSpans; - ngx_array_t *nginxAttributes; + ngx_flag_t nginxModuleTrustIncomingSpans; + ngx_array_t *nginxModuleAttributes; + ngx_array_t *nginxModuleIgnorePaths; } ngx_http_opentelemetry_loc_conf_t; @@ -156,8 +157,10 @@ static ngx_flag_t otel_requestHasErrors(ngx_http_request_t* r); static ngx_uint_t otel_getErrorCode(ngx_http_request_t* r); static char* ngx_otel_context_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char* ngx_otel_attributes_set(ngx_conf_t* cf, ngx_command_t*, void* conf); +static char* ngx_conf_ignore_path_set(ngx_conf_t* cf, ngx_command_t* cmd, void* conf); static void ngx_otel_set_global_context(ngx_http_opentelemetry_loc_conf_t * prev); static void ngx_otel_set_attributes(ngx_http_opentelemetry_loc_conf_t * prev, ngx_http_opentelemetry_loc_conf_t * conf); +static void ngx_conf_merge_ignore_paths(ngx_http_opentelemetry_loc_conf_t * prev, ngx_http_opentelemetry_loc_conf_t * conf); static void removeUnwantedHeader(ngx_http_request_t* r); /* Module specific handler diff --git a/instrumentation/otel-webserver-module/src/util/RegexResolver.cpp b/instrumentation/otel-webserver-module/src/util/RegexResolver.cpp new file mode 100644 index 000000000..cae25efe7 --- /dev/null +++ b/instrumentation/otel-webserver-module/src/util/RegexResolver.cpp @@ -0,0 +1,17 @@ +#include "RegexResolver.h" +#include +#include + +bool matchIgnorePathRegex(char * uri , char * regexVar){ + const std::string uriString(uri); + std::string regexVarString(regexVar); + + std::cmatch match; + const std::regex pattern(regexVarString); + bool ans = std::regex_match(uriString, pattern); + if(ans){ + return true; + }else{ + return false; + } +} \ No newline at end of file