diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 1a889988566c..834c46f59d17 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -1199,10 +1199,21 @@ jobs: name: wasm-dev-binary path: packages/next-swc/crates/wasm/pkg-nodejs + check-trace-secrests: + runs-on: ubuntu-latest + outputs: + trace-api-key: ${{ steps.trace-api-key.outputs.defined }} + steps: + - id: trace-api-key + env: + TRACE_API_KEY: ${{ secrets.DATA_DOG_API_KEY }} + if: "${{ env.TRACE_API_KEY != '' }}" + run: echo "::set-output name=defined::true" build-performance-metrics: name: Performance Metrics for Release Build runs-on: ubuntu-latest - needs: [build, build-native-test] + needs: [build, build-native-test, check-trace-secrests] + if: needs.check-trace-secrests.trace-api-key == 'true' steps: - name: Setup node uses: actions/setup-node@v2 @@ -1236,16 +1247,16 @@ jobs: run: | yarn --cwd bench/nested-deps install node bench/nested-deps/bench.mjs build - - uses: datadog/agent-github-action@v1 if: ${{needs.build.outputs.docsChange != 'docs only change'}} with: api_key: ${{ secrets.DATA_DOG_API_KEY }} - - name: Sending metrics data to Datadog if: ${{needs.build.outputs.docsChange != 'docs only change'}} run: | node scripts/trace-dd.mjs bench/nested-deps/.next/trace build ${GIT_SHORT_SHA} ./bench/nested-deps/next.config.js env: + DD_TRACE_PARTIAL_FLUSH_MIN_SPANS: 10 DD_ENV: canary - DD_SERVICE: http://localhost:8126 + DD_SERVICE: nextjs-dev-build + DD_TRACE_DEBUG: true diff --git a/scripts/trace-dd.mjs b/scripts/trace-dd.mjs index 9f09ce6018b6..3b8336b70a36 100644 --- a/scripts/trace-dd.mjs +++ b/scripts/trace-dd.mjs @@ -132,7 +132,14 @@ const collectTraces = async (filePath, metadata) => { * Naively validate, collect necessary args. */ const validateArgs = async () => { - const { DD_ENV, DD_SERVICE } = process.env + const { DD_ENV, DD_SERVICE, DATA_DOG_API_KEY } = process.env + + if (!DATA_DOG_API_KEY) { + console.log( + "Skipping trace collection, api key is not available. Ensure 'DATA_DOG_API_KEY' env variable is set." + ) + return + } if (!DD_ENV || !DD_SERVICE) { throw new Error(