FSD Frontend System Design

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.

  • Time13 min
  • DiagramThree pillars and the questions each one answers
  • Chapter7 Β· Logging & Monitoring

Diagram

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         β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
diagram
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 triage
diagram
FRONTEND-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

  1. Metrics for detection. Cheap to store, fast to query, and what alerts fire on.
  2. Logs for explanation. Sampled and structured, they tell you what happened in a specific failing session.
  3. Traces for location. A propagated request id ties a browser action to the backend spans it caused.
  4. Correlate with releases. Every signal should carry a build id, or "what changed?" is unanswerable.
  5. Close the loop. After each incident, add the one signal that would have made triage faster.

Trade-offs

SignalVolumeCostUse for
MetricslowlowAlerting, dashboards, trends
LogshighhighRoot cause on a specific case
TracesmediummediumCross-service latency
Session replayvery highvery highHard-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.