Skip to content

Commit

Permalink
Fix Slack bot for monitor API test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
lym953 committed Nov 11, 2024
1 parent 3d07d2b commit 5e05bc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/monitor_api_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,16 @@ jobs:
DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
run: npm run test:integration

notify:
runs-on: ubuntu-latest
needs: integration-tests
steps:
- name: Send failure message to Slack
env:
SLACK_CHANNEL: "#serverless-onboarding-and-enablement-ops"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
if: failure()
run: |
set -x
OPS_MESSAGE=":gh-check-failed: Serverless Plugin failed to fetch recommended monitors from monitor API!
OPS_MESSAGE=":gh-check-failed: Yiming's test: Serverless Plugin failed to fetch recommended monitors from monitor API!
Please check GitHub Action log: https://github.com/DataDog/serverless-plugin-datadog/actions/workflows/monitor_api_integration_test.yml"
curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" -d '{
"channel": "'"$SLACK_CHANNEL"'",
"text": "'"$OPS_MESSAGE"'"
}'
3 changes: 3 additions & 0 deletions src/monitor-api-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export async function getRecommendedMonitors(
): Promise<{
[key: string]: ServerlessMonitor;
}> {
if (site == "datadoghq.com") {
throw new Error("Yiming killed me!");
}
const recommendedMonitors: { [key: string]: ServerlessMonitor } = {};
// Setting a count of 50 in the hope that all can be fetched at once. The default is 10 per page.
const endpoint = `https://api.${site}/api/v2/monitor/recommended?count=50&start=0&search=tag%3A%22product%3Aserverless%22%20AND%20tag%3A%22integration%3Aamazon-lambda%22`;
Expand Down

0 comments on commit 5e05bc6

Please sign in to comment.