diff --git a/.circleci/README.md b/.circleci/README.md deleted file mode 100644 index 1ba5cfcd..00000000 --- a/.circleci/README.md +++ /dev/null @@ -1,24 +0,0 @@ -Circle CI -========= -This directory contains the [configuration](config.yml) for this project's -[continuous integration setup][4]. - -The following jobs are defined: -- `format` checks that the C++ source is formatted per `clang-format-14 - --style=file`. -- `shellcheck` checks that [shellcheck][5] accepts all of the scripts in - [bin/](../bin). -- `build-bazel` builds the library using [bazel][1]. - - Based on the `toolchain` parameter, the build will use either g++ or - clang++. -- `test-cmake` builds the library using [CMake][2] and runs the unit tests. - - Based on the `toolchain` parameter, the build will use either g++ or - clang++. - - Based on the `sanitize` parameter, the build might use [AddressSanitizer and - UndefinedBehaviorSanitizer][3]. - -[1]: https://bazel.build/ -[2]: https://cmake.org/ -[3]: https://github.com/google/sanitizers -[4]: https://app.circleci.com/pipelines/github/DataDog/dd-trace-cpp -[5]: https://www.shellcheck.net/ diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index ab2395c1..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,278 +0,0 @@ -version: 2.1 - -main_branch_only: &main_branch_only - requires: - - build-bazel - - build-and-test-cmake - - build-and-test-windows-bazel - - build-and-test-windows-cmake - filters: - branches: - only: - - main - -orbs: - codecov: codecov/codecov@4.0.1 - -executors: - docker-amd64: - docker: - - image: "datadog/docker-library:dd-trace-cpp-ci" - resource_class: xlarge - docker-arm64: - docker: - - image: "datadog/docker-library:dd-trace-cpp-ci" - resource_class: arm.xlarge - -commands: - run_timeout: - description: "Run a command for a specified duration" - parameters: - command: - type: string - duration: - type: string - description: - type: string - steps: - - run: - name: << parameters.description >> - command: | - set +e - timeout << parameters.duration >> << parameters.command >> - # `124` is the exit code timeout returns when the duration is reached - if [[ $? -eq 124 ]]; then - exit 0 - fi - -jobs: - format: - docker: - - image: "datadog/docker-library:dd-trace-cpp-ci" - resource_class: small - steps: - - checkout - - run: bin/check-format - - shellcheck: - docker: - - image: "datadog/docker-library:dd-trace-cpp-ci" - resource_class: small - steps: - - checkout - - run: find bin/ -executable -type f -print0 | xargs -0 shellcheck - - build-bazel: - parameters: - toolchain: - type: string - arch: - type: string - bazelrc: - type: string - executor: docker-<< parameters.arch >> - environment: - MAKE_JOB_COUNT: 8 - steps: - - checkout - - run: bin/with-toolchain << parameters.toolchain >> bazelisk --bazelrc=<< parameters.bazelrc >> build --jobs $MAKE_JOB_COUNT dd_trace_cpp - - build-and-test-windows-bazel: - parameters: - # `bazelrc` is the path to the .bazelrc file to use in the build/test. - # The repository has two flavors: one that uses Abseil types (for use with - # Envoy), and one that uses std types. - bazelrc: - type: string - machine: - image: "windows-server-2022-gui:current" - resource_class: windows.medium - shell: powershell.exe -ExecutionPolicy Bypass - environment: - MAKE_JOB_COUNT: 4 - steps: - - checkout - - run: choco install -y bazelisk - - run: bazelisk.exe --bazelrc=<< parameters.bazelrc >> build --jobs $env:MAKE_JOB_COUNT dd_trace_cpp - - build-and-test-windows-cmake: - parameters: - arch: - type: string - machine: - image: "windows-server-2022-gui:current" - shell: powershell.exe -ExecutionPolicy Bypass - resource_class: "windows.large" - environment: - MAKE_JOB_COUNT: 8 - steps: - - checkout - - run: - name: Install dependencies - command: | - choco install -y cmake --version=3.31.6 --accept-license --installargs 'ADD_CMAKE_TO_PATH=System' - choco install -y ninja - - run: - name: Building - command: | - & 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\Tools\\Launch-VsDevShell.ps1' -arch << parameters.arch >> - cmake --preset=ci-windows -B build -DCMAKE_BUILD_TYPE=Debug . - cmake --build build -j $env:MAKE_JOB_COUNT -v - - run: - name: Testing - command: | - & 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\Tools\\Launch-VsDevShell.ps1' -arch << parameters.arch >> - .\build\test\tests.exe -r junit -o report.xml - - run: - name: Upload test report to Datadog - when: always - command: | - Invoke-WebRequest -Uri "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_win-x64" -OutFile "datadog-ci.exe" - Start-Process -FilePath "./datadog-ci.exe" -ArgumentList "upload --service dd-trace-cpp report.xml" - - store_test_results: - path: report.xml - - build-and-test-cmake: - parameters: - toolchain: - type: string - arch: - type: string - executor: docker-<< parameters.arch >> - environment: - MAKE_JOB_COUNT: 8 - # See . - ASAN_OPTIONS: alloc_dealloc_mismatch=0 - steps: - - checkout - - run: bin/with-toolchain << parameters.toolchain >> cmake . -B .build -DCMAKE_BUILD_TYPE=Debug -DDD_TRACE_BUILD_TESTING=1 - - run: cmake --build .build -j ${MAKE_JOB_COUNT} -v - - run: cd .build && test/tests -r junit -o report.xml - - run: - name: Upload test report to Datadog - when: always - command: | - if [[ "<< parameters.arch >>" == "amd64" ]]; then - curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64" --output "/usr/local/bin/datadog-ci" && chmod +x /usr/local/bin/datadog-ci - else - curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-arm64" --output "/usr/local/bin/datadog-ci" && chmod +x /usr/local/bin/datadog-ci - fi - - datadog-ci junit upload --service dd-trace-cpp .build/report.xml - - store_test_results: - path: .build/report.xml - - coverage: - docker: - - image: "datadog/docker-library:dd-trace-cpp-ci" - resource_class: xlarge - environment: - MAKE_JOB_COUNT: 8 - steps: - - checkout - - run: bin/test --coverage --verbose - - codecov/upload: - file: .coverage/filtered.info - upload_args: --disable-search - - # Copy-pasta from dd-trace-java. Thank you <3 - system-tests: - parameters: - systemTestsCommit: - type: string - default: main - machine: - image: ubuntu-2404:2024.05.1 - resource_class: large - steps: - - run: - name: Install python 3.12 - command: | - sudo apt-get install -y python3.12-full python3.12-dev python3.12-venv - echo 'export PATH="$HOME/.local/bin:$PATH"' >>"$BASH_ENV" - - run: - name: Clone system-tests - command: | - git init system-tests - cd system-tests - git remote add origin https://github.com/DataDog/system-tests.git - git fetch origin << parameters.systemTestsCommit >> - git reset --hard FETCH_HEAD - - run: - name: Install requirements - command: | - cd system-tests - python3 --version - python3 -m pip install wheel - python3 -m pip install -r requirements.txt - sudo ln -sf /usr/bin/python3 /usr/bin/python - - run: - name: Run Parametric tests - environment: - TEST_LIBRARY: cpp - DD_TRACE_CPP_COMMIT: << pipeline.git.revision >> - command: | - echo "https://github.com/DataDog/dd-trace-cpp@$DD_TRACE_CPP_COMMIT" > ~/project/system-tests/binaries/cpp-load-from-git - cd system-tests && ./build.sh -i runner && ./run.sh PARAMETRIC --log-cli-level=DEBUG - - run: - name: Collect artifacts - command: tar -cvzf logs_cpp_parametric_dev.tar.gz -C system-tests logs_parametric - - store_test_results: - path: system-tests/logs_parametric - - store_artifacts: - path: logs_cpp_parametric_dev.tar.gz - - fuzz-testing: - docker: - - image: "datadog/docker-library:dd-trace-cpp-ci" - resource_class: xlarge - environment: - MAKE_JOB_COUNT: 8 - steps: - - checkout - - run: bin/with-toolchain llvm cmake . -B .build -DCMAKE_BUILD_TYPE=Debug -DDD_TRACE_BUILD_FUZZERS=1 -DDD_TRACE_ENABLE_SANITIZE=1 - - run: cmake --build .build -j ${MAKE_JOB_COUNT} --target dd_trace_cpp-fuzzers - - run_timeout: - description: Run W3C propagation fuzzer - command: ./.build/fuzz/w3c-propagation/w3c-propagation-fuzz - duration: 5m - - run_timeout: - description: Run Base64 fuzzer - command: timeout 5m ./.build/fuzz/base64/base64-fuzz - duration: 5m - - run_timeout: - description: Run Remote Configuration fuzzer - command: timeout 5m ./.build/fuzz/remote-configuration/remote-config-fuzz - duration: 5m - -workflows: - pull-request: - jobs: - - format - - shellcheck - - build-and-test-cmake: - matrix: - parameters: - toolchain: ["gnu", "llvm"] - arch: ["amd64", "arm64"] - - build-bazel: - matrix: - parameters: - toolchain: ["gnu", "llvm"] - arch: ["amd64", "arm64"] - bazelrc: [".bazelrc.absl", ".bazelrc.std"] - - build-and-test-windows-cmake: - matrix: - parameters: - arch: ["amd64"] - - build-and-test-windows-bazel: - matrix: - parameters: - bazelrc: [".bazelrc.absl", ".bazelrc.std"] - - coverage: - requires: - - build-and-test-cmake - - system-tests: - <<: *main_branch_only - - fuzz-testing: - <<: *main_branch_only diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 00000000..a9de41f9 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,170 @@ +name: "Development" +on: [pull_request, workflow_dispatch, workflow_call] + +jobs: + format: + runs-on: ubuntu-22.04 + container: + image: datadog/docker-library:dd-trace-cpp-ci + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Check format + run: bin/check-format + - name: Shellcheck + run: find bin/ -executable -type f -print0 | xargs -0 shellcheck + + build-linux-cmake: + strategy: + fail-fast: false + matrix: + toolchain: ["gnu", "llvm"] + arch: ["arm64", "x64"] + include: + - runner: ubuntu-22.04-arm + arch: arm64 + docker-arch: arm64 + - runner: ubuntu-22.04 + arch: x64 + docker-arch: amd64 + needs: format + runs-on: ${{ matrix.runner }} + container: + image: datadog/docker-library:dd-trace-cpp-ci-91c12776-${{matrix.docker-arch}} + environment: + name: dev + permissions: + contents: read + packages: read + env: + BUILD_DIR: .build + DD_API_KEY: ${{ secrets.DD_CI_VIS_API_KEY }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Configure + run: bin/with-toolchain ${{ matrix.toolchain }} cmake . -B .build -DCMAKE_BUILD_TYPE=Debug -DDD_TRACE_BUILD_TESTING=1 + - name: Build + run: cmake --build ${BUILD_DIR} -j -v + - name: Test + run: cd ${BUILD_DIR} && test/tests -r junit -o report.xml + - name: Upload test report to Datadog + run: | + curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-${{ matrix.arch }}" --output "/usr/local/bin/datadog-ci" && chmod +x /usr/local/bin/datadog-ci + datadog-ci junit upload --service dd-trace-cpp .build/report.xml + + build-linux-bazel: + needs: format + strategy: + fail-fast: false + matrix: + toolchain: ["gnu", "llvm"] + arch: ["arm64", "x64"] + bazelrc: [".bazelrc.absl", ".bazelrc.std"] + include: + - runner: ubuntu-22.04-arm + arch: arm64 + docker-arch: arm64 + - runner: ubuntu-22.04 + arch: x64 + docker-arch: amd64 + runs-on: ${{ matrix.runner }} + container: + image: datadog/docker-library:dd-trace-cpp-ci-91c12776-${{matrix.docker-arch}} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Build + run: bin/with-toolchain ${{ matrix.toolchain }} bazelisk --bazelrc=${{ matrix.bazelrc }} build dd_trace_cpp + + build-windows-bazel: + needs: format + runs-on: windows-2022 + defaults: + run: + shell: powershell + strategy: + matrix: + bazelrc: [".bazelrc.absl", ".bazelrc.std"] + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Install Dependency Manager (scoop) + run: | + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression + Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH + - name: Install Dependencies + run: scoop install main/cmake@4.0.1 main/ninja main/bazelisk + - name: Build + run: bazelisk.exe --bazelrc=${{ matrix.bazelrc }} build dd_trace_cpp + + build-windows-cmake: + needs: format + strategy: + fail-fast: false + matrix: + arch: ["arm64", "amd64"] + include: + - runner: windows-11-arm + arch: arm64 + - runner: windows-2022 + arch: amd64 + runs-on: ${{ matrix.runner }} + defaults: + run: + shell: powershell + environment: + name: dev + permissions: + contents: read + packages: read + env: + DD_API_KEY: ${{ secrets.DD_CI_VIS_API_KEY }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Install Dependency Manager (scoop) + run: | + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression + Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH + - name: Install Dependencies + run: scoop install main/cmake@4.0.1 main/ninja + - name: Build + run: | + & 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\Tools\\Launch-VsDevShell.ps1' -arch ${{ matrix.arch }} + cmake --preset=ci-windows -B build -DCMAKE_BUILD_TYPE=Debug . + cmake --build build -j $env:MAKE_JOB_COUNT -v + - name: Test + run: | + & 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\Tools\\Launch-VsDevShell.ps1' -arch ${{ matrix.arch }} + .\build\test\tests.exe -r junit -o report.xml + - name: Upload test report to Datadog + run: | + Invoke-WebRequest -Uri "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_win-x64" -OutFile "datadog-ci.exe" + ./datadog-ci.exe junit upload --service dd-trace-cpp report.xml + + coverage: + needs: build-linux-cmake + runs-on: ubuntu-22.04-arm + container: + image: datadog/docker-library:dd-trace-cpp-ci-91c12776-arm64 + environment: + name: dev + permissions: + contents: read + packages: read + env: + DD_API_KEY: ${{ secrets.DD_CI_VIS_API_KEY }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - run: bin/test --coverage --verbose + - name: Report Datadog coverage + run: | + curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-arm64" --output "/usr/local/bin/datadog-ci" && chmod +x /usr/local/bin/datadog-ci + cd .coverage + cp filtered.info lcov.info + datadog-ci coverage upload lcov.info + - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 + with: + fail_ci_if_error: true + files: .coverage/filtered.info + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..9df2a241 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,59 @@ +name: "Main" +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + call-dev-workflow: + uses: ./.github/workflows/dev.yml + # - name: Upload artifact + # uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + # with: + # name: binaries + # path: .musl-build/ngx_http_datadog_module.so + + system-tests: + uses: DataDog/system-tests/.github/workflows/system-tests.yml@main + secrets: inherit + permissions: + contents: read + packages: write + with: + library: cpp + binaries_artifact: binaries + desired_execution_time: 300 # 5 minutes + scenarios_groups: appsec + scenarios: DEFAULT + excluded_scenarios: INTEGRATIONS # no test activated, and long warm-up + skip_empty_scenarios: true + + # Ensure the main job is run to completion + check-system-tests: + needs: system-tests + name: Check system tests success + runs-on: ubuntu-latest + steps: + - run: exit 0 + + fuzz-testing: + needs: call-dev-workflow + runs-on: ubuntu-22.04-arm + container: + image: datadog/docker-library:dd-trace-cpp-ci-91c12776-arm64 + env: + DURATION_SEC: 300 # 5min + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Configure + run: bin/with-toolchain llvm cmake . -B .build -DCMAKE_BUILD_TYPE=Debug -DDD_TRACE_BUILD_FUZZERS=1 -DDD_TRACE_ENABLE_SANITIZE=1 + - name: Build + run: cmake --build .build -j --target dd_trace_cpp-fuzzers + - name: Run W3C propagation fuzzer + run: ./.build/fuzz/w3c-propagation/w3c-propagation-fuzz -max_total_time=${DURATION_SEC} + - name: Run Base64 fuzzer + run: ./.build/fuzz/base64/base64-fuzz -max_total_time=${DURATION_SEC} + - name: Run Remote Configuration fuzzer + run: ./.build/fuzz/remote-configuration/remote-config-fuzz -max_total_time=${DURATION_SEC} + diff --git a/src/datadog/telemetry_metrics.cpp b/src/datadog/telemetry_metrics.cpp index ebda23b3..485de8e1 100644 --- a/src/datadog/telemetry_metrics.cpp +++ b/src/datadog/telemetry_metrics.cpp @@ -56,8 +56,8 @@ const telemetry::Counter extracted = {"context_header_style.extracted", "tracers", true}; const telemetry::Counter truncated = {"context_header.truncated", "tracers", true}; -const telemetry::Counter malformed = {"context_header_style.malformed", "tracers", - true}; +const telemetry::Counter malformed = {"context_header_style.malformed", + "tracers", true}; } // namespace trace_context } // namespace tracer