Skip to content

Commit

Permalink
ci(trace): adjust agent env variables (#35790)
Browse files Browse the repository at this point in the history
* ci(trace): adjust agent env variables

* refactor(trace): exit early when there's no key

* ci(trace): try to skip agent if api key is not available
  • Loading branch information
kwonoj committed Mar 31, 2022
1 parent aa93109 commit 69a166b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -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
Expand Down Expand Up @@ -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
9 changes: 8 additions & 1 deletion scripts/trace-dd.mjs
Expand Up @@ -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(
Expand Down

0 comments on commit 69a166b

Please sign in to comment.