canary

Post-deploy canary monitor. Establishes a baseline (p50/p95 latency + error rate) in ~/.dog/canary/{slug}/baseline.json, polls metrics after deploy, and alerts if any metric exceeds 2σ above baseline. Use after deploying to production to detect regressions before they escalate.

/dog:canary — Post-Deploy Canary Monitor

Establishes a performance baseline, then polls metrics after a deploy and alerts on anomalies exceeding 2 standard deviations above the baseline.

When to Use

  • Immediately after a production deployment
  • After /dog:land completes the merge + CI cycle
  • When you suspect a deploy introduced a latency or error-rate regression

When NOT to Use

  • Before a baseline has been established — run /dog:canary baseline first
  • On services with no accessible metrics endpoint

Commands

/dog:canary baseline <url>     → capture baseline metrics (run before deploy)
/dog:canary check <url>        → poll metrics and compare to baseline
/dog:canary watch <url>        → poll N times (default: 5) with 30s interval

Baseline Schema

File: ~/.dog/canary/{slug}/baseline.json

{
  "url": "https://api.example.com/health",
  "captured_at": "2026-04-15T12:00:00Z",
  "commit_sha": "abc1234",
  "samples": 10,
  "p50_ms": 120,
  "p95_ms": 350,
  "error_rate": 0.01,
  "stddev_p50": 15,
  "stddev_p95": 40,
  "stddev_error_rate": 0.003
}

Process

Baseline capture

  1. Send N=10 requests to <url> (sequential, 1s apart)
  2. Measure response time (ms) and status code for each
  3. Compute: p50, p95, error_rate (non-2xx / total)
  4. Compute standard deviations across samples
  5. Save to ~/.dog/canary/{slug}/baseline.json
SLUG=$(echo "$URL" | sed 's|[/:.]|-|g')
mkdir -p ~/.dog/canary/${SLUG}

Report:

Baseline captured:
  URL: https://api.example.com/health
  Samples: 10
  p50: 120ms  p95: 350ms  error_rate: 1.0%
  Saved: ~/.dog/canary/api-example-com-health/baseline.json

Check (single poll)

  1. Load baseline from ~/.dog/canary/{slug}/baseline.json
  2. Send N=5 requests to <url>
  3. Compute current p50, p95, error_rate
  4. Compare to baseline thresholds: baseline + 2σ

Anomaly detection:

threshold_p50      = baseline.p50_ms + 2 × baseline.stddev_p50
threshold_p95      = baseline.p95_ms + 2 × baseline.stddev_p95
threshold_err_rate = baseline.error_rate + 2 × baseline.stddev_error_rate

if current_p50 > threshold_p50:    ALERT
if current_p95 > threshold_p95:    ALERT
if current_error_rate > threshold_err_rate: ALERT

Report (healthy):

Canary check: ✓ HEALTHY
  p50: 115ms (threshold: 150ms) ✓
  p95: 330ms (threshold: 430ms) ✓
  error_rate: 0.8% (threshold: 1.6%) ✓

Report (anomaly):

Canary check: ✗ ANOMALY DETECTED
  p50: 115ms (threshold: 150ms) ✓
  p95: 520ms (threshold: 430ms) ✗  ← +90ms above threshold
  error_rate: 4.2% (threshold: 1.6%) ✗  ← +2.6% above threshold

Action required: investigate before rolling forward.

Watch (repeated polling)

Run check N times (default: 5) with 30s intervals between polls. Report each poll inline. Stop early on anomaly if --fail-fast flag is set.

for i in $(seq 1 5); do
  echo "Poll $i/5..."
  # run check
  sleep 30
done

Verification

After baseline capture:

SLUG=$(echo "$URL" | sed 's|[/:.]|-|g')
cat ~/.dog/canary/${SLUG}/baseline.json | jq .p50_ms

Expected: a positive number (milliseconds).

Related

  • Skill: dog:deployment-patterns, dog:land-and-deploy
  • Command: /dog:land, /dog:ship
  • Agent: performance-optimizer