Canary: Post-Deploy Monitoring
Watch a live application after deployment. Alert on errors and regressions. Compare against a pre-deploy baseline.
Two modes:
--baseline: capture the current state BEFORE deploying- (default): monitor AFTER deploying and compare against baseline
Instructions
Phase 1: Setup
Parse the user's arguments and detect the deployment context.
bash
# Detect current branch and recent deploy commit
git branch --show-current
git log --oneline -5
# Auto-detect platform from config files
[ -f fly.toml ] && echo "PLATFORM: fly"
[ -f render.yaml ] && echo "PLATFORM: render"
[ -f vercel.json ] && echo "PLATFORM: vercel"
[ -f netlify.toml ] && echo "PLATFORM: netlify"
[ -f Procfile ] && echo "PLATFORM: heroku"
[ -f railway.toml ] && echo "PLATFORM: railway"
# Check for health endpoint
curl -sf "${URL}/health" -w "\n%{http_code}" 2>/dev/null | tail -1
curl -sf "${URL}/api/health" -w "\n%{http_code}" 2>/dev/null | tail -1Create the working directory:
bash
mkdir -p .canary/baselines .canary/reports .canary/screenshotsPhase 2: Baseline Capture (--baseline mode)
Run this BEFORE deploying to capture the current healthy state.
For each page to monitor, record:
- HTTP status: is the page returning 200?
- Response time: how long does it take to load?
- Content snapshot: key text content to detect blank pages later
bash
# For each page URL
for PAGE_PATH in "/" "/dashboard" "/settings" "/api/health"; do
SLUG=$(echo "$PAGE_PATH" | tr '/' '_' | tr -d '?&=')
RESULT=$(curl -sf -o /dev/null -w "%{http_code}|%{time_total}" "${BASE_URL}${PAGE_PATH}" 2>/dev/null)
STATUS=$(echo "$RESULT" | cut -d'|' -f1)
TIME_MS=$(echo "$RESULT" | awk -F'|' '{printf "%.0f", $2 * 1000}')
echo " ${PAGE_PATH}: HTTP ${STATUS}, ${TIME_MS}ms"
doneSave baseline to .canary/baselines/baseline.json:
json
{