@@ -16,21 +16,23 @@ jobs:
16
16
- name : Send CI metrics to Datadog
17
17
run : |
18
18
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" \
21
21
-H "Content-Type: application/json" \
22
22
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
23
23
-d '{
24
24
"series": [{
25
25
"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 }}"]
29
28
}, {
30
29
"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 }}"]
34
36
}]
35
37
}')
36
38
echo "Datadog API response: $response"
@@ -105,16 +107,19 @@ jobs:
105
107
- name : Send build metrics to Datadog
106
108
run : |
107
109
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" \
110
112
-H "Content-Type: application/json" \
111
113
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
112
114
-d '{
113
115
"series": [{
114
116
"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 }}"]
118
123
}]
119
124
}')
120
125
echo "Datadog API response: $response"
@@ -189,16 +194,19 @@ jobs:
189
194
- name : Send test metrics to Datadog
190
195
run : |
191
196
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" \
194
199
-H "Content-Type: application/json" \
195
200
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
196
201
-d '{
197
202
"series": [{
198
203
"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 }}"]
202
210
}]
203
211
}')
204
212
echo "Datadog API response: $response"
@@ -292,16 +300,19 @@ jobs:
292
300
- name : Send release metrics to Datadog
293
301
run : |
294
302
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" \
297
305
-H "Content-Type: application/json" \
298
306
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
299
307
-d '{
300
308
"series": [{
301
309
"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 }}"]
305
316
}]
306
317
}')
307
318
echo "Datadog API response: $response"
@@ -316,18 +327,47 @@ jobs:
316
327
- name : Send final CI metrics to Datadog
317
328
run : |
318
329
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" \
321
344
-H "Content-Type: application/json" \
322
345
-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
+ }")
330
357
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"
331
371
else
332
372
echo "No DATADOG_API_KEY provided, skipping final metrics"
333
373
fi
0 commit comments