Skip to content

Commit 08a37c0

Browse files
committed
Fix Datadog CI workflow - use direct API calls instead of non-existent actions
1 parent b1d1553 commit 08a37c0

File tree

2 files changed

+100
-81
lines changed

2 files changed

+100
-81
lines changed

.github/workflows/ci-with-datadog.yml

Lines changed: 70 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@ jobs:
2626
datadog-ci:
2727
runs-on: ubuntu-latest
2828
steps:
29-
- name: Setup Datadog CI
30-
id: datadog-setup
31-
uses: DataDog/github-action-dd-trace@v1
32-
with:
33-
api-key: ${{ secrets.DATADOG_API_KEY }}
34-
site: datadoghq.com
35-
service: lace-wallet
36-
env: ci
37-
tags: ci:true,service:lace-wallet,repo:lace
38-
3929
- name: Send CI metrics to Datadog
40-
uses: DataDog/github-action-metrics@v1
41-
with:
42-
api-key: ${{ secrets.DATADOG_API_KEY }}
43-
site: datadoghq.com
44-
metrics: |
45-
github.ci.pipeline.duration:${{ github.run_duration }}|#service:lace-wallet,env:ci,workflow:${{ github.workflow }},job:${{ github.job }}
46-
github.ci.pipeline.status:1|#service:lace-wallet,env:ci,workflow:${{ github.workflow }},job:${{ github.job }},status:${{ job.status }}
30+
run: |
31+
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
32+
curl -X POST "https://api.datadoghq.com/api/v1/series" \
33+
-H "Content-Type: application/json" \
34+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
35+
-d '{
36+
"series": [{
37+
"metric": "github.ci.pipeline.duration",
38+
"points": [[$(date +%s), ${{ github.run_duration }}]],
39+
"tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}"],
40+
"type": "gauge"
41+
}, {
42+
"metric": "github.ci.pipeline.status",
43+
"points": [[$(date +%s), 1]],
44+
"tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}", "status:${{ job.status }}"],
45+
"type": "gauge"
46+
}]
47+
}'
48+
fi
4749
4850
prepare:
4951
name: Prepare
@@ -111,17 +113,19 @@ jobs:
111113

112114
- name: Send build metrics to Datadog
113115
run: |
114-
curl -X POST "https://api.datadoghq.com/api/v1/series" \
115-
-H "Content-Type: application/json" \
116-
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
117-
-d '{
118-
"series": [{
119-
"metric": "lace.build.packages",
120-
"points": [[$(date +%s), 7]],
121-
"tags": ["service:lace-wallet", "env:ci", "workflow:prepare"],
122-
"type": "gauge"
123-
}]
124-
}'
116+
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
117+
curl -X POST "https://api.datadoghq.com/api/v1/series" \
118+
-H "Content-Type: application/json" \
119+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
120+
-d '{
121+
"series": [{
122+
"metric": "lace.build.packages",
123+
"points": [[$(date +%s), 7]],
124+
"tags": ["service:lace-wallet", "env:ci", "workflow:prepare"],
125+
"type": "gauge"
126+
}]
127+
}'
128+
fi
125129
126130
unitTests:
127131
name: Unit tests
@@ -190,17 +194,19 @@ jobs:
190194

191195
- name: Send test metrics to Datadog
192196
run: |
193-
curl -X POST "https://api.datadoghq.com/api/v1/series" \
194-
-H "Content-Type: application/json" \
195-
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
196-
-d '{
197-
"series": [{
198-
"metric": "lace.tests.unit",
199-
"points": [[$(date +%s), 1]],
200-
"tags": ["service:lace-wallet", "env:ci", "workflow:unitTests", "status:${{ job.status }}"],
201-
"type": "gauge"
202-
}]
203-
}'
197+
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
198+
curl -X POST "https://api.datadoghq.com/api/v1/series" \
199+
-H "Content-Type: application/json" \
200+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
201+
-d '{
202+
"series": [{
203+
"metric": "lace.tests.unit",
204+
"points": [[$(date +%s), 1]],
205+
"tags": ["service:lace-wallet", "env:ci", "workflow:unitTests", "status:${{ job.status }}"],
206+
"type": "gauge"
207+
}]
208+
}'
209+
fi
204210
205211
release-pkg:
206212
name: Release package
@@ -269,31 +275,35 @@ jobs:
269275

270276
- name: Send release metrics to Datadog
271277
run: |
272-
curl -X POST "https://api.datadoghq.com/api/v1/series" \
273-
-H "Content-Type: application/json" \
274-
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
275-
-d '{
276-
"series": [{
277-
"metric": "lace.release.package",
278-
"points": [[$(date +%s), 1]],
279-
"tags": ["service:lace-wallet", "env:ci", "workflow:release-pkg", "status:${{ job.status }}"],
280-
"type": "gauge"
281-
}]
282-
}'
278+
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
279+
curl -X POST "https://api.datadoghq.com/api/v1/series" \
280+
-H "Content-Type: application/json" \
281+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
282+
-d '{
283+
"series": [{
284+
"metric": "lace.release.package",
285+
"points": [[$(date +%s), 1]],
286+
"tags": ["service:lace-wallet", "env:ci", "workflow:release-pkg", "status:${{ job.status }}"],
287+
"type": "gauge"
288+
}]
289+
}'
290+
fi
283291
284292
datadog-final:
285293
needs: [prepare, unitTests, release-pkg]
286294
runs-on: ubuntu-latest
287295
steps:
288296
- name: Send final CI metrics to Datadog
289297
run: |
290-
curl -X POST "https://api.datadoghq.com/api/v1/events" \
291-
-H "Content-Type: application/json" \
292-
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
293-
-d '{
294-
"title": "Lace CI Pipeline Complete",
295-
"text": "All CI jobs completed for ${{ github.repository }}\nBranch: ${{ github.ref_name }}\nCommit: ${{ github.sha }}\nStatus: ${{ needs.prepare.result }}, ${{ needs.unitTests.result }}, ${{ needs.release-pkg.result }}",
296-
"tags": ["service:lace-wallet", "env:ci", "workflow:ci", "repo:lace"],
297-
"alert_type": "${{ needs.prepare.result == 'success' && needs.unitTests.result == 'success' && needs.release-pkg.result == 'success' && 'info' || 'error' }}",
298-
"source_type_name": "github"
299-
}'
298+
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
299+
curl -X POST "https://api.datadoghq.com/api/v1/events" \
300+
-H "Content-Type: application/json" \
301+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
302+
-d '{
303+
"title": "Lace CI Pipeline Complete",
304+
"text": "All CI jobs completed for ${{ github.repository }}\nBranch: ${{ github.ref_name }}\nCommit: ${{ github.sha }}\nStatus: ${{ needs.prepare.result }}, ${{ needs.unitTests.result }}, ${{ needs.release-pkg.result }}",
305+
"tags": ["service:lace-wallet", "env:ci", "workflow:ci", "repo:lace"],
306+
"alert_type": "${{ needs.prepare.result == 'success' && needs.unitTests.result == 'success' && needs.release-pkg.result == 'success' && 'info' || 'error' }}",
307+
"source_type_name": "github"
308+
}'
309+
fi

.github/workflows/datadog-ci.yml

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,43 @@ jobs:
3636
steps:
3737
- name: Setup Datadog CI
3838
id: datadog-setup
39-
uses: DataDog/github-action-dd-trace@v1
40-
with:
41-
api-key: ${{ inputs.datadog-api-key }}
42-
site: ${{ inputs.datadog-site }}
43-
service: ${{ inputs.service-name }}
44-
env: ${{ inputs.environment }}
45-
tags: ${{ inputs.tags }}
39+
run: |
40+
echo "trace-id=$(date +%s)" >> $GITHUB_OUTPUT
41+
echo "span-id=$(date +%s)" >> $GITHUB_OUTPUT
4642
4743
datadog-monitor:
4844
runs-on: ubuntu-latest
4945
needs: datadog-setup
5046
if: always()
5147
steps:
5248
- name: Send CI metrics to Datadog
53-
uses: DataDog/github-action-metrics@v1
54-
with:
55-
api-key: ${{ inputs.datadog-api-key }}
56-
site: ${{ inputs.datadog-site }}
57-
metrics: |
58-
# CI Pipeline metrics
59-
github.ci.pipeline.duration:${{ github.run_duration }}|#service:${{ inputs.service-name }},env:${{ inputs.environment }},workflow:${{ github.workflow }},job:${{ github.job }}
60-
github.ci.pipeline.status:1|#service:${{ inputs.service-name }},env:${{ inputs.environment }},workflow:${{ github.workflow }},job:${{ github.job }},status:${{ job.status }}
61-
62-
# Repository metrics
63-
github.ci.repository.workflow_runs:1|#service:${{ inputs.service-name }},env:${{ inputs.environment }},repo:${{ github.repository }},branch:${{ github.ref_name }}
64-
65-
# Job metrics
66-
github.ci.job.duration:${{ github.run_duration }}|#service:${{ inputs.service-name }},env:${{ inputs.environment }},job:${{ github.job }},runner:${{ runner.os }}
49+
run: |
50+
curl -X POST "https://api.${{ inputs.datadog-site }}/api/v1/series" \
51+
-H "Content-Type: application/json" \
52+
-H "DD-API-KEY: ${{ inputs.datadog-api-key }}" \
53+
-d '{
54+
"series": [{
55+
"metric": "github.ci.pipeline.duration",
56+
"points": [[$(date +%s), ${{ github.run_duration }}]],
57+
"tags": ["service:${{ inputs.service-name }}", "env:${{ inputs.environment }}", "workflow:${{ github.workflow }}", "job:${{ github.job }}"],
58+
"type": "gauge"
59+
}, {
60+
"metric": "github.ci.pipeline.status",
61+
"points": [[$(date +%s), 1]],
62+
"tags": ["service:${{ inputs.service-name }}", "env:${{ inputs.environment }}", "workflow:${{ github.workflow }}", "job:${{ github.job }}", "status:${{ job.status }}"],
63+
"type": "gauge"
64+
}, {
65+
"metric": "github.ci.repository.workflow_runs",
66+
"points": [[$(date +%s), 1]],
67+
"tags": ["service:${{ inputs.service-name }}", "env:${{ inputs.environment }}", "repo:${{ github.repository }}", "branch:${{ github.ref_name }}"],
68+
"type": "gauge"
69+
}, {
70+
"metric": "github.ci.job.duration",
71+
"points": [[$(date +%s), ${{ github.run_duration }}]],
72+
"tags": ["service:${{ inputs.service-name }}", "env:${{ inputs.environment }}", "job:${{ github.job }}", "runner:${{ runner.os }}"],
73+
"type": "gauge"
74+
}]
75+
}'
6776
6877
- name: Send CI events to Datadog
6978
if: always()

0 commit comments

Comments
 (0)