Skip to content

Commit ebefcf1

Browse files
committed
chore: test datadog v2 ci agent
1 parent 7fc2964 commit ebefcf1

File tree

1 file changed

+72
-32
lines changed

1 file changed

+72
-32
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,23 @@ jobs:
1616
- name: Send CI metrics to Datadog
1717
run: |
1818
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
19-
echo "Sending metrics to Datadog..."
20-
response=$(curl -s -w "%{http_code}" -X POST "https://api.datadoghq.com/api/v1/series" \
19+
echo "Sending CI metrics to Datadog v2..."
20+
response=$(curl -s -w "%{http_code}" -X POST "https://api.us5.datadoghq.com/api/v2/series" \
2121
-H "Content-Type: application/json" \
2222
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
2323
-d '{
2424
"series": [{
2525
"metric": "github.ci.pipeline.duration",
26-
"points": [[$(date +%s), ${{ github.run_duration }}]],
27-
"tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}"],
28-
"type": "gauge"
26+
"points": [{"timestamp": $(date +%s), "value": ${{ github.run_duration }}}],
27+
"tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}", "repo:${{ github.repository }}", "branch:${{ github.ref_name }}"]
2928
}, {
3029
"metric": "github.ci.pipeline.status",
31-
"points": [[$(date +%s), 1]],
32-
"tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}", "status:${{ job.status }}"],
33-
"type": "gauge"
30+
"points": [{"timestamp": $(date +%s), "value": 1}],
31+
"tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}", "status:${{ job.status }}", "repo:${{ github.repository }}", "branch:${{ github.ref_name }}"]
32+
}, {
33+
"metric": "github.ci.job.duration",
34+
"points": [{"timestamp": $(date +%s), "value": ${{ github.run_duration }}}],
35+
"tags": ["service:lace-wallet", "env:ci", "workflow:${{ github.workflow }}", "job:${{ github.job }}", "runner:ubuntu-latest", "repo:${{ github.repository }}"]
3436
}]
3537
}')
3638
echo "Datadog API response: $response"
@@ -105,16 +107,19 @@ jobs:
105107
- name: Send build metrics to Datadog
106108
run: |
107109
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
108-
echo "Sending build metrics to Datadog..."
109-
response=$(curl -s -w "%{http_code}" -X POST "https://api.datadoghq.com/api/v1/series" \
110+
echo "Sending build metrics to Datadog v2..."
111+
response=$(curl -s -w "%{http_code}" -X POST "https://api.us5.datadoghq.com/api/v2/series" \
110112
-H "Content-Type: application/json" \
111113
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
112114
-d '{
113115
"series": [{
114116
"metric": "lace.build.packages",
115-
"points": [[$(date +%s), 1]],
116-
"tags": ["service:lace-wallet", "env:ci", "workflow:ci", "status:${{ job.status }}"],
117-
"type": "gauge"
117+
"points": [{"timestamp": $(date +%s), "value": 1}],
118+
"tags": ["service:lace-wallet", "env:ci", "workflow:ci", "status:${{ job.status }}", "repo:${{ github.repository }}", "branch:${{ github.ref_name }}", "job:prepare"]
119+
}, {
120+
"metric": "lace.build.duration",
121+
"points": [{"timestamp": $(date +%s), "value": ${{ github.run_duration }}}],
122+
"tags": ["service:lace-wallet", "env:ci", "workflow:ci", "job:prepare", "repo:${{ github.repository }}"]
118123
}]
119124
}')
120125
echo "Datadog API response: $response"
@@ -189,16 +194,19 @@ jobs:
189194
- name: Send test metrics to Datadog
190195
run: |
191196
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
192-
echo "Sending test metrics to Datadog..."
193-
response=$(curl -s -w "%{http_code}" -X POST "https://api.datadoghq.com/api/v1/series" \
197+
echo "Sending test metrics to Datadog v2..."
198+
response=$(curl -s -w "%{http_code}" -X POST "https://api.us5.datadoghq.com/api/v2/series" \
194199
-H "Content-Type: application/json" \
195200
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
196201
-d '{
197202
"series": [{
198203
"metric": "lace.tests.unit",
199-
"points": [[$(date +%s), 1]],
200-
"tags": ["service:lace-wallet", "env:ci", "workflow:unitTests", "status:${{ job.status }}"],
201-
"type": "gauge"
204+
"points": [{"timestamp": $(date +%s), "value": 1}],
205+
"tags": ["service:lace-wallet", "env:ci", "workflow:unitTests", "status:${{ job.status }}", "repo:${{ github.repository }}", "branch:${{ github.ref_name }}", "test_type:unit"]
206+
}, {
207+
"metric": "lace.tests.duration",
208+
"points": [{"timestamp": $(date +%s), "value": ${{ github.run_duration }}}],
209+
"tags": ["service:lace-wallet", "env:ci", "workflow:unitTests", "test_type:unit", "repo:${{ github.repository }}"]
202210
}]
203211
}')
204212
echo "Datadog API response: $response"
@@ -292,16 +300,19 @@ jobs:
292300
- name: Send release metrics to Datadog
293301
run: |
294302
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
295-
echo "Sending release metrics to Datadog..."
296-
response=$(curl -s -w "%{http_code}" -X POST "https://api.datadoghq.com/api/v1/series" \
303+
echo "Sending release metrics to Datadog v2..."
304+
response=$(curl -s -w "%{http_code}" -X POST "https://api.us5.datadoghq.com/api/v2/series" \
297305
-H "Content-Type: application/json" \
298306
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
299307
-d '{
300308
"series": [{
301309
"metric": "lace.release.package",
302-
"points": [[$(date +%s), 1]],
303-
"tags": ["service:lace-wallet", "env:ci", "workflow:release-pkg", "status:${{ job.status }}"],
304-
"type": "gauge"
310+
"points": [{"timestamp": $(date +%s), "value": 1}],
311+
"tags": ["service:lace-wallet", "env:ci", "workflow:release-pkg", "status:${{ job.status }}", "repo:${{ github.repository }}", "branch:${{ github.ref_name }}", "artifact:lace-browser-extension"]
312+
}, {
313+
"metric": "lace.release.duration",
314+
"points": [{"timestamp": $(date +%s), "value": ${{ github.run_duration }}}],
315+
"tags": ["service:lace-wallet", "env:ci", "workflow:release-pkg", "repo:${{ github.repository }}"]
305316
}]
306317
}')
307318
echo "Datadog API response: $response"
@@ -316,18 +327,47 @@ jobs:
316327
- name: Send final CI metrics to Datadog
317328
run: |
318329
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
319-
echo "Sending final metrics to Datadog..."
320-
response=$(curl -s -w "%{http_code}" -X POST "https://api.datadoghq.com/api/v1/events" \
330+
echo "Sending final metrics to Datadog v2..."
331+
332+
# Calculate overall pipeline status
333+
if [ "${{ needs.prepare.result }}" = "success" ] && [ "${{ needs.unitTests.result }}" = "success" ] && [ "${{ needs.release-pkg.result }}" = "success" ]; then
334+
overall_status="success"
335+
else
336+
overall_status="failure"
337+
fi
338+
339+
# Get current timestamp
340+
timestamp=$(date +%s)
341+
342+
# Send final metrics
343+
response=$(curl -s -w "%{http_code}" -X POST "https://api.us5.datadoghq.com/api/v2/series" \
321344
-H "Content-Type: application/json" \
322345
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
323-
-d '{
324-
"title": "Lace CI Pipeline Complete",
325-
"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 }}",
326-
"tags": ["service:lace-wallet", "env:ci", "workflow:ci", "repo:lace"],
327-
"alert_type": "${{ needs.prepare.result == 'success' && needs.unitTests.result == 'success' && needs.release-pkg.result == 'success' && 'info' || 'error' }}",
328-
"source_type_name": "github"
329-
}')
346+
-d "{
347+
\"series\": [{
348+
\"metric\": \"github.ci.pipeline.final_status\",
349+
\"points\": [{\"timestamp\": $timestamp, \"value\": 1}],
350+
\"tags\": [\"service:lace-wallet\", \"env:ci\", \"workflow:ci\", \"status:$overall_status\", \"repo:${{ github.repository }}\", \"branch:${{ github.ref_name }}\", \"commit:${{ github.sha }}\"]
351+
}, {
352+
\"metric\": \"github.ci.pipeline.total_duration\",
353+
\"points\": [{\"timestamp\": $timestamp, \"value\": ${{ github.run_duration }}}],
354+
\"tags\": [\"service:lace-wallet\", \"env:ci\", \"workflow:ci\", \"repo:${{ github.repository }}\", \"branch:${{ github.ref_name }}\"]
355+
}]
356+
}")
330357
echo "Datadog API response: $response"
358+
359+
# Send event using v1 API (more reliable for events)
360+
event_response=$(curl -s -w "%{http_code}" -X POST "https://api.us5.datadoghq.com/api/v1/events" \
361+
-H "Content-Type: application/json" \
362+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
363+
-d "{
364+
\"title\": \"Lace CI Pipeline Complete\",
365+
\"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 }}\nOverall: $overall_status\",
366+
\"tags\": [\"service:lace-wallet\", \"env:ci\", \"workflow:ci\", \"repo:lace\", \"status:$overall_status\"],
367+
\"alert_type\": \"$overall_status\",
368+
\"source_type_name\": \"github\"
369+
}")
370+
echo "Datadog Event API response: $event_response"
331371
else
332372
echo "No DATADOG_API_KEY provided, skipping final metrics"
333373
fi

0 commit comments

Comments
 (0)