diff --git a/.github/actions/coverage/action.yml b/.github/actions/coverage/action.yml index 914b9bbcb45..a143978b017 100644 --- a/.github/actions/coverage/action.yml +++ b/.github/actions/coverage/action.yml @@ -1,5 +1,5 @@ name: coverage -description: Verify coverage output and upload it to Codecov. +description: Verify coverage output and upload it to Codecov and Datadog. inputs: flags: @@ -9,6 +9,9 @@ inputs: description: "Coverage report directory (defaults to 'coverage')" required: false default: coverage + dd_api_key: + description: "Datadog API key for coverage upload" + required: true runs: using: composite @@ -21,3 +24,12 @@ runs: uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: flags: ${{ inputs.flags }} + + - name: Upload coverage to Datadog + if: always() + continue-on-error: true + uses: DataDog/coverage-upload-github-action@d2cf302a39c05e0ad22063360a2bf6ce0cc4906c # v1 + with: + api_key: ${{ inputs.dd_api_key }} + files: . + flags: ${{ inputs.flags }} diff --git a/.github/actions/instrumentations/test/action.yml b/.github/actions/instrumentations/test/action.yml index 0e3a97b007a..c39d5807841 100644 --- a/.github/actions/instrumentations/test/action.yml +++ b/.github/actions/instrumentations/test/action.yml @@ -17,6 +17,7 @@ runs: - uses: ./.github/actions/coverage with: flags: instrumentations-${{ github.job }} + dd_api_key: ${{ inputs.dd_api_key }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/actions/plugins/test-and-upstream/action.yml b/.github/actions/plugins/test-and-upstream/action.yml index 28df1e9ad3f..8cec126b915 100644 --- a/.github/actions/plugins/test-and-upstream/action.yml +++ b/.github/actions/plugins/test-and-upstream/action.yml @@ -22,6 +22,7 @@ runs: - uses: ./.github/actions/coverage with: flags: plugins-test-and-upstream-${{ github.job }} + dd_api_key: ${{ inputs.dd_api_key }} - if: always() uses: ./.github/actions/testagent/logs with: diff --git a/.github/actions/plugins/test/action.yml b/.github/actions/plugins/test/action.yml index a5527693eea..92637478ea3 100644 --- a/.github/actions/plugins/test/action.yml +++ b/.github/actions/plugins/test/action.yml @@ -18,6 +18,7 @@ runs: - uses: ./.github/actions/coverage with: flags: plugins-${{ github.job }} + dd_api_key: ${{ inputs.dd_api_key }} - if: always() uses: ./.github/actions/testagent/logs with: diff --git a/.github/actions/plugins/upstream/action.yml b/.github/actions/plugins/upstream/action.yml index 862af3377c1..77afcd88cf4 100644 --- a/.github/actions/plugins/upstream/action.yml +++ b/.github/actions/plugins/upstream/action.yml @@ -18,6 +18,7 @@ runs: - uses: ./.github/actions/coverage with: flags: plugins-upstream-${{ github.job }} + dd_api_key: ${{ inputs.dd_api_key }} - if: always() uses: ./.github/actions/testagent/logs with: diff --git a/.github/dependabot.yml b/.github/dependabot.yml.disabled similarity index 100% rename from .github/dependabot.yml rename to .github/dependabot.yml.disabled diff --git a/.github/workflows/aiguard.yml b/.github/workflows/aiguard.yml index bf37e560df0..4c6352dedcd 100644 --- a/.github/workflows/aiguard.yml +++ b/.github/workflows/aiguard.yml @@ -26,6 +26,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: aiguard-macos + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -48,6 +49,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: aiguard-ubuntu + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -66,6 +68,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: aiguard-windows + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/workflows/apm-capabilities.yml b/.github/workflows/apm-capabilities.yml index 1cd1024d10e..592ec3f48f4 100644 --- a/.github/workflows/apm-capabilities.yml +++ b/.github/workflows/apm-capabilities.yml @@ -32,6 +32,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-capabilities-tracing-macos + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -53,6 +54,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-capabilities-tracing-ubuntu + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -70,6 +72,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-capabilities-tracing-windows + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/workflows/apm-integrations.yml b/.github/workflows/apm-integrations.yml index 18f28026c13..0d70eda4fe5 100644 --- a/.github/workflows/apm-integrations.yml +++ b/.github/workflows/apm-integrations.yml @@ -80,6 +80,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-aerospike-${{ matrix.node-version }}-${{ matrix.range_clean }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -222,6 +223,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-child-process + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -290,6 +292,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-confluentinc-kafka-javascript-${{ matrix.node-version }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -351,6 +354,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-couchbase-${{ matrix.node-version }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -389,6 +393,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-dns + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -419,6 +424,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-elasticsearch + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -567,6 +573,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-http-${{ matrix.node-version }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -595,6 +602,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-http2 + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -646,6 +654,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-kafkajs-${{ matrix.node-version }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -897,6 +906,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-net + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -954,6 +964,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-next-${{ matrix.range_clean }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -1032,6 +1043,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-oracledb + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -1058,6 +1070,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-pino + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -1150,6 +1163,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-prisma-${{ matrix.node-version }}-${{ matrix.range_clean }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -1306,6 +1320,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-sharedb + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -1339,6 +1354,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: apm-integrations-tedious + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/workflows/appsec.yml b/.github/workflows/appsec.yml index 90f33890754..5f8da2c7f72 100644 --- a/.github/workflows/appsec.yml +++ b/.github/workflows/appsec.yml @@ -33,6 +33,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-macos + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -55,6 +56,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-ubuntu + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -73,6 +75,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-windows + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -104,6 +107,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-ldapjs + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -133,6 +137,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-postgres + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -162,6 +167,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-mysql + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -182,6 +188,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-express + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -202,6 +209,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-fastify + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -222,6 +230,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-graphql + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -248,6 +257,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-mongodb-core + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -274,6 +284,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-mongoose + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -297,6 +308,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-sourcing + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -357,6 +369,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-next-${{ matrix.version }}-${{ matrix.range_clean }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -377,6 +390,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-lodash + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -414,6 +428,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-passport + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -433,6 +448,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-template + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -453,6 +469,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-node-serialize + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -491,6 +508,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: appsec-kafka + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -507,7 +525,10 @@ jobs: - run: yarn test:appsec:plugins:ci - uses: ./.github/actions/node/latest - run: yarn test:appsec:plugins:ci - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + - uses: ./.github/actions/coverage + with: + flags: appsec-stripe + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/workflows/debugger.yml b/.github/workflows/debugger.yml index eafbaad62b3..a7c3766e8df 100644 --- a/.github/workflows/debugger.yml +++ b/.github/workflows/debugger.yml @@ -38,6 +38,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: debugger-ubuntu-${{ matrix.version }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/workflows/llmobs.yml b/.github/workflows/llmobs.yml index 0e7d3afe02b..1f8f911d130 100644 --- a/.github/workflows/llmobs.yml +++ b/.github/workflows/llmobs.yml @@ -42,6 +42,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: llmobs-sdk-${{ matrix.version }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -66,6 +67,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: llmobs-${{ github.job }} + dd_api_key: ${{ secrets.DD_API_KEY }} - if: always() uses: ./.github/actions/testagent/logs with: @@ -94,6 +96,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: llmobs-${{ github.job }} + dd_api_key: ${{ secrets.DD_API_KEY }} - if: always() uses: ./.github/actions/testagent/logs with: @@ -120,6 +123,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: llmobs-${{ github.job }} + dd_api_key: ${{ secrets.DD_API_KEY }} - if: always() uses: ./.github/actions/testagent/logs with: @@ -148,6 +152,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: llmobs-${{ github.job }} + dd_api_key: ${{ secrets.DD_API_KEY }} - if: always() uses: ./.github/actions/testagent/logs with: @@ -176,6 +181,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: llmobs-${{ github.job }} + dd_api_key: ${{ secrets.DD_API_KEY }} - if: always() uses: ./.github/actions/testagent/logs with: @@ -204,6 +210,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: llmobs-${{ github.job }} + dd_api_key: ${{ secrets.DD_API_KEY }} - if: always() uses: ./.github/actions/testagent/logs with: @@ -232,6 +239,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: llmobs-${{ github.job }} + dd_api_key: ${{ secrets.DD_API_KEY }} - if: always() uses: ./.github/actions/testagent/logs with: diff --git a/.github/workflows/openfeature.yml b/.github/workflows/openfeature.yml index 0b6bad6947a..a8b5e3aa669 100644 --- a/.github/workflows/openfeature.yml +++ b/.github/workflows/openfeature.yml @@ -36,6 +36,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: openfeature-unit-${{ matrix.version }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/workflows/platform.yml b/.github/workflows/platform.yml index 500c8046d24..33893761c83 100644 --- a/.github/workflows/platform.yml +++ b/.github/workflows/platform.yml @@ -88,6 +88,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: platform-core + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -115,6 +116,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: platform-esbuild + dd_api_key: ${{ secrets.DD_API_KEY }} instrumentation-bluebird: runs-on: ubuntu-latest @@ -240,6 +242,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: instrumentations-${{ github.job }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -420,6 +423,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: platform-instrumentations-misc + dd_api_key: ${{ secrets.DD_API_KEY }} - if: always() uses: ./.github/actions/testagent/logs with: @@ -465,6 +469,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: platform-unit-guardrails + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -523,6 +528,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: platform-shimmer + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/workflows/profiling.yml b/.github/workflows/profiling.yml index 182588fd949..90e53835858 100644 --- a/.github/workflows/profiling.yml +++ b/.github/workflows/profiling.yml @@ -34,6 +34,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: profiling-macos + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -60,6 +61,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: profiling-ubuntu + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -79,6 +81,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: profiling-windows + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.github/workflows/serverless.yml b/.github/workflows/serverless.yml index ca666e1e28c..18ed56e1fab 100644 --- a/.github/workflows/serverless.yml +++ b/.github/workflows/serverless.yml @@ -43,6 +43,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: serverless-lambda + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -119,6 +120,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: serverless-aws-sdk-${{ matrix.node-version }}-${{ matrix.spec }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: @@ -220,6 +222,7 @@ jobs: - uses: ./.github/actions/coverage with: flags: serverless-azure-functions-${{ matrix.spec }} + dd_api_key: ${{ secrets.DD_API_KEY }} - uses: ./.github/actions/push_to_test_optimization if: "!cancelled()" with: diff --git a/.gitignore b/.gitignore index 5fa33334899..01f82f977cf 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,9 @@ typings/ # Output of tap .tap/* +# JUnit artifacts emitted by local/agent CI-style Mocha runs +node-*-junit.xml + ### VSCode ### .vscode/* diff --git a/.gitlab/one-pipeline.locked.yml b/.gitlab/one-pipeline.locked.yml index 3e1f1a6259a..d4f90914ed1 100644 --- a/.gitlab/one-pipeline.locked.yml +++ b/.gitlab/one-pipeline.locked.yml @@ -1,4 +1,4 @@ # DO NOT EDIT THIS FILE MANUALLY # This file is auto-generated by automation. include: - - remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/f14ac28614630d12bcfe6cba4fd8d72dce142c62ff0b053ba7c323622104ebd7/one-pipeline.yml + - remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/9cf7d7609ff62e4723c9cbc061ca2a25345ce5d6055b9acad9a13dbf736261f0/one-pipeline.yml diff --git a/integration-tests/helpers/index.js b/integration-tests/helpers/index.js index 141d68cb40e..33743387fbf 100644 --- a/integration-tests/helpers/index.js +++ b/integration-tests/helpers/index.js @@ -265,21 +265,25 @@ function spawnProcAndExpectExit (filename, options = {}, stdioHandler, stderrHan /** * Stop a process and wait for it to fully exit. * - * Sends `SIGTERM` first, waits up to `timeoutMs`, and escalates to `SIGKILL` if needed. + * Sends `signal` first, waits up to `timeoutMs`, and escalates to `SIGKILL` if needed. * * @param {childProcess.ChildProcess|undefined} proc - Process to stop. * @param {object} [options] - Stop options. + * @param {NodeJS.Signals} [options.signal='SIGTERM'] - Signal to send before escalating. * @param {number} [options.timeoutMs=defaultStopProcTimeoutMs] - Max wait per signal in milliseconds. * @returns {Promise} */ -async function stopProc (proc, { timeoutMs = defaultStopProcTimeoutMs } = {}) { +async function stopProc (proc, options = {}) { if (!proc) return if (proc.exitCode !== null || proc.signalCode !== null) return - proc.kill() + const signal = options.signal ?? 'SIGTERM' + const timeoutMs = options.timeoutMs ?? defaultStopProcTimeoutMs - const exitedAfterSigterm = await waitForProcExit(proc, timeoutMs) - if (exitedAfterSigterm) return + proc.kill(signal) + + const exitedAfterInitialSignal = await waitForProcExit(proc, timeoutMs) + if (exitedAfterInitialSignal) return proc.kill('SIGKILL') const exitedAfterSigkill = await waitForProcExit(proc, timeoutMs) diff --git a/integration-tests/profiler/profiler.spec.js b/integration-tests/profiler/profiler.spec.js index c9be0d306ca..fa1980a901d 100644 --- a/integration-tests/profiler/profiler.spec.js +++ b/integration-tests/profiler/profiler.spec.js @@ -278,8 +278,9 @@ async function gatherTimelineEvents (cwd, scriptFilePath, agentPort, eventType, // Gather only tested events if (event === eventValue) { if (process.platform !== 'win32') { - assert.notStrictEqual(spanId, undefined, encoded) - assert.notStrictEqual(localRootSpanId, undefined, encoded) + // Skip events without span IDs: these are from internal operations (e.g. background + // source map loading) that occur outside any user span and are not relevant to the test. + if (spanId === undefined || localRootSpanId === undefined) continue } else { assert.strictEqual(spanId, undefined, encoded) assert.strictEqual(localRootSpanId, undefined, encoded) diff --git a/package.json b/package.json index 540384bf3d6..9d151a2d623 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dd-trace", - "version": "5.92.0", + "version": "5.93.0", "description": "Datadog APM tracing client for JavaScript", "main": "index.js", "typings": "index.d.ts", @@ -138,7 +138,7 @@ "import-in-the-middle": "^3.0.0" }, "optionalDependencies": { - "@datadog/libdatadog": "0.8.1", + "@datadog/libdatadog": "0.9.2", "@datadog/native-appsec": "11.0.1", "@datadog/native-iast-taint-tracking": "4.1.0", "@datadog/native-metrics": "3.1.1", diff --git a/packages/datadog-plugin-ai/test/integration-test/client.spec.js b/packages/datadog-plugin-ai/test/integration-test/client.spec.js index f8187dcbf07..8f922f4f606 100644 --- a/packages/datadog-plugin-ai/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-ai/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { useSandbox, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -42,7 +43,7 @@ describe('esm', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-amqp10/test/integration-test/client.spec.js b/packages/datadog-plugin-amqp10/test/integration-test/client.spec.js index 6af340642ac..440cbba4578 100644 --- a/packages/datadog-plugin-amqp10/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-amqp10/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-amqplib/test/integration-test/client.spec.js b/packages/datadog-plugin-amqplib/test/integration-test/client.spec.js index 627fa0d0095..4190df17a9e 100644 --- a/packages/datadog-plugin-amqplib/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-amqplib/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-anthropic/test/integration-test/client.spec.js b/packages/datadog-plugin-anthropic/test/integration-test/client.spec.js index 7f21ee775d5..73067bce342 100644 --- a/packages/datadog-plugin-anthropic/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-anthropic/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -34,7 +35,7 @@ describe('esm', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-aws-sdk/src/base.js b/packages/datadog-plugin-aws-sdk/src/base.js index 9303a80764b..da8e40a56f1 100644 --- a/packages/datadog-plugin-aws-sdk/src/base.js +++ b/packages/datadog-plugin-aws-sdk/src/base.js @@ -154,6 +154,11 @@ class BaseAwsSdkPlugin extends ClientPlugin { }) this.finish(ctx) + + if (IS_SERVERLESS) { + const peerStore = storage('peerServerless').getStore() + if (peerStore) delete peerStore.peerHostname + } }) this.addBind(`apm:aws:response:start:${this.serviceIdentifier}`, ctx => { diff --git a/packages/datadog-plugin-aws-sdk/test/integration-test/client.spec.js b/packages/datadog-plugin-aws-sdk/test/integration-test/client.spec.js index 6109185f1b3..d2dcc9243d2 100644 --- a/packages/datadog-plugin-aws-sdk/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-aws-sdk/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-aws-sdk/test/integration-test/sqs.spec.js b/packages/datadog-plugin-aws-sdk/test/integration-test/sqs.spec.js index 237f8b7fa8c..f4398267b47 100644 --- a/packages/datadog-plugin-aws-sdk/test/integration-test/sqs.spec.js +++ b/packages/datadog-plugin-aws-sdk/test/integration-test/sqs.spec.js @@ -7,6 +7,7 @@ const { useSandbox, checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +24,7 @@ describe('recursion regression test', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-aws-sdk/test/serverless-peer-service.spec.js b/packages/datadog-plugin-aws-sdk/test/serverless-peer-service.spec.js index 672c5e4328d..346fc7b7314 100644 --- a/packages/datadog-plugin-aws-sdk/test/serverless-peer-service.spec.js +++ b/packages/datadog-plugin-aws-sdk/test/serverless-peer-service.spec.js @@ -79,6 +79,51 @@ describe('Plugin', () => { }), ]) }) + + it('does not leak DynamoDB peer.service to subsequent unrelated HTTP spans', async () => { + const http = require('http') + + const server = http.createServer((req, res) => res.end('ok')) + await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve)) + const port = server.address().port + + try { + const send = toPromise(dynamo, dynamo.putItem) + const allSpans = [] + const peerService = 'dynamodb.us-east-1.amazonaws.com' + + const tracesPromise = agent.assertSomeTraces(traces => { + allSpans.push(...traces.flat()) + assert.ok(allSpans.find(s => s.name === 'aws.request'), 'expected aws.request span') + assert.ok( + allSpans.find(s => s.name === 'http.request' && s.meta['http.url']?.includes('/unrelated')), + 'expected unrelated http.request span' + ) + }, { timeoutMs: 15000 }) + + await send({ TableName: tableName, Item: { id: { S: 'leak-test' } } }) + + await new Promise((resolve, reject) => { + http.get(`http://127.0.0.1:${port}/unrelated`, (res) => { + res.on('data', () => {}) + res.on('end', resolve) + }).on('error', reject) + }) + + await tracesPromise + + const unrelatedHttpSpan = allSpans.find( + s => s.name === 'http.request' && s.meta['http.url']?.includes('/unrelated') + ) + assert.notStrictEqual( + unrelatedHttpSpan.meta['peer.service'], + peerService, + 'unrelated HTTP span should not inherit DynamoDB peer.service' + ) + } finally { + server.close() + } + }) }) describe('Kinesis-Serverless', () => { diff --git a/packages/datadog-plugin-axios/test/integration-test/client.spec.js b/packages/datadog-plugin-axios/test/integration-test/client.spec.js index 4a1f8fe5663..27a9c2e8873 100644 --- a/packages/datadog-plugin-axios/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-axios/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') describe('esm', () => { let agent @@ -27,7 +28,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-durable-functions/test/integration-test/client.spec.js b/packages/datadog-plugin-azure-durable-functions/test/integration-test/client.spec.js index dc35ca52763..3f99b4450a3 100644 --- a/packages/datadog-plugin-azure-durable-functions/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-azure-durable-functions/test/integration-test/client.spec.js @@ -11,6 +11,7 @@ const { useSandbox, curlAndAssertMessage, assertObjectContains, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -35,10 +36,7 @@ describe('esm', () => { afterEach(async () => { // after each test, kill process and wait for exit before continuing - if (proc) { - proc.kill('SIGINT') - await new Promise(resolve => proc.on('exit', resolve)) - } + await stopProc(proc, { signal: 'SIGINT' }) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-event-hubs/test/integration-test/batchSpanContextRegressionTest/client.spec.js b/packages/datadog-plugin-azure-event-hubs/test/integration-test/batchSpanContextRegressionTest/client.spec.js index f9df5442c9a..3e2fc97ad67 100644 --- a/packages/datadog-plugin-azure-event-hubs/test/integration-test/batchSpanContextRegressionTest/client.spec.js +++ b/packages/datadog-plugin-azure-event-hubs/test/integration-test/batchSpanContextRegressionTest/client.spec.js @@ -6,6 +6,7 @@ const { sandboxCwd, useSandbox, spawnPluginIntegrationTestProcAndExpectExit, + stopProc, } = require('../../../../../integration-tests/helpers') const { withVersions } = require('../../../../dd-trace/test/setup/mocha') @@ -25,7 +26,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-event-hubs/test/integration-test/core-test/client.spec.js b/packages/datadog-plugin-azure-event-hubs/test/integration-test/core-test/client.spec.js index 9c99ea58616..4fee17f2dff 100644 --- a/packages/datadog-plugin-azure-event-hubs/test/integration-test/core-test/client.spec.js +++ b/packages/datadog-plugin-azure-event-hubs/test/integration-test/core-test/client.spec.js @@ -11,6 +11,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../../integration-tests/helpers') const { withVersions } = require('../../../../dd-trace/test/setup/mocha') @@ -31,7 +32,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-event-hubs/test/integration-test/tryAddRegressionTest/client.spec.js b/packages/datadog-plugin-azure-event-hubs/test/integration-test/tryAddRegressionTest/client.spec.js index 3b292742f57..001501ec244 100644 --- a/packages/datadog-plugin-azure-event-hubs/test/integration-test/tryAddRegressionTest/client.spec.js +++ b/packages/datadog-plugin-azure-event-hubs/test/integration-test/tryAddRegressionTest/client.spec.js @@ -6,6 +6,7 @@ const { sandboxCwd, useSandbox, spawnPluginIntegrationTestProcAndExpectExit, + stopProc, } = require('../../../../../integration-tests/helpers') const { withVersions } = require('../../../../dd-trace/test/setup/mocha') @@ -25,7 +26,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-functions/test/integration-test/eventhubs-test/eventhubs.spec.js b/packages/datadog-plugin-azure-functions/test/integration-test/eventhubs-test/eventhubs.spec.js index aa417fb7856..18eef9de5d1 100644 --- a/packages/datadog-plugin-azure-functions/test/integration-test/eventhubs-test/eventhubs.spec.js +++ b/packages/datadog-plugin-azure-functions/test/integration-test/eventhubs-test/eventhubs.spec.js @@ -10,6 +10,7 @@ const { sandboxCwd, useSandbox, curlAndAssertMessage, + stopProc, } = require('../../../../../integration-tests/helpers') const { withVersions } = require('../../../../dd-trace/test/setup/mocha') @@ -32,7 +33,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill('SIGINT') + await stopProc(proc, { signal: 'SIGINT' }) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-functions/test/integration-test/http-test/client.spec.js b/packages/datadog-plugin-azure-functions/test/integration-test/http-test/client.spec.js index 473aad9758e..09a729772ba 100644 --- a/packages/datadog-plugin-azure-functions/test/integration-test/http-test/client.spec.js +++ b/packages/datadog-plugin-azure-functions/test/integration-test/http-test/client.spec.js @@ -10,6 +10,7 @@ const { sandboxCwd, useSandbox, curlAndAssertMessage, + stopProc, } = require('../../../../../integration-tests/helpers') const { withVersions } = require('../../../../dd-trace/test/setup/mocha') @@ -31,7 +32,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill('SIGINT') + await stopProc(proc, { signal: 'SIGINT' }) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-functions/test/integration-test/servicebus-test/servicebus.spec.js b/packages/datadog-plugin-azure-functions/test/integration-test/servicebus-test/servicebus.spec.js index 4ab9661e9d7..9e197db2e1b 100644 --- a/packages/datadog-plugin-azure-functions/test/integration-test/servicebus-test/servicebus.spec.js +++ b/packages/datadog-plugin-azure-functions/test/integration-test/servicebus-test/servicebus.spec.js @@ -10,6 +10,7 @@ const { sandboxCwd, useSandbox, curlAndAssertMessage, + stopProc, } = require('../../../../../integration-tests/helpers') const { withVersions } = require('../../../../dd-trace/test/setup/mocha') @@ -32,7 +33,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill('SIGINT') + await stopProc(proc, { signal: 'SIGINT' }) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-service-bus/test/integration-test/core-test/client.spec.js b/packages/datadog-plugin-azure-service-bus/test/integration-test/core-test/client.spec.js index ed9b2628e9a..942bd7d37bd 100644 --- a/packages/datadog-plugin-azure-service-bus/test/integration-test/core-test/client.spec.js +++ b/packages/datadog-plugin-azure-service-bus/test/integration-test/core-test/client.spec.js @@ -9,6 +9,7 @@ const { useSandbox, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../../integration-tests/helpers') const { withVersions } = require('../../../../dd-trace/test/setup/mocha') @@ -33,7 +34,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-azure-service-bus/test/integration-test/tryAddMessageRegressionTest/client.spec.js b/packages/datadog-plugin-azure-service-bus/test/integration-test/tryAddMessageRegressionTest/client.spec.js index 48dc1603f81..d307c7a67c3 100644 --- a/packages/datadog-plugin-azure-service-bus/test/integration-test/tryAddMessageRegressionTest/client.spec.js +++ b/packages/datadog-plugin-azure-service-bus/test/integration-test/tryAddMessageRegressionTest/client.spec.js @@ -6,6 +6,7 @@ const { sandboxCwd, useSandbox, spawnPluginIntegrationTestProcAndExpectExit, + stopProc, } = require('../../../../../integration-tests/helpers') const { withVersions } = require('../../../../dd-trace/test/setup/mocha') @@ -25,7 +26,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-body-parser/test/integration-test/client.spec.js b/packages/datadog-plugin-body-parser/test/integration-test/client.spec.js index 013872b2808..7609622e6df 100644 --- a/packages/datadog-plugin-body-parser/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-body-parser/test/integration-test/client.spec.js @@ -3,8 +3,12 @@ const assert = require('node:assert/strict') const axios = require('axios') const { - sandboxCwd, useSandbox, varySandbox, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -24,7 +28,7 @@ withVersions('body-parser', 'body-parser', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-bullmq/test/integration-test/client.spec.js b/packages/datadog-plugin-bullmq/test/integration-test/client.spec.js index 25823d845a3..ea04f63dc63 100644 --- a/packages/datadog-plugin-bullmq/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-bullmq/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -26,7 +27,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-bunyan/test/integration-test/client.spec.js b/packages/datadog-plugin-bunyan/test/integration-test/client.spec.js index 64637ee48cd..b1441c0dd74 100644 --- a/packages/datadog-plugin-bunyan/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-bunyan/test/integration-test/client.spec.js @@ -7,6 +7,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -28,7 +29,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) for (const variant of varySandbox.VARIANTS) { diff --git a/packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js b/packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js index e8319cf5f5b..83d7e4f47e9 100644 --- a/packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-cassandra-driver/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-confluentinc-kafka-javascript/test/integration-test/client.spec.js b/packages/datadog-plugin-confluentinc-kafka-javascript/test/integration-test/client.spec.js index 73ec154116f..41706381dd2 100644 --- a/packages/datadog-plugin-confluentinc-kafka-javascript/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-confluentinc-kafka-javascript/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-connect/test/integration-test/client.spec.js b/packages/datadog-plugin-connect/test/integration-test/client.spec.js index f32d4d8b919..32385a67ff4 100644 --- a/packages/datadog-plugin-connect/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-connect/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-cookie-parser/test/integration-test/client.spec.js b/packages/datadog-plugin-cookie-parser/test/integration-test/client.spec.js index 568a9681ffa..948576449c1 100644 --- a/packages/datadog-plugin-cookie-parser/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-cookie-parser/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('cookie-parser', 'cookie-parser', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-cookie/test/integration-test/client.spec.js b/packages/datadog-plugin-cookie/test/integration-test/client.spec.js index 254a81cae5c..eb40fedf469 100644 --- a/packages/datadog-plugin-cookie/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-cookie/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('cookie', 'cookie', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-couchbase/test/integration-test/client.spec.js b/packages/datadog-plugin-couchbase/test/integration-test/client.spec.js index e4bd3fedf29..515674a7345 100644 --- a/packages/datadog-plugin-couchbase/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-couchbase/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -31,7 +32,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-crypto/test/integration-test/client.spec.js b/packages/datadog-plugin-crypto/test/integration-test/client.spec.js index b7789419196..47d26052138 100644 --- a/packages/datadog-plugin-crypto/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-crypto/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - useSandbox, sandboxCwd, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + useSandbox, + sandboxCwd, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') describe('ESM', () => { @@ -21,7 +26,7 @@ describe('ESM', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-dns/test/integration-test/client.spec.js b/packages/datadog-plugin-dns/test/integration-test/client.spec.js index 20756f91fd1..af95d4f7f19 100644 --- a/packages/datadog-plugin-dns/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-dns/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') describe('esm', () => { let agent @@ -27,7 +28,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-elasticsearch/test/integration-test/client.spec.js b/packages/datadog-plugin-elasticsearch/test/integration-test/client.spec.js index f06a4789faf..4c0a9c6902e 100644 --- a/packages/datadog-plugin-elasticsearch/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-elasticsearch/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -37,7 +38,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-express-mongo-sanitize/test/integration-test/client.spec.js b/packages/datadog-plugin-express-mongo-sanitize/test/integration-test/client.spec.js index 1e609db71ab..b0bb36edfcf 100644 --- a/packages/datadog-plugin-express-mongo-sanitize/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-express-mongo-sanitize/test/integration-test/client.spec.js @@ -3,8 +3,12 @@ const assert = require('node:assert/strict') const axios = require('axios') const { - sandboxCwd, useSandbox, varySandbox, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -24,7 +28,7 @@ withVersions('express-mongo-sanitize', 'express-mongo-sanitize', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-express-session/test/integration-test/client.spec.js b/packages/datadog-plugin-express-session/test/integration-test/client.spec.js index 3bf882eab1f..a0a915e4b4c 100644 --- a/packages/datadog-plugin-express-session/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-express-session/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('express-session', 'express-session', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-express/test/integration-test/client.spec.js b/packages/datadog-plugin-express/test/integration-test/client.spec.js index 89d7c0bda56..0abbf42ebd5 100644 --- a/packages/datadog-plugin-express/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-express/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -31,7 +32,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) for (const variant of varySandbox.VARIANTS) { diff --git a/packages/datadog-plugin-fastify/test/integration-test/client.spec.js b/packages/datadog-plugin-fastify/test/integration-test/client.spec.js index e4e747da398..28fa3024363 100644 --- a/packages/datadog-plugin-fastify/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-fastify/test/integration-test/client.spec.js @@ -8,6 +8,7 @@ const { curlAndAssertMessage, checkSpansForServiceName, spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions, insertVersionDep } = require('../../../dd-trace/test/setup/mocha') @@ -27,7 +28,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-fetch/test/integration-test/client.spec.js b/packages/datadog-plugin-fetch/test/integration-test/client.spec.js index ff5b5950d08..e6d69268c6b 100644 --- a/packages/datadog-plugin-fetch/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-fetch/test/integration-test/client.spec.js @@ -7,6 +7,7 @@ const { sandboxCwd, useSandbox, spawnPluginIntegrationTestProcAndExpectExit, + stopProc, } = require('../../../../integration-tests/helpers') const describe = globalThis.fetch ? globalThis.describe : globalThis.describe.skip @@ -22,7 +23,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-generic-pool/test/integration-test/client.spec.js b/packages/datadog-plugin-generic-pool/test/integration-test/client.spec.js index 2488cb7a8fd..79d14b252c9 100644 --- a/packages/datadog-plugin-generic-pool/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-generic-pool/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('generic-pool', 'generic-pool', '<3', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-google-cloud-pubsub/test/integration-test/client.spec.js b/packages/datadog-plugin-google-cloud-pubsub/test/integration-test/client.spec.js index 0f3083f68e4..4ada3b83c1a 100644 --- a/packages/datadog-plugin-google-cloud-pubsub/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-google-cloud-pubsub/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-google-cloud-vertexai/test/integration-test/client.spec.js b/packages/datadog-plugin-google-cloud-vertexai/test/integration-test/client.spec.js index 1a26fae85a3..5537c881c8a 100644 --- a/packages/datadog-plugin-google-cloud-vertexai/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-google-cloud-vertexai/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -34,7 +35,7 @@ describe('esm', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-google-genai/test/integration-test/client.spec.js b/packages/datadog-plugin-google-genai/test/integration-test/client.spec.js index 9cc15d82990..8a2220fbdd3 100644 --- a/packages/datadog-plugin-google-genai/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-google-genai/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -33,7 +34,7 @@ describe('esm', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-graphql/test/esm-test/esm.spec.js b/packages/datadog-plugin-graphql/test/esm-test/esm.spec.js index 3875ecf63c7..06181ef450f 100644 --- a/packages/datadog-plugin-graphql/test/esm-test/esm.spec.js +++ b/packages/datadog-plugin-graphql/test/esm-test/esm.spec.js @@ -10,6 +10,7 @@ const { useSandbox, checkSpansForServiceName, spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -27,7 +28,7 @@ describe('Plugin (ESM)', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-graphql/test/integration-test/client.spec.js b/packages/datadog-plugin-graphql/test/integration-test/client.spec.js index 4df35636096..838d8d50da1 100644 --- a/packages/datadog-plugin-graphql/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-graphql/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-grpc/test/integration-test/client.spec.js b/packages/datadog-plugin-grpc/test/integration-test/client.spec.js index 9d404059bd0..8288a97c594 100644 --- a/packages/datadog-plugin-grpc/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-grpc/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProc, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') const { NODE_MAJOR } = require('../../../../version') @@ -33,7 +34,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-handlebars/test/integration-test/client.spec.js b/packages/datadog-plugin-handlebars/test/integration-test/client.spec.js index e8f11e01bd6..c0d7ab21076 100644 --- a/packages/datadog-plugin-handlebars/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-handlebars/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('handlebars', 'handlebars', '>=4.0.0', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-hapi/test/integration-test/client.spec.js b/packages/datadog-plugin-hapi/test/integration-test/client.spec.js index 1f64336e51b..83f9e204cbc 100644 --- a/packages/datadog-plugin-hapi/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-hapi/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProc, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') const { assertObjectContains } = require('../../../../integration-tests/helpers') @@ -32,7 +33,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-hono/test/integration-test/client.spec.js b/packages/datadog-plugin-hono/test/integration-test/client.spec.js index e554da99335..d3c01de38d8 100644 --- a/packages/datadog-plugin-hono/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-hono/test/integration-test/client.spec.js @@ -8,6 +8,7 @@ const { spawnPluginIntegrationTestProc, assertObjectContains, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -29,7 +30,7 @@ describe('esm integration test', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-http/test/integration-test/client.spec.js b/packages/datadog-plugin-http/test/integration-test/client.spec.js index 0f1eb48f680..ef88fc98ce9 100644 --- a/packages/datadog-plugin-http/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-http/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { curlAndAssertMessage, spawnPluginIntegrationTestProc, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') describe('esm', () => { let agent @@ -27,7 +28,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-http2/test/integration-test/client.spec.js b/packages/datadog-plugin-http2/test/integration-test/client.spec.js index a0cae7ae522..b1d08c5d777 100644 --- a/packages/datadog-plugin-http2/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-http2/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') describe('esm', () => { @@ -28,7 +29,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-ioredis/test/integration-test/client.spec.js b/packages/datadog-plugin-ioredis/test/integration-test/client.spec.js index b30ce7d7dff..cfa037bddba 100644 --- a/packages/datadog-plugin-ioredis/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-ioredis/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-iovalkey/test/integration-test/client.spec.js b/packages/datadog-plugin-iovalkey/test/integration-test/client.spec.js index 11a3b8c8cef..f4c4cb9c5a3 100644 --- a/packages/datadog-plugin-iovalkey/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-iovalkey/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-kafkajs/test/integration-test/client.spec.js b/packages/datadog-plugin-kafkajs/test/integration-test/client.spec.js index d192c2d04ab..fdb09c2fc0c 100644 --- a/packages/datadog-plugin-kafkajs/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-kafkajs/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-knex/test/integration-test/client.spec.js b/packages/datadog-plugin-knex/test/integration-test/client.spec.js index 593bde00ae3..d7487ff0750 100644 --- a/packages/datadog-plugin-knex/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-knex/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('knex', 'knex', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-koa/test/integration-test/client.spec.js b/packages/datadog-plugin-koa/test/integration-test/client.spec.js index 3daf75f0815..e248921c047 100644 --- a/packages/datadog-plugin-koa/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-koa/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProc, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -26,7 +27,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-langchain/test/integration-test/client.spec.js b/packages/datadog-plugin-langchain/test/integration-test/client.spec.js index edc9a3c9af2..e3789de2118 100644 --- a/packages/datadog-plugin-langchain/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-langchain/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -34,7 +35,7 @@ describe('esm', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-ldapjs/test/integration-test/client.spec.js b/packages/datadog-plugin-ldapjs/test/integration-test/client.spec.js index e61d43229cc..e9fcd9c9f5f 100644 --- a/packages/datadog-plugin-ldapjs/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-ldapjs/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('ldapjs', 'ldapjs', '>=2', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-light-my-request/test/integration-test/client.spec.js b/packages/datadog-plugin-light-my-request/test/integration-test/client.spec.js index 5870277cb38..47506d2493b 100644 --- a/packages/datadog-plugin-light-my-request/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-light-my-request/test/integration-test/client.spec.js @@ -8,6 +8,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-limitd-client/test/integration-test/client.spec.js b/packages/datadog-plugin-limitd-client/test/integration-test/client.spec.js index 05f471b6589..27f9978a1b1 100644 --- a/packages/datadog-plugin-limitd-client/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-limitd-client/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) for (const variant of varySandbox.VARIANTS) { diff --git a/packages/datadog-plugin-lodash/test/integration-test/client.spec.js b/packages/datadog-plugin-lodash/test/integration-test/client.spec.js index 576ca05790d..7e3d45fa726 100644 --- a/packages/datadog-plugin-lodash/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-lodash/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('lodash', 'lodash', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-mariadb/test/integration-test/client.spec.js b/packages/datadog-plugin-mariadb/test/integration-test/client.spec.js index 75f89fdb56c..f50bd29156c 100644 --- a/packages/datadog-plugin-mariadb/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-mariadb/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-memcached/test/integration-test/client.spec.js b/packages/datadog-plugin-memcached/test/integration-test/client.spec.js index 0953722b7d8..d11ddaf46d6 100644 --- a/packages/datadog-plugin-memcached/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-memcached/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -25,7 +26,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-microgateway-core/test/integration-test/client.spec.js b/packages/datadog-plugin-microgateway-core/test/integration-test/client.spec.js index c0b44501ce0..68f9246e3c3 100644 --- a/packages/datadog-plugin-microgateway-core/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-microgateway-core/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProc, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -31,7 +32,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-moleculer/test/integration-test/client.spec.js b/packages/datadog-plugin-moleculer/test/integration-test/client.spec.js index 31a4966e207..56e3ae58658 100644 --- a/packages/datadog-plugin-moleculer/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-moleculer/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -31,7 +32,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-mongodb-core/test/integration-test/client.spec.js b/packages/datadog-plugin-mongodb-core/test/integration-test/client.spec.js index e51826e6eb6..c3c0d6105f3 100644 --- a/packages/datadog-plugin-mongodb-core/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-mongodb-core/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) @@ -62,7 +63,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-mongoose/test/integration-test/client.spec.js b/packages/datadog-plugin-mongoose/test/integration-test/client.spec.js index a727330b9d5..79f6ce68730 100644 --- a/packages/datadog-plugin-mongoose/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-mongoose/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) for (const variant of varySandbox.VARIANTS) { diff --git a/packages/datadog-plugin-multer/test/integration-test/client.spec.js b/packages/datadog-plugin-multer/test/integration-test/client.spec.js index 7986bcc4a4a..8352b241a5e 100644 --- a/packages/datadog-plugin-multer/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-multer/test/integration-test/client.spec.js @@ -3,8 +3,12 @@ const assert = require('node:assert/strict') const axios = require('axios') const { - useSandbox, sandboxCwd, varySandbox, - FakeAgent, spawnPluginIntegrationTestProc, + useSandbox, + sandboxCwd, + varySandbox, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -24,7 +28,7 @@ withVersions('multer', 'multer', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-mysql/test/integration-test/client.spec.js b/packages/datadog-plugin-mysql/test/integration-test/client.spec.js index 41f669584d2..12060be9b6f 100644 --- a/packages/datadog-plugin-mysql/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-mysql/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-mysql2/test/integration-test/client.spec.js b/packages/datadog-plugin-mysql2/test/integration-test/client.spec.js index 67422b775e3..4106d242504 100644 --- a/packages/datadog-plugin-mysql2/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-mysql2/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-net/test/integration-test/client.spec.js b/packages/datadog-plugin-net/test/integration-test/client.spec.js index ca6d392cf24..06f4d634417 100644 --- a/packages/datadog-plugin-net/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-net/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') describe('esm', () => { let agent @@ -27,7 +28,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-next/test/integration-test/client.spec.js b/packages/datadog-plugin-next/test/integration-test/client.spec.js index f9fc1e737b5..1a55047f147 100644 --- a/packages/datadog-plugin-next/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-next/test/integration-test/client.spec.js @@ -11,6 +11,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') const { assertObjectContains } = require('../../../../integration-tests/helpers') @@ -47,7 +48,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-node-serialize/test/integration-test/client.spec.js b/packages/datadog-plugin-node-serialize/test/integration-test/client.spec.js index 5ca16c3fd8b..1e94ed8d7b9 100644 --- a/packages/datadog-plugin-node-serialize/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-node-serialize/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - useSandbox, sandboxCwd, varySandbox, - FakeAgent, spawnPluginIntegrationTestProc, curl, + useSandbox, + sandboxCwd, + varySandbox, + FakeAgent, + spawnPluginIntegrationTestProc, + curl, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('node-serialize', 'node-serialize', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-openai/test/integration-test/client.spec.js b/packages/datadog-plugin-openai/test/integration-test/client.spec.js index 9d5eaeb4575..f5a53db1f6c 100644 --- a/packages/datadog-plugin-openai/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-openai/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -40,7 +41,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-opensearch/test/integration-test/client.spec.js b/packages/datadog-plugin-opensearch/test/integration-test/client.spec.js index a7910d5984d..55c27841043 100644 --- a/packages/datadog-plugin-opensearch/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-opensearch/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-oracledb/test/integration-test/client.spec.js b/packages/datadog-plugin-oracledb/test/integration-test/client.spec.js index 8993ac77581..300ba86f099 100644 --- a/packages/datadog-plugin-oracledb/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-oracledb/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-passport-http/test/integration-test/client.spec.js b/packages/datadog-plugin-passport-http/test/integration-test/client.spec.js index 0d4d91a4ed0..c79cd3f14aa 100644 --- a/packages/datadog-plugin-passport-http/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-passport-http/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('passport-http', 'passport-http', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-pg/test/integration-test/client.spec.js b/packages/datadog-plugin-pg/test/integration-test/client.spec.js index fbc179fb083..2bed625b182 100644 --- a/packages/datadog-plugin-pg/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-pg/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -39,7 +40,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-pino/test/integration-test/client.spec.js b/packages/datadog-plugin-pino/test/integration-test/client.spec.js index 433ba016505..e308064b2d3 100644 --- a/packages/datadog-plugin-pino/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-pino/test/integration-test/client.spec.js @@ -7,6 +7,7 @@ const { sandboxCwd, useSandbox, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -28,7 +29,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-prisma/test/integration-test/client.spec.js b/packages/datadog-plugin-prisma/test/integration-test/client.spec.js index 01612ebda21..063ab2bd6b2 100644 --- a/packages/datadog-plugin-prisma/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-prisma/test/integration-test/client.spec.js @@ -14,6 +14,7 @@ const { spawnPluginIntegrationTestProcAndExpectExit, assertObjectContains, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') const externals = require('../../../dd-trace/test/plugins/externals') @@ -299,7 +300,7 @@ describe('esm', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent?.stop() }) diff --git a/packages/datadog-plugin-process/test/integration-test/client.spec.js b/packages/datadog-plugin-process/test/integration-test/client.spec.js index fc56a4b83af..0212418b1ad 100644 --- a/packages/datadog-plugin-process/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-process/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - useSandbox, sandboxCwd, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + useSandbox, + sandboxCwd, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') describe('ESM', () => { @@ -21,7 +26,7 @@ describe('ESM', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-pug/test/integration-test/client.spec.js b/packages/datadog-plugin-pug/test/integration-test/client.spec.js index 797809def95..0a2cfa8442b 100644 --- a/packages/datadog-plugin-pug/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-pug/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('pug', 'pug', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-redis/test/integration-test/client.spec.js b/packages/datadog-plugin-redis/test/integration-test/client.spec.js index a30539f395a..1372e95fe99 100644 --- a/packages/datadog-plugin-redis/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-redis/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -30,7 +31,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-restify/test/integration-test/client.spec.js b/packages/datadog-plugin-restify/test/integration-test/client.spec.js index 0227e34fc80..7e1506752a5 100644 --- a/packages/datadog-plugin-restify/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-restify/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProc, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -32,7 +33,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-rhea/test/integration-test/client.spec.js b/packages/datadog-plugin-rhea/test/integration-test/client.spec.js index eda3c044d93..8a263a4dc62 100644 --- a/packages/datadog-plugin-rhea/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-rhea/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-router/test/integration-test/client.spec.js b/packages/datadog-plugin-router/test/integration-test/client.spec.js index 86ad224cfaf..b221a4a4711 100644 --- a/packages/datadog-plugin-router/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-router/test/integration-test/client.spec.js @@ -10,6 +10,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProc, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -31,7 +32,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-sequelize/test/integration-test/client.spec.js b/packages/datadog-plugin-sequelize/test/integration-test/client.spec.js index 642aa45448e..c57d2bab05d 100644 --- a/packages/datadog-plugin-sequelize/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-sequelize/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - sandboxCwd, useSandbox, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + sandboxCwd, + useSandbox, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -23,7 +28,7 @@ withVersions('sequelize', 'sequelize', version => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-sharedb/test/integration-test/client.spec.js b/packages/datadog-plugin-sharedb/test/integration-test/client.spec.js index 36419167b3f..7f30753a8b7 100644 --- a/packages/datadog-plugin-sharedb/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-sharedb/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') describe('esm', () => { @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-tedious/test/integration-test/client.spec.js b/packages/datadog-plugin-tedious/test/integration-test/client.spec.js index 3e897f7f524..6b6c283cfd0 100644 --- a/packages/datadog-plugin-tedious/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-tedious/test/integration-test/client.spec.js @@ -9,6 +9,7 @@ const { checkSpansForServiceName, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const version = require('../../../../version.js') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -37,7 +38,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-url/test/integration-test/client.spec.js b/packages/datadog-plugin-url/test/integration-test/client.spec.js index 7340717bfe2..8bc656c99bd 100644 --- a/packages/datadog-plugin-url/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-url/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - useSandbox, sandboxCwd, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + useSandbox, + sandboxCwd, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') describe('ESM', () => { @@ -21,7 +26,7 @@ describe('ESM', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-vm/test/integration-test/client.spec.js b/packages/datadog-plugin-vm/test/integration-test/client.spec.js index e4d1f204613..1be4c65a3fd 100644 --- a/packages/datadog-plugin-vm/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-vm/test/integration-test/client.spec.js @@ -2,8 +2,13 @@ const assert = require('node:assert/strict') const { - useSandbox, sandboxCwd, varySandbox, curl, - FakeAgent, spawnPluginIntegrationTestProc, + useSandbox, + sandboxCwd, + varySandbox, + curl, + FakeAgent, + spawnPluginIntegrationTestProc, + stopProc, } = require('../../../../integration-tests/helpers') describe('ESM', () => { @@ -21,7 +26,7 @@ describe('ESM', () => { }) afterEach(async () => { - proc?.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/datadog-plugin-winston/test/integration-test/client.spec.js b/packages/datadog-plugin-winston/test/integration-test/client.spec.js index c65dd321db3..70f98181f0f 100644 --- a/packages/datadog-plugin-winston/test/integration-test/client.spec.js +++ b/packages/datadog-plugin-winston/test/integration-test/client.spec.js @@ -7,6 +7,7 @@ const { useSandbox, spawnPluginIntegrationTestProcAndExpectExit, varySandbox, + stopProc, } = require('../../../../integration-tests/helpers') const { withVersions } = require('../../../dd-trace/test/setup/mocha') @@ -29,7 +30,7 @@ describe('esm', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/src/config/supported-configurations.json b/packages/dd-trace/src/config/supported-configurations.json index c3fa3368afd..5bca7736dc9 100644 --- a/packages/dd-trace/src/config/supported-configurations.json +++ b/packages/dd-trace/src/config/supported-configurations.json @@ -744,9 +744,9 @@ ], "DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED": [ { - "implementation": "A", + "implementation": "B", "type": "boolean", - "default": "false", + "default": "true", "configurationNames": [ "propagateProcessTags.enabled" ] diff --git a/packages/dd-trace/src/crashtracking/index.js b/packages/dd-trace/src/crashtracking/index.js index 2ba38e72658..5addf3864ef 100644 --- a/packages/dd-trace/src/crashtracking/index.js +++ b/packages/dd-trace/src/crashtracking/index.js @@ -1,9 +1,15 @@ 'use strict' +const { existsSync } = require('node:fs') const { isMainThread } = require('worker_threads') const log = require('../log') -if (isMainThread) { +// libdatadog v29 crashtracker segfaults during init on ARM64 musl (Alpine). +// The segfault bypasses JS try/catch so we must avoid loading it entirely. +// See: https://github.com/DataDog/libdatadog-nodejs/issues/114 +const isArm64Musl = process.arch === 'arm64' && existsSync('/etc/alpine-release') + +if (isMainThread && !isArm64Musl) { try { module.exports = require('./crashtracker') } catch (e) { diff --git a/packages/dd-trace/src/exporters/common/docker.js b/packages/dd-trace/src/exporters/common/docker.js index fd3700c19c0..311b9581cae 100644 --- a/packages/dd-trace/src/exporters/common/docker.js +++ b/packages/dd-trace/src/exporters/common/docker.js @@ -35,6 +35,7 @@ if (inodePath) { const entityId = containerId ? `ci-${containerId}` : inode && `in-${inode}` module.exports = { + containerId, entityId, inject (carrier) { diff --git a/packages/dd-trace/src/exporters/common/request.js b/packages/dd-trace/src/exporters/common/request.js index fe9986fbbaa..f21daa0de5f 100644 --- a/packages/dd-trace/src/exporters/common/request.js +++ b/packages/dd-trace/src/exporters/common/request.js @@ -14,9 +14,9 @@ const { urlToHttpOptions } = require('./url-to-http-options-polyfill') const docker = require('./docker') const { httpAgent, httpsAgent } = require('./agents') -const maxActiveRequests = 8 +const maxActiveBufferSize = 1024 * 1024 * 64 -let activeRequests = 0 +let activeBufferSize = 0 function parseUrl (urlObjOrString) { if (urlObjOrString !== null && typeof urlObjOrString === 'object') return urlToHttpOptions(urlObjOrString) @@ -50,7 +50,22 @@ function request (data, options, callback) { } } - const isReadable = data instanceof Readable + if (data instanceof Readable) { + const chunks = [] + + data + .on('data', (data) => { + chunks.push(data) + }) + .on('end', () => { + request(Buffer.concat(chunks), options, callback) + }) + .on('error', (err) => { + callback(err) + }) + + return + } // The timeout should be kept low to avoid excessive queueing. const timeout = options.timeout || 2000 @@ -58,12 +73,10 @@ function request (data, options, callback) { const client = isSecure ? https : http let dataArray = data - if (!isReadable) { - if (!Array.isArray(data)) { - dataArray = [data] - } - options.headers['Content-Length'] = byteLength(dataArray) + if (!Array.isArray(data)) { + dataArray = [data] } + options.headers['Content-Length'] = byteLength(dataArray) docker.inject(options.headers) @@ -126,14 +139,14 @@ function request (data, options, callback) { return callback(null) } - activeRequests++ + activeBufferSize += options.headers['Content-Length'] ?? 0 storage('legacy').run({ noop: true }, () => { let finished = false const finalize = () => { if (finished) return finished = true - activeRequests-- + activeBufferSize -= options.headers['Content-Length'] ?? 0 } const req = client.request(options, (res) => onResponse(res, finalize)) @@ -158,12 +171,8 @@ function request (data, options, callback) { } }) - if (isReadable) { - data.pipe(req) // TODO: Validate whether this is actually retriable. - } else { - for (const buffer of dataArray) req.write(buffer) - req.end() - } + for (const buffer of dataArray) req.write(buffer) + req.end() }) } @@ -183,7 +192,7 @@ function byteLength (data) { Object.defineProperty(request, 'writable', { get () { - return activeRequests < maxActiveRequests + return activeBufferSize < maxActiveBufferSize }, }) diff --git a/packages/dd-trace/src/priority_sampler.js b/packages/dd-trace/src/priority_sampler.js index 4e586bc6a93..6edfc39c81a 100644 --- a/packages/dd-trace/src/priority_sampler.js +++ b/packages/dd-trace/src/priority_sampler.js @@ -37,13 +37,16 @@ const { const DEFAULT_KEY = 'service:,env:' /** - * Formats a sampling rate as a string with up to 6 significant digits and no trailing zeros. + * Formats a sampling rate as a string with up to 6 decimal digits and no trailing zeros. * * @param {number} rate - * @returns {string} */ function formatKnuthRate (rate) { - return Number(rate.toPrecision(6)).toString() + const string = Number(rate).toFixed(6) + for (let i = string.length - 1; i > 0; i--) { + if (string[i] === '0') continue + return string.slice(0, i + (string[i] === '.' ? 0 : 1)) + } } const defaultSampler = new Sampler(AUTO_KEEP) diff --git a/packages/dd-trace/src/profiling/profiler.js b/packages/dd-trace/src/profiling/profiler.js index 91c4bba8ae3..c107fc82750 100644 --- a/packages/dd-trace/src/profiling/profiler.js +++ b/packages/dd-trace/src/profiling/profiler.js @@ -1,8 +1,6 @@ 'use strict' const { EventEmitter } = require('events') -const { promisify } = require('util') -const zlib = require('zlib') const dc = require('dc-polyfill') const crashtracker = require('../crashtracking') const log = require('../log') @@ -34,6 +32,14 @@ function findWebSpan (startedSpans, spanId) { return false } +const MISSING_SOURCE_MAPS_TOKEN = 'dd:has-missing-map-files' + +function profileHasMissingSourceMaps (profile) { + const strings = profile?.stringTable?.strings + if (!strings) return false + return profile.comment?.some(idx => strings[idx] === MISSING_SOURCE_MAPS_TOKEN) ?? false +} + function processInfo (infos, info, type) { if (Object.keys(info).length > 0) { infos[type] = info @@ -42,6 +48,7 @@ function processInfo (infos, info, type) { class Profiler extends EventEmitter { #compressionFn + #compressionFnInitialized = false #compressionOptions #config #enabled = false @@ -50,7 +57,6 @@ class Profiler extends EventEmitter { #logger #profileSeq = 0 #spanFinishListener - #sourceMapCount = 0 #timer constructor () { @@ -116,11 +122,13 @@ class Profiler extends EventEmitter { reportHostname, } - return this._start(options).catch((err) => { + try { + return this._start(options) + } catch (err) { logError(logger, 'Error starting profiler. For troubleshooting tips, see ' + '', err) return false - }) + } } get enabled () { @@ -131,7 +139,50 @@ class Profiler extends EventEmitter { logError(this.#logger, err) } - async _start (options) { + #getCompressionFn () { + if (!this.#compressionFnInitialized) { + this.#compressionFnInitialized = true + try { + const { promisify } = require('util') + const zlib = require('zlib') + const { method, level: clevel } = this.#config.uploadCompression + switch (method) { + case 'gzip': + this.#compressionFn = promisify(zlib.gzip) + if (clevel !== undefined) { + this.#compressionOptions = { + level: clevel, + } + } + break + case 'zstd': + // eslint-disable-next-line n/no-unsupported-features/node-builtins + if (typeof zlib.zstdCompress === 'function') { + // eslint-disable-next-line n/no-unsupported-features/node-builtins + this.#compressionFn = promisify(zlib.zstdCompress) + if (clevel !== undefined) { + this.#compressionOptions = { + params: { + // eslint-disable-next-line n/no-unsupported-features/node-builtins + [zlib.constants.ZSTD_c_compressionLevel]: clevel, + }, + } + } + } else { + const zstdCompress = require('@datadog/libdatadog').load('datadog-js-zstd').zstd_compress + const level = clevel ?? 0 // 0 is zstd default compression level + this.#compressionFn = (buffer) => Promise.resolve(Buffer.from(zstdCompress(buffer, level))) + } + break + } + } catch (err) { + this.#logError(err) + } + } + return this.#compressionFn + } + + _start (options) { if (this.enabled) return true const config = this.#config = new Config(options) @@ -148,45 +199,21 @@ class Profiler extends EventEmitter { setLogger(config.logger) if (config.sourceMap) { - mapper = await SourceMapper.create([process.cwd()], config.debugSourceMaps) - this.#sourceMapCount = mapper.infoMap.size - if (config.debugSourceMaps) { - this.#logger.debug(() => { - return this.#sourceMapCount === 0 - ? 'Found no source maps' - : `Found source maps for following files: [${[...mapper.infoMap.keys()].join(', ')}]` - }) - } - } - - const clevel = config.uploadCompression.level - switch (config.uploadCompression.method) { - case 'gzip': - this.#compressionFn = promisify(zlib.gzip) - if (clevel !== undefined) { - this.#compressionOptions = { - level: clevel, - } - } - break - case 'zstd': - if (typeof zlib.zstdCompress === 'function') { // eslint-disable-line n/no-unsupported-features/node-builtins - // eslint-disable-next-line n/no-unsupported-features/node-builtins - this.#compressionFn = promisify(zlib.zstdCompress) - if (clevel !== undefined) { - this.#compressionOptions = { - params: { - // eslint-disable-next-line n/no-unsupported-features/node-builtins - [zlib.constants.ZSTD_c_compressionLevel]: clevel, - }, - } + mapper = new SourceMapper(config.debugSourceMaps) + mapper.loadDirectory(process.cwd()) + .then(() => { + if (config.debugSourceMaps) { + const count = mapper.infoMap.size + this.#logger.debug(() => { + return count === 0 + ? 'Found no source maps' + : `Found source maps for following files: [${[...mapper.infoMap.keys()].join(', ')}]` + }) } - } else { - const zstdCompress = require('@datadog/libdatadog').load('datadog-js-zstd').zstd_compress - const level = clevel ?? 0 // 0 is zstd default compression level - this.#compressionFn = (buffer) => Promise.resolve(Buffer.from(zstdCompress(buffer, level))) - } - break + }) + .catch((err) => { + this.#logError(err) + }) } } catch (err) { this.#logError(err) @@ -295,7 +322,7 @@ class Profiler extends EventEmitter { return { serverless: this.serverless, settings: this.#config.systemInfoReport, - sourceMapCount: this.#sourceMapCount, + hasMissingSourceMaps: false, } } @@ -332,15 +359,19 @@ class Profiler extends EventEmitter { const encodedProfiles = {} const infos = this.#createInitialInfos() + const compressionFn = this.#getCompressionFn() // encode and export asynchronously await Promise.all(profiles.map(async ({ profiler, profile, info }) => { try { const encoded = await profiler.encode(profile) - const compressed = encoded instanceof Buffer && this.#compressionFn !== undefined - ? await this.#compressionFn(encoded, this.#compressionOptions) + const compressed = encoded instanceof Buffer && compressionFn !== undefined + ? await compressionFn(encoded, this.#compressionOptions) : encoded encodedProfiles[profiler.type] = compressed + if (profileHasMissingSourceMaps(profile)) { + infos.hasMissingSourceMaps = true + } processInfo(infos, info, profiler.type) this.#logger.debug(() => { const profileJson = JSON.stringify(profile, (_, value) => { diff --git a/packages/dd-trace/src/proxy.js b/packages/dd-trace/src/proxy.js index 7595ab0ef6a..015e91f78ca 100644 --- a/packages/dd-trace/src/proxy.js +++ b/packages/dd-trace/src/proxy.js @@ -180,7 +180,7 @@ class Tracer extends NoopProxy { if (config.profiling.enabled === 'true') { this._profilerStarted = this._startProfiler(config) } else { - this._profilerStarted = Promise.resolve(false) + this._profilerStarted = false if (config.profiling.enabled === 'auto') { const { SSIHeuristics } = require('./profiling/ssi-heuristics') const ssiHeuristics = new SSIHeuristics(config) @@ -252,6 +252,7 @@ class Tracer extends NoopProxy { 'Error starting profiler. For troubleshooting tips, see ', e ) + return false } } @@ -329,11 +330,11 @@ class Tracer extends NoopProxy { * @override */ profilerStarted () { - if (!this._profilerStarted) { + if (this._profilerStarted === undefined) { // injection hardening: this is only ever invoked from tests. throw new Error('profilerStarted() must be called after init()') } - return this._profilerStarted + return Promise.resolve(this._profilerStarted) } /** diff --git a/packages/dd-trace/src/tracer_metadata.js b/packages/dd-trace/src/tracer_metadata.js index 3226f8cf590..9a780cdf756 100644 --- a/packages/dd-trace/src/tracer_metadata.js +++ b/packages/dd-trace/src/tracer_metadata.js @@ -11,13 +11,22 @@ function storeConfig (config) { return } + const { containerId } = require('./exporters/common/docker') + const processTags = require('./process-tags') + + const processTagsSerialized = config.propagateProcessTags?.enabled + ? (processTags.serialized || null) + : null + const metadata = new processDiscovery.TracerMetadata( config.tags['runtime-id'], tracerVersion, config.hostname, config.service || null, config.env || null, - config.version || null + config.version || null, + processTagsSerialized, + containerId || null ) return processDiscovery.storeMetadata(metadata) diff --git a/packages/dd-trace/test/appsec/api_security_sampling.integration.spec.js b/packages/dd-trace/test/appsec/api_security_sampling.integration.spec.js index a2304048bb8..1979067d3a7 100644 --- a/packages/dd-trace/test/appsec/api_security_sampling.integration.spec.js +++ b/packages/dd-trace/test/appsec/api_security_sampling.integration.spec.js @@ -4,7 +4,7 @@ const assert = require('node:assert/strict') const path = require('path') const Axios = require('axios') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../integration-tests/helpers') +const { sandboxCwd, useSandbox, FakeAgent, spawnProc, stopProc } = require('../../../../integration-tests/helpers') const { calculateHttpEndpoint } = require('../../src/plugins/util/url') describe('API Security sampling integration', () => { @@ -59,7 +59,7 @@ describe('API Security sampling integration', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/appsec/downstream_requests.integration.spec.js b/packages/dd-trace/test/appsec/downstream_requests.integration.spec.js index f0196285b4f..40a0c450fac 100644 --- a/packages/dd-trace/test/appsec/downstream_requests.integration.spec.js +++ b/packages/dd-trace/test/appsec/downstream_requests.integration.spec.js @@ -3,7 +3,7 @@ const assert = require('node:assert/strict') const path = require('path') const Axios = require('axios') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../integration-tests/helpers') +const { sandboxCwd, useSandbox, FakeAgent, spawnProc, stopProc } = require('../../../../integration-tests/helpers') describe('RASP - downstream request integration', () => { let cwd, appFile @@ -36,7 +36,7 @@ describe('RASP - downstream request integration', () => { } async function teardownTest (agent, proc) { - proc.kill() + await stopProc(proc) await agent.stop() } diff --git a/packages/dd-trace/test/appsec/iast/code_injection.integration.spec.js b/packages/dd-trace/test/appsec/iast/code_injection.integration.spec.js index 01316b82234..dc56c2eed35 100644 --- a/packages/dd-trace/test/appsec/iast/code_injection.integration.spec.js +++ b/packages/dd-trace/test/appsec/iast/code_injection.integration.spec.js @@ -4,7 +4,7 @@ const assert = require('node:assert/strict') const path = require('path') const Axios = require('axios') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../../integration-tests/helpers') +const { sandboxCwd, useSandbox, FakeAgent, spawnProc, stopProc } = require('../../../../../integration-tests/helpers') describe('IAST - code_injection - integration', () => { let axios, cwd, agent, proc @@ -24,7 +24,7 @@ describe('IAST - code_injection - integration', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/appsec/iast/overhead-controller.integration.spec.js b/packages/dd-trace/test/appsec/iast/overhead-controller.integration.spec.js index 90d675b8636..3e1ab4c4fb9 100644 --- a/packages/dd-trace/test/appsec/iast/overhead-controller.integration.spec.js +++ b/packages/dd-trace/test/appsec/iast/overhead-controller.integration.spec.js @@ -4,7 +4,7 @@ const assert = require('node:assert/strict') const path = require('path') const Axios = require('axios') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../../integration-tests/helpers') +const { sandboxCwd, useSandbox, FakeAgent, spawnProc, stopProc } = require('../../../../../integration-tests/helpers') describe('IAST - overhead-controller - integration', () => { let axios, cwd, agent, proc @@ -24,7 +24,7 @@ describe('IAST - overhead-controller - integration', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/appsec/rasp/command_injection.integration.spec.js b/packages/dd-trace/test/appsec/rasp/command_injection.integration.spec.js index ea289cf319f..912f4e95086 100644 --- a/packages/dd-trace/test/appsec/rasp/command_injection.integration.spec.js +++ b/packages/dd-trace/test/appsec/rasp/command_injection.integration.spec.js @@ -6,7 +6,13 @@ const path = require('node:path') const Axios = require('axios') const { describe, it, before, beforeEach, afterEach } = require('mocha') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../../integration-tests/helpers') +const { + sandboxCwd, + useSandbox, + FakeAgent, + spawnProc, + stopProc, +} = require('../../../../../integration-tests/helpers') describe('RASP - command_injection - integration', () => { let axios, cwd, appFile, agent, proc @@ -39,7 +45,7 @@ describe('RASP - command_injection - integration', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/appsec/rasp/lfi.integration.express.plugin.spec.js b/packages/dd-trace/test/appsec/rasp/lfi.integration.express.plugin.spec.js index e9522a8cc76..8d431f8e69e 100644 --- a/packages/dd-trace/test/appsec/rasp/lfi.integration.express.plugin.spec.js +++ b/packages/dd-trace/test/appsec/rasp/lfi.integration.express.plugin.spec.js @@ -4,7 +4,7 @@ const assert = require('node:assert/strict') const path = require('path') const Axios = require('axios') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../../integration-tests/helpers') +const { sandboxCwd, useSandbox, FakeAgent, spawnProc, stopProc } = require('../../../../../integration-tests/helpers') describe('RASP - lfi - integration - sync', () => { let axios, cwd, appFile, agent, proc @@ -33,7 +33,7 @@ describe('RASP - lfi - integration - sync', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/appsec/rasp/rasp-metrics.integration.spec.js b/packages/dd-trace/test/appsec/rasp/rasp-metrics.integration.spec.js index 419e22c2884..bf9731a7246 100644 --- a/packages/dd-trace/test/appsec/rasp/rasp-metrics.integration.spec.js +++ b/packages/dd-trace/test/appsec/rasp/rasp-metrics.integration.spec.js @@ -4,7 +4,7 @@ const assert = require('node:assert/strict') const path = require('path') const Axios = require('axios') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../../integration-tests/helpers') +const { sandboxCwd, useSandbox, FakeAgent, spawnProc, stopProc } = require('../../../../../integration-tests/helpers') describe('RASP metrics', () => { let axios, cwd, appFile @@ -39,7 +39,7 @@ describe('RASP metrics', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) @@ -91,7 +91,7 @@ describe('RASP metrics', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/appsec/rasp/sql_injection.integration.pg.plugin.spec.js b/packages/dd-trace/test/appsec/rasp/sql_injection.integration.pg.plugin.spec.js index 9136c4ca56b..bfa904d1368 100644 --- a/packages/dd-trace/test/appsec/rasp/sql_injection.integration.pg.plugin.spec.js +++ b/packages/dd-trace/test/appsec/rasp/sql_injection.integration.pg.plugin.spec.js @@ -4,7 +4,7 @@ const assert = require('node:assert/strict') const path = require('path') const Axios = require('axios') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../../integration-tests/helpers') +const { sandboxCwd, useSandbox, FakeAgent, spawnProc, stopProc } = require('../../../../../integration-tests/helpers') // These test are here and not in the integration tests // because they require postgres instance describe('RASP - sql_injection - integration', () => { @@ -35,7 +35,7 @@ describe('RASP - sql_injection - integration', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/appsec/waf-metrics.integration.spec.js b/packages/dd-trace/test/appsec/waf-metrics.integration.spec.js index 973888d5fbc..ccf1421beda 100644 --- a/packages/dd-trace/test/appsec/waf-metrics.integration.spec.js +++ b/packages/dd-trace/test/appsec/waf-metrics.integration.spec.js @@ -4,7 +4,7 @@ const assert = require('node:assert/strict') const path = require('path') const Axios = require('axios') -const { sandboxCwd, useSandbox, FakeAgent, spawnProc } = require('../../../../integration-tests/helpers') +const { sandboxCwd, useSandbox, FakeAgent, spawnProc, stopProc } = require('../../../../integration-tests/helpers') describe('WAF Metrics', () => { let axios, cwd, appFile @@ -37,7 +37,7 @@ describe('WAF Metrics', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) @@ -99,7 +99,7 @@ describe('WAF Metrics', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) @@ -151,7 +151,7 @@ describe('WAF Metrics', () => { }) afterEach(async () => { - proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/exporters/common/request.spec.js b/packages/dd-trace/test/exporters/common/request.spec.js index a82334cb95b..63d6cdad6ea 100644 --- a/packages/dd-trace/test/exporters/common/request.spec.js +++ b/packages/dd-trace/test/exporters/common/request.spec.js @@ -3,6 +3,7 @@ const assert = require('node:assert/strict') const http = require('node:http') const zlib = require('node:zlib') +const stream = require('node:stream') const { describe, it, beforeEach, afterEach } = require('mocha') const sinon = require('sinon') @@ -434,4 +435,53 @@ describe('request', function () { }) }) }) + + it('should drop requests when too much data is buffered', (done) => { + const bufferSize = 8 * 1024 * 1024 + const buffer = Buffer.alloc(bufferSize).fill(69) + + nock('http://test:123', { + reqheaders: { + 'content-type': 'application/octet-stream', + 'content-length': bufferSize, + }, + }) + .put('/path') + .times(10) + .reply(200, 'OK') + + let okCount = 0 + let koCount = 0 + + for (let i = 0; i < 10; i++) { + request( + stream.Readable.from(buffer), + { + protocol: 'http:', + hostname: 'test', + port: 123, + path: '/path', + method: 'PUT', + headers: { + 'Content-Type': 'application/octet-stream', + }, + }, + (err, res) => { + if (err) return done(err) + + if (res) { + assert.strictEqual(res, 'OK') + okCount++ + } else { + koCount++ + } + + if (okCount + koCount === 10) { + assert.strictEqual(okCount, 8) + assert.strictEqual(koCount, 2) + done() + } + }) + } + }) }) diff --git a/packages/dd-trace/test/llmobs/sdk/typescript/index.spec.js b/packages/dd-trace/test/llmobs/sdk/typescript/index.spec.js index 86785ef75b3..e54d5839f5b 100644 --- a/packages/dd-trace/test/llmobs/sdk/typescript/index.spec.js +++ b/packages/dd-trace/test/llmobs/sdk/typescript/index.spec.js @@ -9,6 +9,7 @@ const { sandboxCwd, useSandbox, spawnProcAndExpectExit, + stopProc, } = require('../../../../../../integration-tests/helpers') const { assertLlmObsSpanEvent } = require('../../util') @@ -83,7 +84,7 @@ describe('typescript', () => { }) afterEach(async () => { - proc && proc.kill() + await stopProc(proc) await agent.stop() }) diff --git a/packages/dd-trace/test/priority_sampler.spec.js b/packages/dd-trace/test/priority_sampler.spec.js index 39bbf2f153e..7e2c821b012 100644 --- a/packages/dd-trace/test/priority_sampler.spec.js +++ b/packages/dd-trace/test/priority_sampler.spec.js @@ -421,6 +421,45 @@ describe('PrioritySampler', () => { assert.strictEqual(typeof context._trace.tags[SAMPLING_KNUTH_RATE], 'string') }) + it('should format _dd.p.ksr with decimal notation for very small rates', () => { + Sampler.withArgs(0.000001).returns({ + isSampled: sinon.stub().returns(true), + rate: sinon.stub().returns(0.000001), + }) + prioritySampler = new PrioritySampler('test', { + sampleRate: 0.000001, + }) + prioritySampler.sample(span) + + assert.strictEqual(context._trace.tags[SAMPLING_KNUTH_RATE], '0.000001') + }) + + it('should round _dd.p.ksr to zero when rate is below 6 decimal precision', () => { + Sampler.withArgs(0.0000001).returns({ + isSampled: sinon.stub().returns(true), + rate: sinon.stub().returns(0.0000001), + }) + prioritySampler = new PrioritySampler('test', { + sampleRate: 0.0000001, + }) + prioritySampler.sample(span) + + assert.strictEqual(context._trace.tags[SAMPLING_KNUTH_RATE], '0') + }) + + it('should round _dd.p.ksr up to 0.000001 when rate rounds up', () => { + Sampler.withArgs(0.00000051).returns({ + isSampled: sinon.stub().returns(true), + rate: sinon.stub().returns(0.00000051), + }) + prioritySampler = new PrioritySampler('test', { + sampleRate: 0.00000051, + }) + prioritySampler.sample(span) + + assert.strictEqual(context._trace.tags[SAMPLING_KNUTH_RATE], '0.000001') + }) + it('should not set _dd.p.ksr tag for manual sampling', () => { context._tags[MANUAL_KEEP] = undefined diff --git a/packages/dd-trace/test/process-tags.spec.js b/packages/dd-trace/test/process-tags.spec.js index b35d7c61580..facfc7e636d 100644 --- a/packages/dd-trace/test/process-tags.spec.js +++ b/packages/dd-trace/test/process-tags.spec.js @@ -302,19 +302,21 @@ describe('process-tags', () => { assert.strictEqual(processor._processTags, false) }) - it('should disable process tags propagation when not set', () => { - // Don't set the environment variable + it('should enable process tags propagation when not set', () => { + // Don't set the environment variable — default is enabled const config = getConfigFresh() const processTagsModule = require('../src/process-tags') processTagsModule.initialize() - assert.notStrictEqual(config.propagateProcessTags?.enabled, true) + assert.ok(config.propagateProcessTags) + assert.strictEqual(config.propagateProcessTags.enabled, true) SpanProcessor = require('../src/span_processor') const processor = new SpanProcessor(undefined, undefined, config) - assert.strictEqual(processor._processTags, false) + assert.ok(typeof processor._processTags === 'string') + assert.match(processor._processTags, /entrypoint/) }) }) }) diff --git a/packages/dd-trace/test/profiling/profiler.spec.js b/packages/dd-trace/test/profiling/profiler.spec.js index da2ab499ae3..0b0b405e8a8 100644 --- a/packages/dd-trace/test/profiling/profiler.spec.js +++ b/packages/dd-trace/test/profiling/profiler.spec.js @@ -24,7 +24,8 @@ describe('profiler', function () { let profilers let consoleLogger let logger - let sourceMapCreate + let SourceMapperStub + let mapperInstance let interval function waitForExport () { @@ -79,7 +80,11 @@ describe('profiler', function () { exporters = [exporter] profilers = [wallProfiler, spaceProfiler] - sourceMapCreate = sinon.stub() + mapperInstance = { + infoMap: new Map(), + loadDirectory: sinon.stub().resolves(), + } + SourceMapperStub = sinon.stub().returns(mapperInstance) } function makeStartOptions (overrides = {}) { @@ -95,9 +100,7 @@ describe('profiler', function () { function initProfiler () { Profiler = proxyquire('../../src/profiling/profiler', { '@datadog/pprof': { - SourceMapper: { - create: sourceMapCreate, - }, + SourceMapper: SourceMapperStub, }, }).Profiler @@ -347,19 +350,19 @@ describe('profiler', function () { }) it('should pass source mapper to profilers when enabled', async () => { - const mapper = { infoMap: new Map() } - sourceMapCreate.returns(Promise.resolve(mapper)) - await profiler._start(makeStartOptions({ sourceMap: true })) + profiler._start(makeStartOptions({ sourceMap: true })) const options = profilers[0].start.args[0][0] assert.ok(Object.hasOwn(options, 'mapper')) - assert.strictEqual(mapper, options.mapper) + assert.strictEqual(mapperInstance, options.mapper) }) it('should work with a root working dir and source maps on', async () => { const error = new Error('fail') - sourceMapCreate.rejects(error) - await profiler._start(makeStartOptions({ logger, sourceMap: true })) + mapperInstance.loadDirectory.rejects(error) + profiler._start(makeStartOptions({ logger, sourceMap: true })) + await Promise.resolve() // let .then() propagate the rejection + await Promise.resolve() // let .catch() callback run assert.strictEqual(consoleLogger.error.args[0][0], error) assert.strictEqual(profiler.enabled, true) }) @@ -385,27 +388,13 @@ describe('profiler', function () { assert.strictEqual(infos.serverless, false) }) - it('should include sourceMapCount: 0 when source maps are disabled', async () => { - exporterPromise = new Promise(resolve => { - exporter.export = (exportSpec) => { - resolve(exportSpec) - return Promise.resolve() - } + it('should set hasMissingSourceMaps to true when any profile has the comment token', async () => { + const token = 'dd:has-missing-map-files' + wallProfiler.profile.returns({ + comment: [1], + stringTable: { strings: ['', token] }, }) - await profiler._start(makeStartOptions({ sourceMap: false })) - - clock.tick(interval) - - const { infos } = await exporterPromise - - assert.strictEqual(infos.sourceMapCount, 0) - }) - - it('should include sourceMapCount: 0 when no source maps are found', async () => { - const mapper = { infoMap: new Map() } - sourceMapCreate.returns(Promise.resolve(mapper)) - exporterPromise = new Promise(resolve => { exporter.export = (exportSpec) => { resolve(exportSpec) @@ -413,25 +402,16 @@ describe('profiler', function () { } }) - await profiler._start(makeStartOptions({ sourceMap: true })) + await profiler._start(makeStartOptions()) clock.tick(interval) const { infos } = await exporterPromise - assert.strictEqual(infos.sourceMapCount, 0) + assert.strictEqual(infos.hasMissingSourceMaps, true) }) - it('should include sourceMapCount with the number of loaded source maps', async () => { - const mapper = { - infoMap: new Map([ - ['file1.js', {}], - ['file2.js', {}], - ['file3.js', {}], - ]), - } - sourceMapCreate.returns(Promise.resolve(mapper)) - + it('should set hasMissingSourceMaps to false when no profile has the comment token', async () => { exporterPromise = new Promise(resolve => { exporter.export = (exportSpec) => { resolve(exportSpec) @@ -439,13 +419,13 @@ describe('profiler', function () { } }) - await profiler._start(makeStartOptions({ sourceMap: true })) + await profiler._start(makeStartOptions()) clock.tick(interval) const { infos } = await exporterPromise - assert.strictEqual(infos.sourceMapCount, 3) + assert.strictEqual(infos.hasMissingSourceMaps, false) }) }) @@ -455,9 +435,7 @@ describe('profiler', function () { function initServerlessProfiler () { Profiler = proxyquire('../../src/profiling/profiler', { '@datadog/pprof': { - SourceMapper: { - create: sourceMapCreate, - }, + SourceMapper: SourceMapperStub, }, }).ServerlessProfiler @@ -525,14 +503,12 @@ describe('profiler', function () { assert.strictEqual(infos.serverless, true) }) - it('should include sourceMapCount in export infos', async () => { - const mapper = { - infoMap: new Map([ - ['file1.js', {}], - ['file2.js', {}], - ]), - } - sourceMapCreate.returns(Promise.resolve(mapper)) + it('should set hasMissingSourceMaps to true when any profile has the comment token', async () => { + const token = 'dd:has-missing-map-files' + wallProfiler.profile.returns({ + comment: [1], + stringTable: { strings: ['', token] }, + }) exporterPromise = new Promise(resolve => { exporter.export = (exportSpec) => { @@ -541,7 +517,7 @@ describe('profiler', function () { } }) - await profiler._start(makeStartOptions({ sourceMap: true })) + profiler._start(makeStartOptions()) // flushAfterIntervals + 1 because it flushes after last interval for (let i = 0; i < flushAfterIntervals + 1; i++) { @@ -550,7 +526,7 @@ describe('profiler', function () { const { infos } = await exporterPromise - assert.strictEqual(infos.sourceMapCount, 2) + assert.strictEqual(infos.hasMissingSourceMaps, true) }) }) }) diff --git a/packages/dd-trace/test/tracer_metadata.spec.js b/packages/dd-trace/test/tracer_metadata.spec.js new file mode 100644 index 00000000000..90b38205fc7 --- /dev/null +++ b/packages/dd-trace/test/tracer_metadata.spec.js @@ -0,0 +1,123 @@ +'use strict' + +const assert = require('node:assert/strict') +const { describe, it, beforeEach, afterEach } = require('mocha') +const proxyquire = require('proxyquire') +const sinon = require('sinon') + +describe('tracer_metadata', () => { + let storeConfig + let storeMetadataStub + let TracerMetadataStub + let processDiscoveryStub + let libdatadogStub + let dockerStub + let processTagsStub + + const baseConfig = { + tags: { 'runtime-id': 'test-runtime-id' }, + hostname: 'test-host', + service: 'test-service', + env: 'test-env', + version: '1.0.0', + propagateProcessTags: { enabled: false }, + } + + beforeEach(() => { + storeMetadataStub = sinon.stub().returns({ handle: 'mock-handle' }) + TracerMetadataStub = sinon.stub() + + processDiscoveryStub = { + TracerMetadata: TracerMetadataStub, + storeMetadata: storeMetadataStub, + } + + libdatadogStub = { + maybeLoad: sinon.stub().withArgs('process-discovery').returns(processDiscoveryStub), + } + + dockerStub = { containerId: undefined } + processTagsStub = { serialized: 'tag1:val1,tag2:val2' } + + storeConfig = proxyquire('../src/tracer_metadata', { + '@datadog/libdatadog': libdatadogStub, + './exporters/common/docker': dockerStub, + './process-tags': processTagsStub, + }) + }) + + afterEach(() => { + sinon.restore() + }) + + it('calls storeMetadata with correct base fields', () => { + storeConfig(baseConfig) + + sinon.assert.calledOnce(TracerMetadataStub) + const args = TracerMetadataStub.firstCall.args + assert.strictEqual(args[0], 'test-runtime-id') + assert.strictEqual(args[2], 'test-host') + assert.strictEqual(args[3], 'test-service') + assert.strictEqual(args[4], 'test-env') + assert.strictEqual(args[5], '1.0.0') + + sinon.assert.calledOnce(storeMetadataStub) + }) + + it('passes null for process_tags when propagateProcessTags is disabled', () => { + storeConfig({ ...baseConfig, propagateProcessTags: { enabled: false } }) + + const args = TracerMetadataStub.firstCall.args + assert.strictEqual(args[6], null) + }) + + it('passes serialized process tags when propagateProcessTags is enabled', () => { + storeConfig({ ...baseConfig, propagateProcessTags: { enabled: true } }) + + const args = TracerMetadataStub.firstCall.args + assert.strictEqual(args[6], 'tag1:val1,tag2:val2') + }) + + it('passes container_id when available', () => { + dockerStub.containerId = 'abc123container' + + storeConfig(baseConfig) + + const args = TracerMetadataStub.firstCall.args + assert.strictEqual(args[7], 'abc123container') + }) + + it('passes null for container_id when not in a container', () => { + dockerStub.containerId = undefined + + storeConfig(baseConfig) + + const args = TracerMetadataStub.firstCall.args + assert.strictEqual(args[7], null) + }) + + it('passes null for service when config.service is falsy', () => { + storeConfig({ ...baseConfig, service: undefined }) + + const args = TracerMetadataStub.firstCall.args + assert.strictEqual(args[3], null) + }) + + it('returns undefined and does not throw when process-discovery is unavailable', () => { + libdatadogStub.maybeLoad.returns(undefined) + + const result = storeConfig(baseConfig) + assert.strictEqual(result, undefined) + }) + + it('returns undefined and does not throw when libdatadog throws', () => { + const storeConfigWithThrow = proxyquire('../src/tracer_metadata', { + '@datadog/libdatadog': { maybeLoad: () => { throw new Error('load error') } }, + './exporters/common/docker': dockerStub, + './process-tags': processTagsStub, + }) + + const result = storeConfigWithThrow(baseConfig) + assert.strictEqual(result, undefined) + }) +}) diff --git a/scripts/all-green.mjs b/scripts/all-green.mjs index 8092dd749e5..373284ba354 100644 --- a/scripts/all-green.mjs +++ b/scripts/all-green.mjs @@ -55,15 +55,16 @@ async function hasCompleted () { } async function checkCompleted () { - if (RETRIES && retries > RETRIES) { - throw new Error(`State is still pending after ${RETRIES} retries.`) - } - if (!await hasCompleted()) { + retries++ + + if (RETRIES && retries > RETRIES) { + throw new Error(`State is still pending after ${RETRIES} retries.`) + } + console.log(`Status is still pending, waiting for ${POLLING_INTERVAL} minutes before retrying.`) await setTimeout(POLLING_INTERVAL * 60_000) console.log('Retrying.') - retries++ await checkCompleted() } } @@ -108,6 +109,18 @@ async function checkAllGreen () { } async function printSummary (checkRuns) { + const runs = checkRuns.map(run => ({ + name: run.name, + status: run.status, + conclusion: run.conclusion + ? `${run.conclusion} ${checkConclusionEmojis[run.conclusion]}` + : ' ', + started_at: run.started_at, + completed_at: run.completed_at ?? ' ', + })) + + console.table(runs) + const header = [ { data: 'name', header: true }, { data: 'status', header: true }, @@ -116,12 +129,12 @@ async function printSummary (checkRuns) { { data: 'completed_at', header: true }, ] - const body = checkRuns.map(run => [ + const body = runs.map(run => [ run.name, run.status, - run.conclusion ? `${run.conclusion} ${checkConclusionEmojis[run.conclusion]}` : ' ', + run.conclusion, run.started_at, - run.completed_at ?? ' ', + run.completed_at, ]) await summary diff --git a/yarn.lock b/yarn.lock index 5678e053657..eb3d8574f0d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -197,10 +197,10 @@ dependencies: spark-md5 "^3.0.2" -"@datadog/libdatadog@0.8.1": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@datadog/libdatadog/-/libdatadog-0.8.1.tgz#370c7aaf03102399740dcdee52c118da41847c1f" - integrity sha512-WeWPw24cVRmEWfRRw3+h4k7f8mf9vbWEq6MYg1eOd+FycG7q4LaV8/uKROWoKFoD6ScoNvZXxOjKHW3AdYgM+A== +"@datadog/libdatadog@0.9.2": + version "0.9.2" + resolved "https://registry.yarnpkg.com/@datadog/libdatadog/-/libdatadog-0.9.2.tgz#d7a0193ab656bd9cc40649f300ef6c54d9bea52d" + integrity sha512-grOerTYuU3wHuFIOBGg3jB144A3KEthEdVEL3meeiXYo7E7fBXXGRgAOwVE42VXFXfl0r8kDKCL7KupBc511tg== "@datadog/native-appsec@11.0.1": version "11.0.1" @@ -2183,9 +2183,9 @@ flat@^5.0.2: integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== flatted@^3.2.9: - version "3.3.4" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.4.tgz#0986e681008f0f13f58e18656c47967682db5ff6" - integrity sha512-3+mMldrTAPdta5kjX2G2J7iX4zxtnwpdA8Tr2ZSjkyPSanvbZAcy6flmtnXbEybHrDcU9641lxrMfFuUxVz9vA== + version "3.4.2" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.4.2.tgz#f5c23c107f0f37de8dbdf24f13722b3b98d52726" + integrity sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA== follow-redirects@^1.15.11: version "1.15.11"