Part III β The Speed Β· Lesson 7.1
Logging & Monitoring Overview
In one lineLogs, metrics, and traces answer three different questions β you need all three to debug production.
Where you've seen itCheckout starts failing at 2am. The graph would have shown it instantly; instead the sales team reports it at 9am.
Diagram
THE THREE PILLARS
ββββββββββββββββ¬βββββββββββββββββββββββ¬βββββββββββββββββββββββββ
β METRICS β LOGS β TRACES β
ββββββββββββββββΌβββββββββββββββββββββββΌβββββββββββββββββββββββββ€
β numbers over β discrete events with β one request's path β
β time β context β across services β
β β β β
β "error rate β "TypeError: cannot β "this checkout spent β
β is 4.2%" β read 'id' of undef, β 1.8s in pricing, β
β β user 91, /checkout" β 40ms in inventory" β
ββββββββββββββββΌβββββββββββββββββββββββΌβββββββββββββββββββββββββ€
β IS something β WHAT exactly β WHERE in the system β
β wrong? β happened? β did it go wrong? β
ββββββββββββββββΌβββββββββββββββββββββββΌβββββββββββββββββββββββββ€
β cheap, fast, β expensive at volume, β moderate, needs β
β aggregate β precise β propagated ids β
ββββββββββββββββ΄βββββββββββββββββββββββ΄βββββββββββββββββββββββββTHE LOOP β this chapter in one picture
ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ
β COLLECT ββββΊβ ALERT ββββΊβ TRIAGE ββββΊβ FIX β
β (7.2) β β (7.3) β β (7.4) β β (7.4) β
ββββββββββββ ββββββββββββ ββββββββββββ ββββββ¬ββββββ
β² β
βββββββββ add the signal you wished ββββββββββ
you'd had during triageFRONTEND-SPECIFIC SIGNALS β what the backend can't see
JS errors + stack traces (needs source maps β 7.4)
unhandled promise rejections the most-missed one
failed fetches by endpoint including CORS and network drops
Core Web Vitals from real users (5.3)
rage clicks / dead clicks UX breakage with no exception
console errors from 3rd parties your CSP violations too (3.4)How it works
- Metrics for detection. Cheap to store, fast to query, and what alerts fire on.
- Logs for explanation. Sampled and structured, they tell you what happened in a specific failing session.
- Traces for location. A propagated request id ties a browser action to the backend spans it caused.
- Correlate with releases. Every signal should carry a build id, or "what changed?" is unanswerable.
- Close the loop. After each incident, add the one signal that would have made triage faster.
Trade-offs
| Signal | Volume | Cost | Use for |
|---|---|---|---|
| Metrics | low | low | Alerting, dashboards, trends |
| Logs | high | high | Root cause on a specific case |
| Traces | medium | medium | Cross-service latency |
| Session replay | very high | very high | Hard-to-reproduce UX bugs |
Interview angle
"How do you know your frontend is healthy in production?"
- Metrics first: JS error rate, failed request rate, and p75 Web Vitals, all sliced by release.
- Alert on user-visible symptoms rather than causes β checkout success rate beats CPU usage.
- Then logs and traces for depth, with a request id that connects a browser session to backend spans.
Recap
- Metrics say is something wrong; logs say what; traces say where.
- Tag everything with a release id β the first triage question is always "what shipped?"
- Every incident should end by adding the signal you wished you'd had.