-
Define on-call questions first — before adding any instrumentation, write down 2–4 questions an engineer will ask about this feature when it breaks:
FEATURE: checkout payment retry
QUESTIONS ON-CALL WILL ASK:
1. What fraction of payments succeed on first attempt vs after retry?
2. When a payment fails permanently, why? (provider error? timeout? validation?)
3. Is the payment provider slower than usual?
→ Every signal below must help answer one of these.
If you can't name the questions, you're not ready to instrument — you'll log everything and learn nothing.
-
Pick the right signal for each question:
| Signal | Answers | Example |
|---|
| Structured log | "What happened in this specific case?" | payment_failed with provider error code + attempt count |
| Metric | "How often / how fast in aggregate?" | p99 latency histogram of provider calls |
| Trace | "Where did time go across services?" | One slow checkout broken down by hop |
-
Structured logs — log events not prose. Every log line is a JSON object with a stable event name and machine-readable fields. Attach a requestId to every line. Use consistent log levels: error (someone may need to act), warn (degraded but handled), info (significant business event), debug (off in production by default). Never log secrets, tokens, passwords, or full PII.
-
RED metrics on every endpoint and external dependency — Rate (requests/sec), Errors (failure rate), Duration (latency histogram, p95/p99 — never averages). Labels must come from small fixed sets; never use user IDs, raw URLs, or error message text as labels (cardinality bomb).
-
Alert on symptoms users feel, not infrastructure causes:
- Page-worthy: error rate > 1% for 5 min, p99 latency > 2s, queue age > 10 min
- Not page-worthy: CPU at 85%, one pod restarted, disk at 70%
Every alert must be actionable and link to a runbook.
-
Verify the telemetry before shipping — trigger the path in staging, find the log line by requestId, confirm metric series appear with correct labels, follow one trace end-to-end without broken spans.