Skip to content

Commit e694019

Browse files
committed
chore: add ci metrics to working test-datadog
1 parent 916a36e commit e694019

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

.github/workflows/test-datadog.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
if [ -n "${{ secrets.DATADOG_API_KEY }}" ]; then
2828
echo "✅ API Key is set, proceeding with test..."
2929
30-
# Prepare the JSON payload (v2 API format)
30+
# Prepare the JSON payload (v2 API format) - Testing CI metrics
3131
json_payload="{
3232
\"series\": [{
3333
\"metric\": \"test.datadog.integration\",
@@ -37,6 +37,14 @@ jobs:
3737
\"metric\": \"test.datadog.simple\",
3838
\"points\": [{\"timestamp\": $(date +%s), \"value\": 100}],
3939
\"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\"]
40+
}, {
41+
\"metric\": \"github.ci.pipeline.duration\",
42+
\"points\": [{\"timestamp\": $(date +%s), \"value\": 120}],
43+
\"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\", \"job:test-datadog\"]
44+
}, {
45+
\"metric\": \"github.ci.pipeline.status\",
46+
\"points\": [{\"timestamp\": $(date +%s), \"value\": 1}],
47+
\"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\", \"status:success\"]
4048
}]
4149
}"
4250
@@ -86,12 +94,50 @@ jobs:
8694
echo " 4. Ensure you're looking at us5.datadoghq.com"
8795
fi
8896
97+
# Test CI Events functionality
98+
echo ""
99+
echo "📝 Testing CI Events..."
100+
event_payload="{
101+
\"title\": \"Test Datadog CI Event: ${{ github.workflow }}\",
102+
\"text\": \"Test workflow ${{ github.workflow }} completed successfully\\nRepository: ${{ github.repository }}\\nBranch: ${{ github.ref_name }}\\nCommit: ${{ github.sha }}\",
103+
\"tags\": [\"service:lace-wallet\", \"env:test\", \"workflow:test-datadog\", \"status:success\", \"repo:${{ github.repository }}\"],
104+
\"alert_type\": \"info\",
105+
\"source_type_name\": \"github\"
106+
}"
107+
108+
echo "📤 Sending CI event payload:"
109+
echo "$event_payload"
110+
echo ""
111+
112+
event_response=$(curl -s -w "\nHTTP_STATUS_CODE:%{http_code}\nTOTAL_TIME:%{time_total}s\n" \
113+
-X POST "https://api.us5.datadoghq.com/api/v1/events" \
114+
-H "Content-Type: application/json" \
115+
-H "DD-API-KEY: ${{ secrets.DATADOG_API_KEY }}" \
116+
-d "$event_payload")
117+
118+
event_http_code=$(echo "$event_response" | grep "HTTP_STATUS_CODE:" | cut -d: -f2)
119+
event_response_body=$(echo "$event_response" | sed '/HTTP_STATUS_CODE:/d' | sed '/TOTAL_TIME:/d')
120+
121+
if [ "$event_http_code" = "202" ]; then
122+
echo "✅ SUCCESS: CI Event sent successfully to Datadog!"
123+
else
124+
echo "❌ ERROR: Failed to send CI Event to Datadog"
125+
echo " Status: $event_http_code"
126+
echo " Error: $event_response_body"
127+
fi
128+
89129
echo ""
90130
echo "🔍 To verify in Datadog UI:"
91131
echo " 1. Go to Metrics Explorer"
92132
echo " 2. Search for: test.datadog.integration"
93133
echo " 3. Set time range to 'Last 1 hour'"
94134
echo " 4. Look for metrics with tags: service:lace-wallet, env:test"
135+
echo ""
136+
echo "📊 Also check for CI metrics:"
137+
echo " 5. Search for: github.ci.pipeline.duration"
138+
echo " 6. Search for: github.ci.pipeline.status"
139+
echo " 7. Check Events tab for CI events"
140+
echo " 8. Look for event titled: 'Test Datadog CI Event: test-datadog'"
95141
96142
else
97143
echo "❌ ERROR: DATADOG_API_KEY secret is not set"

0 commit comments

Comments
 (0)