Skip to content

Commit 2b75247

Browse files
authored
add send metric (#183)
1 parent 67b6fa8 commit 2b75247

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,20 @@ jobs:
9999
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
100100
RUNTIME_PARAM: ${{ matrix.runtime-param }}
101101
run: ./scripts/run_integration_tests.sh
102+
103+
- name: Send success metric
104+
env:
105+
DD_API_KEY: ${{ secrets.DD_API_KEY }}
106+
run: ./scripts/send_status_metric.sh 0 $DD_API_KEY
107+
108+
integration-test-failure:
109+
runs-on: ubuntu-latest
110+
needs: [integration-test]
111+
if: always() && (needs.integration-test.result == 'failure')
112+
steps:
113+
- name: Checkout
114+
uses: actions/checkout@v2
115+
- name: Send a failure metric
116+
env:
117+
DD_API_KEY: ${{ secrets.DD_API_KEY }}
118+
run: ./scripts/send_status_metric.sh 1 $DD_API_KEY

scripts/send_status_metric.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
if [ -z $GITHUB_REF ]; then
2+
echo "GITHUB_REF is not set, not sending the metric"
3+
exit 0
4+
fi
5+
6+
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
7+
echo "Not on the main branch, not sending the metric"
8+
exit 0
9+
fi
10+
11+
#Retrieve the status
12+
# 0 means success
13+
# 1 means failure
14+
STATUS=$1
15+
16+
API_KEY=$2
17+
CURRENT_TIME=$(date +%s)
18+
19+
#Send the metric
20+
curl -H "Content-type: application/json" \
21+
-H "DD-API-KEY: ${API_KEY}" \
22+
-d "{ \"series\" :
23+
[{\"metric\":\"serverless.integration_test.python.status\",
24+
\"points\":[[$CURRENT_TIME, $STATUS]],
25+
\"type\":\"gauge\",
26+
\"tags\":[\"service:serverless-integration-test\"]}
27+
]
28+
}" \
29+
'https://app.datadoghq.com/api/v1/series'

0 commit comments

Comments
 (0)