diff --git a/.clang-format b/.clang-format index 96943111..daee4e16 100644 --- a/.clang-format +++ b/.clang-format @@ -20,7 +20,7 @@ AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true -BraceWrapping: +BraceWrapping: AfterClass: false AfterControlStatement: false AfterEnum: false @@ -48,7 +48,7 @@ DerivePointerAlignment: true DisableFormat: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -IncludeCategories: +IncludeCategories: - Regex: '^<.*\.h>' Priority: 1 - Regex: '^<.*' diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index f4f75b84..04eb6811 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -12,7 +12,7 @@ permissions: env: ACTIONS_RUNNER_DEBUG: true ACTIONS_STEP_DEBUG: true - + jobs: dependabot: runs-on: ubuntu-latest @@ -23,7 +23,7 @@ jobs: uses: dependabot/fetch-metadata@v1 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - + - name: Approve a PR if: ${{contains(steps.metadata.outputs.directory, '/test')}} run: gh pr review --approve "$PR_URL" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..a0f2b165 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,41 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: .*pb2.* +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + args: [--allow-multiple-documents] + - id: check-ast + - id: check-added-large-files + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-executables-have-shebangs + - id: check-symlinks + - id: check-case-conflict + - id: check-vcs-permalinks + - id: check-json + - id: pretty-format-json + args: [--autofix, --no-sort-keys, --no-ensure-ascii] + - id: mixed-line-ending + args: [--fix=lf] + - id: name-tests-test + args: [--pytest-test-first] + - id: no-commit-to-branch + - id: requirements-txt-fixer + - id: fix-byte-order-marker + - repo: https://github.com/asottile/pyupgrade + rev: v3.6.0 + hooks: + - id: pyupgrade + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black diff --git a/ci/build_nginx_opentracing_module.sh b/ci/build_nginx_opentracing_module.sh index f3f41266..aba7d7e5 100755 --- a/ci/build_nginx_opentracing_module.sh +++ b/ci/build_nginx_opentracing_module.sh @@ -12,4 +12,3 @@ cd nginx-release-${NGINX_VERSION} --with-debug \ --add-dynamic-module="${SRC_DIR}/opentracing" make VERBOSE=1 - diff --git a/ci/install_gcc4.8.sh b/ci/install_gcc4.8.sh index a27658db..bcbb39c1 100755 --- a/ci/install_gcc4.8.sh +++ b/ci/install_gcc4.8.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -apt-get update +apt-get update apt-get install --no-install-recommends --no-install-suggests -y \ software-properties-common add-apt-repository -y ppa:ubuntu-toolchain-r/test diff --git a/ci/release.sh b/ci/release.sh index 2f3231d5..6b7d0c36 100755 --- a/ci/release.sh +++ b/ci/release.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -apt-get update +apt-get update apt-get install --no-install-recommends --no-install-suggests -y \ wget \ unzip diff --git a/ci/run_nginx_ot_docker.sh b/ci/run_nginx_ot_docker.sh index 40181f4e..ba9f5ad0 100755 --- a/ci/run_nginx_ot_docker.sh +++ b/ci/run_nginx_ot_docker.sh @@ -12,4 +12,3 @@ if [ -n "$1" ]; then else docker run -v "$PWD":/src -w /src --privileged -it "$BUILD_IMAGE" /bin/bash -l fi - diff --git a/ci/setup_build_environment.sh b/ci/setup_build_environment.sh index 3503904b..49d4602b 100755 --- a/ci/setup_build_environment.sh +++ b/ci/setup_build_environment.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -apt-get update +apt-get update apt-get install --no-install-recommends --no-install-suggests -y \ build-essential \ cmake \ diff --git a/doc/Tutorial.md b/doc/Tutorial.md index cbce53bf..7913b052 100644 --- a/doc/Tutorial.md +++ b/doc/Tutorial.md @@ -4,7 +4,7 @@ Virtual Zoo In this tutorial, we'll enable an application for OpenTracing and use the trace data to guide us in making several optimizations. The application we're going to work with is a virtual zoo. Users admit new animals into the zoo by -filling out a form and submitting a profile picture. +filling out a form and submitting a profile picture. ![alt text](data/Admit.png "Admit New Animal") @@ -16,7 +16,7 @@ page with thumbnail pictures of all the animals organized into a table. The application uses NGINX to load-balance between multiple Node.js backends and serve static content. When processing a new admittance, a Node.js server writes the profile data to a shared sqlite database and resizes the profile -picture to a common thumbnail size. Here's what the NGINX configuration looks +picture to a common thumbnail size. Here's what the NGINX configuration looks like: ``` @@ -65,18 +65,18 @@ http { proxy_pass http://backend; opentracing_propagate_context; - + # Redirect to the spash page if the animal was successfully admitted. proxy_intercept_errors on; error_page 301 302 303 =200 /; } location / { - root www; + root www; } location ~ \.jpg$ { - # Set the root directory to where the Node.js backend uploads profile + # Set the root directory to where the Node.js backend uploads profile # images. include image_params; } @@ -104,7 +104,7 @@ uses the name of the first location as the name for the top-level span. We can change this behavior by using the directives `opentracing_operation_name` and `opentracing_location_operation_name` to set the names of the request and location block spans respectively. For -example, by adding +example, by adding ``` http { ... @@ -125,7 +125,7 @@ OpenTracing. Enabling OpenTracing for the Backend --------------------------------- -When using express with Node.js, OpenTracing can be turn on +When using express with Node.js, OpenTracing can be turn on by adding tracing middleware to the express app: ```JavaScript const app = express(); @@ -157,7 +157,7 @@ of its contents to the Node.js servers. Updating NGINX's configuration file to d client_max_body_size 1000M; proxy_pass_request_headers on; - proxy_set_header admit-profile-pic $request_body_file; + proxy_set_header admit-profile-pic $request_body_file; proxy_set_body off; proxy_redirect off; ... diff --git a/example/php/jaeger/app.php b/example/php/jaeger/app.php index 0d967f87..f8f786ef 100644 --- a/example/php/jaeger/app.php +++ b/example/php/jaeger/app.php @@ -21,7 +21,7 @@ function getallheaders() { $config = new Config( [ 'sampler' => [ - 'type' => 'const', + 'type' => 'const', 'param' => true, ], 'local_agent' => [ diff --git a/example/php/jaeger/composer.json b/example/php/jaeger/composer.json index 6163ec21..9f9564bc 100644 --- a/example/php/jaeger/composer.json +++ b/example/php/jaeger/composer.json @@ -1,7 +1,7 @@ { "minimum-stability": "dev", - "require": { + "require": { "jonahgeorge/jaeger-client-php": "1.4.3", - "opentracing/opentracing":"1.0.2" + "opentracing/opentracing": "1.0.2" } } diff --git a/example/trivial/datadog/Dockerfile b/example/trivial/datadog/Dockerfile index ec78a492..569cf88c 100644 --- a/example/trivial/datadog/Dockerfile +++ b/example/trivial/datadog/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:18.04 # 17.10 doesn't come with latest golang. WORKDIR /app diff --git a/example/trivial/datadog/README.md b/example/trivial/datadog/README.md index c8cc680b..6bbda63a 100644 --- a/example/trivial/datadog/README.md +++ b/example/trivial/datadog/README.md @@ -1,6 +1,6 @@ A minimal OpenTracing example demonstrating usage of the nginx-opentracing docker image with Datadog. It features Nginx as a reverse-proxy in front a Go -server. +server. Before running create an account at https://www.datadoghq.com and enter your API key into docker-compose.yaml diff --git a/example/trivial/datadog/datadog-config.json b/example/trivial/datadog/datadog-config.json index 7c84dd6a..b3b92327 100644 --- a/example/trivial/datadog/datadog-config.json +++ b/example/trivial/datadog/datadog-config.json @@ -3,4 +3,4 @@ "operation_name_override": "nginx.handle", "agent_host": "dd-agent", "agent_port": 8126 -} \ No newline at end of file +} diff --git a/example/trivial/datadog/docker-compose.yaml b/example/trivial/datadog/docker-compose.yaml index 556efcb9..10929f87 100644 --- a/example/trivial/datadog/docker-compose.yaml +++ b/example/trivial/datadog/docker-compose.yaml @@ -27,7 +27,7 @@ services: - "9001" ports: - "9001:9001" - command: + command: - /app/server dd-agent: diff --git a/example/trivial/jaeger/docker-compose.yaml b/example/trivial/jaeger/docker-compose.yaml index 7840c54c..24a95a8b 100644 --- a/example/trivial/jaeger/docker-compose.yaml +++ b/example/trivial/jaeger/docker-compose.yaml @@ -27,7 +27,7 @@ services: - "9001" ports: - "9001:9001" - command: + command: - /app/server - -collector_host - jaeger diff --git a/example/trivial/ubuntu-x86_64/Dockerfile-nginx b/example/trivial/ubuntu-x86_64/Dockerfile-nginx index 0ad31828..8aef99f2 100644 --- a/example/trivial/ubuntu-x86_64/Dockerfile-nginx +++ b/example/trivial/ubuntu-x86_64/Dockerfile-nginx @@ -1,7 +1,7 @@ FROM ubuntu:18.04 RUN set -x \ -# Install package dependencies +# Install package dependencies && apt-get update \ && apt-get install --no-install-recommends --no-install-suggests -y \ wget \ diff --git a/example/trivial/ubuntu-x86_64/docker-compose.yaml b/example/trivial/ubuntu-x86_64/docker-compose.yaml index d731658e..575789bf 100644 --- a/example/trivial/ubuntu-x86_64/docker-compose.yaml +++ b/example/trivial/ubuntu-x86_64/docker-compose.yaml @@ -29,7 +29,7 @@ services: - "9001" ports: - "9001:9001" - command: + command: - /app/server - -collector_host - jaeger diff --git a/example/trivial/zipkin/docker-compose.yaml b/example/trivial/zipkin/docker-compose.yaml index 11590a4d..b2c099d5 100644 --- a/example/trivial/zipkin/docker-compose.yaml +++ b/example/trivial/zipkin/docker-compose.yaml @@ -27,7 +27,7 @@ services: - "9001" ports: - "9001:9001" - command: + command: - /app/server - -collector_host - zipkin diff --git a/example/zoo/docker-compose.yaml b/example/zoo/docker-compose.yaml index 7914b10f..0018fdab 100644 --- a/example/zoo/docker-compose.yaml +++ b/example/zoo/docker-compose.yaml @@ -46,7 +46,7 @@ services: entrypoint: ./start-backend.sh volumes: - image-volume: + image-volume: tmp-volume: networks: diff --git a/example/zoo/nginx.conf b/example/zoo/nginx.conf index d3acd95b..7d17bf99 100644 --- a/example/zoo/nginx.conf +++ b/example/zoo/nginx.conf @@ -48,7 +48,7 @@ http { client_body_buffer_size 128K; client_max_body_size 1000M; - proxy_set_header admit-profile-pic $request_body_file; + proxy_set_header admit-profile-pic $request_body_file; proxy_set_body off; proxy_redirect off; @@ -62,7 +62,7 @@ http { opentracing_operation_name $request_uri; opentracing_trace_locations off; - root /app/www; + root /app/www; } location ~ \.jpg$ { diff --git a/example/zoo/node/views/animal.pug b/example/zoo/node/views/animal.pug index 84fb8956..1cd55e77 100644 --- a/example/zoo/node/views/animal.pug +++ b/example/zoo/node/views/animal.pug @@ -2,7 +2,7 @@ html head title= title body - table + table tr td(align='center', valign='center') dl @@ -11,4 +11,3 @@ html dd= description br | - diff --git a/example/zoo/node/views/index.pug b/example/zoo/node/views/index.pug index f0d02fd8..f91f054a 100644 --- a/example/zoo/node/views/index.pug +++ b/example/zoo/node/views/index.pug @@ -6,11 +6,10 @@ html each row in animals tr each animal in row - td(align='center', valign='center') + td(align='center', valign='center') a(href=animal.profile) img(src=animal.thumbnail_pic) br | #{animal.name} a(href="/admit.html") | New Admittance - diff --git a/opentracing/src/ngx_http_opentracing_module.cpp b/opentracing/src/ngx_http_opentracing_module.cpp index 8b5f503e..7d6f1867 100644 --- a/opentracing/src/ngx_http_opentracing_module.cpp +++ b/opentracing/src/ngx_http_opentracing_module.cpp @@ -38,7 +38,7 @@ using namespace ngx_opentracing; // https://github.com/opentracing/lua-bridge-tracer/issues/6 // // As a solution, we use a plain pointer and never free and instead rely on the OS to clean up the -// resources when the process exits. This is a pattern proposed on +// resources when the process exits. This is a pattern proposed on // https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables static const opentracing::DynamicTracingLibraryHandle* opentracing_library_handle; @@ -328,7 +328,7 @@ static char *merge_opentracing_loc_conf(ngx_conf_t *, void *parent, } *tag = kv.second; - } + } else { opentracing_tag_t* tag = (opentracing_tag_t*)conf->tags->elts; tag[index] = kv.second; diff --git a/test/environment/grpc/app.py b/test/environment/grpc/app.py index c4f12276..d31113fd 100644 --- a/test/environment/grpc/app.py +++ b/test/environment/grpc/app.py @@ -1,25 +1,28 @@ -from concurrent import futures -import sys import signal +import sys import time -import grpc +from concurrent import futures + import app_pb2 as app_messages import app_pb2_grpc as app_service +import grpc _ONE_DAY_IN_SECONDS = 60 * 60 * 24 + class AppService(app_service.AppServicer): def CheckTraceHeader(self, request, context): metadata = dict(context.invocation_metadata()) - if 'x-ot-span-context' not in metadata: + if "x-ot-span-context" not in metadata: context.set_code(grpc.StatusCode.INTERNAL) context.set_details("Metadatum x-ot-span-context not found") return app_messages.Empty() + def serve(): server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) app_service.add_AppServicer_to_server(AppService(), server) - server.add_insecure_port('0.0.0.0:50051') + server.add_insecure_port("0.0.0.0:50051") server.start() signal.signal(signal.SIGTERM, signal.getsignal(signal.SIGINT)) try: @@ -28,5 +31,6 @@ def serve(): except KeyboardInterrupt: server.stop(0) -if __name__ == '__main__': + +if __name__ == "__main__": serve() diff --git a/test/environment/grpc/requirements.txt b/test/environment/grpc/requirements.txt index 168e8176..c4b59b67 100644 --- a/test/environment/grpc/requirements.txt +++ b/test/environment/grpc/requirements.txt @@ -1,5 +1,5 @@ -grpcio-tools==1.55.0 grpcio==1.55.0 -grpcio-reflection==1.55.0 grpcio-health-checking==1.55.0 +grpcio-reflection==1.55.0 grpcio-testing==1.55.0 +grpcio-tools==1.55.0 diff --git a/test/environment/logs/debug.log b/test/environment/logs/debug.log old mode 100755 new mode 100644 index 8b137891..e69de29b --- a/test/environment/logs/debug.log +++ b/test/environment/logs/debug.log @@ -1 +0,0 @@ - diff --git a/test/environment/logs/error.log b/test/environment/logs/error.log old mode 100755 new mode 100644 index 8b137891..e69de29b --- a/test/environment/logs/error.log +++ b/test/environment/logs/error.log @@ -1 +0,0 @@ - diff --git a/test/environment/tracer-config.json b/test/environment/tracer-config.json index 20ad1b54..cac086e3 100644 --- a/test/environment/tracer-config.json +++ b/test/environment/tracer-config.json @@ -1,3 +1,3 @@ { - "output_file":"/trace.json" + "output_file": "/trace.json" } diff --git a/test/environment/traces/nginx.json b/test/environment/traces/nginx.json index 0637a088..fe51488c 100644 --- a/test/environment/traces/nginx.json +++ b/test/environment/traces/nginx.json @@ -1 +1 @@ -[] \ No newline at end of file +[] diff --git a/test/requirements.ci.txt b/test/requirements.ci.txt index 00fb22c3..932863f9 100644 --- a/test/requirements.ci.txt +++ b/test/requirements.ci.txt @@ -1,6 +1,6 @@ docker==6.1.3 -requests==2.31.0 -websocket-client==1.6.0 -urllib3==2.0.3 grpcio==1.55.0 protobuf==4.23.3 +requests==2.31.0 +urllib3==2.0.3 +websocket-client==1.6.0