01. The Three Pillars of Observability
When your app is live, you can’t see what’s happening. Users report errors, but you don’t know why. Server crashes, but you don’t know when. Observability gives you eyes on your running application.
There are three types of information you need:
02. Error Tracking: Catch Bugs Before Users Do
When your app crashes, you need to know immediately. Error tracking tools capture crashes automatically and alert you.
What You Need
Sentry (free tier available) captures errors with:
- The exact line of code that failed
- The user’s browser and device
- The stack trace (the chain of functions that led to the error)
- Which deployment introduced the bug
How to Set It Up
- Go to sentry.io and create a free account
- Create a new project for your website
- Sentry gives you a DSN (a URL) — copy it
- In your project, tell Lovable or Cursor: “Add Sentry error tracking using this DSN: [paste your DSN]”
- Deploy — all errors are now captured automatically
What You’ll See
When something breaks, Sentry sends you an email with:
- What happened: “TypeError: Cannot read property ‘map’ of undefined”
- Where it happened: “src/components/ProjectList.tsx, line 42”
- How many users affected: “12 users in the last hour”
- When it started: “Started after deployment v2.3.1”
03. Health Checks: Is Your App Alive?
A health check is a simple URL that returns “yes, I’m alive” when your app is running. Monitoring tools ping this URL every 30 seconds. If it doesn’t respond, they alert you.
How It Works
- Your app exposes a URL like
/health - A monitoring tool (like BetterStack or UptimeRobot) checks it every 30 seconds
- If the check fails 3 times in a row, you get an alert
- You fix the problem
- The monitor confirms it’s back online
What to Tell Your AI Tool
When building with Lovable or Cursor, add this to your prompt:
“Add a health check endpoint at /health that returns JSON with status (‘ok’ or ‘unhealthy’), timestamp, and uptime. If the database connection fails, return status ‘unhealthy’ with a 503 status code.”
04. Structured Logging: Better Than console.log
When something goes wrong, you need to see what happened. Structured logging means writing logs in a consistent format that machines can search and humans can read.
The Problem with console.log
Most developers use console.log("something happened"). This is useless in production because:
- You can’t search through thousands of messages
- You don’t know when things happened
- You don’t have context about what user or what request triggered it
The Solution: Structured Logs
Every log entry should have:
- Timestamp: When it happened
- Level: How serious (info, warn, error)
- Message: What happened
- Context: Who was affected, what request triggered it
What to Tell Your AI Tool
“Replace all console.log statements with structured logging. Each log entry should be a JSON object with: timestamp (ISO date string), level (‘info’, ‘warn’, or ‘error’), message (human-readable description), and context (object with requestId, userId, and any relevant data). For errors, also include the error message and stack trace.”
05. Crash Recovery: What Happens When Things Break
Even with monitoring, things will crash. The question is: how fast do you recover?
The Graceful Shutdown
When your app crashes or gets replaced by a new deployment, it should:
- Stop accepting new requests
- Finish processing any in-progress requests
- Close database connections cleanly
- Exit gracefully
This prevents data corruption from half-finished operations.
What to Tell Your AI Tool
“Add graceful shutdown handling that:
- Listens for SIGTERM signal
- Stops accepting new connections
- Waits for in-flight requests to complete (max 30 seconds)
- Closes database connections
- Exits cleanly
If shutdown takes longer than 30 seconds, force exit.”
06. The Monitoring Dashboard
You need a single place to see everything happening with your app. Most hosting platforms (Vercel, Railway) provide this built-in.
What to Monitor
Alert Thresholds
| Metric | Warning | Critical | Action |
|---|---|---|---|
| Error Rate | > 1% | > 5% | Check Sentry for new errors |
| Response Time (P95) | > 500ms | > 2s | Check database queries |
| CPU Usage | > 70% | > 90% | Scale up or optimize |
| Memory Usage | > 70% | > 90% | Check for memory leaks |
| Disk Usage | > 80% | > 95% | Clean up logs or scale |
07. Incident Response: When Things Go Wrong
Even with monitoring, things will break. The difference between junior and senior engineers is how fast they respond.
The 5-Step Process
The Fastest Fix
Rollback. If something breaks after a deploy, the fastest fix is almost always rolling back to the previous version.
In Vercel: Go to your project → Deployments → find the last working one → click “Promote to Production”
In Lovable: Go to GitHub → find the last working commit → click “Restore”
08. What to Tell Your AI Tool
When building with Lovable, Cursor, or any AI tool, add these to your prompts:
For Error Tracking
Add Sentry error tracking. Capture all unhandled errors
and log them with context (user ID, request ID, page URL).
Show a friendly error page to users when something crashes.
For Health Checks
Add a /health endpoint that checks:
1. Is the server running?
2. Can it connect to the database?
3. Are external APIs reachable?
Return status "healthy" or "unhealthy" with details.
For Logging
Add structured logging. Every log entry should be JSON with
timestamp, level, message, and context (requestId, userId).
Replace all console.log with this structured logger.
For Graceful Shutdown
Handle SIGTERM for graceful shutdown:
1. Stop accepting new requests
2. Wait for in-flight requests (max 30s)
3. Close database connections
4. Exit cleanly
Key Takeaways
| Concept | Mental Model | Senior Insight |
|---|---|---|
| Three Pillars | Metrics, Logs, Traces | You need all three — metrics alone tell you something is wrong but not what |
| Error Tracking | Sentry catches crashes | Set it up once, get alerts forever — free tier is enough |
| Health Checks | Simple URL that says “I’m alive” | Monitoring tools ping it every 30 seconds — if it fails, you get alerted |
| Structured Logging | JSON over console.log | Timestamp + level + message + context — queryable and searchable |
| Crash Recovery | Finish in-flight work before exit | Prevents data corruption from half-finished operations |
| Incident Response | Detect → Assess → Mitigate → Retrospective | The fastest fix is almost always a rollback |