Skip to content
groundworkv0.2

Observability

Logs, metrics, traces and alerts, so you know something broke before your users tell you.

8 min read · Last reviewed November 20, 2026

Observability

You can't fix what you can't see. Observability is also how you hand a production bug to an with enough context for it to actually fix it.

You'll be able to#

  • Know the three pillars and when to use each
  • Set up error tracking and uptime alerts in an afternoon
  • Write logs that are useful for both humans and agents

The mental model#

Observability is how you ask a running system questions you didn't plan for, using the evidence it gives off. That evidence comes as logs (a record of events), metrics (measurements over time) and traces (the path of one request through the system). OpenTelemetry calls these signals. Logs tell you what happened, metrics tell you how much and how often, and traces tell you where the time went.

Alongside the evidence, you need two things: someone watching it for problems users would notice (alerts), and a way to hand the evidence to whoever, or whatever, fixes the bug.

Key concepts#

  • Logs: Timestamped events. Structured logs (JSON with fields like userId, requestId) are searchable. Use levels: debug, info, warn, error.
  • Metrics: Numbers over time, such as request rate, error rate, latency (p50/p95/p99), CPU and DB connections.
  • Traces: The path of a single request through services and DB calls, with timings. OpenTelemetry is the vendor-neutral standard.
  • Error tracking: Captures exceptions with stack traces and context (Sentry, Highlight, PostHog). This gives you the most for the least effort.
  • Uptime monitoring: External pings to your health endpoint (Better Stack, UptimeRobot, Checkly).
  • Alerts: Notifications when something crosses a threshold. Alert on symptoms (error rate, latency), not every blip.
  • Request ID / correlation ID: One ID attached to every log line for a request.
  • Product analytics: What users do (PostHog, Plausible). This is separate from system health.

Decisions you make (not the agent)#

Your call, not the agent's

DecisionSensible defaultChoose otherwise when…
ErrorsSentry (or equivalent) on frontend + backend—
LogsPlatform logs + structured JSONScale → Axiom, Better Stack, Datadog, Grafana Loki
UptimeExternal check on /health every 1–5 min—
AlertsError-rate spike + downtime → phone/Slack—
PII in logsNever log passwords, tokens, full card numbers; minimize personal data—

What good output looks like#

  • Logs are structured, with a request ID on every line, so one request can be followed from start to finish
  • Errors are captured with a stack trace and context, and none are silently swallowed
  • The things you watch include latency (not only the average), traffic, errors and how full the system is
  • Alerts fire on symptoms users would notice, and each one needs a person to act
  • No passwords, tokens, keys or personal data appear in logs

Red flags#

  • console.log("here") as the logging strategy
  • Errors swallowed with an empty catch {}
  • Logs that contain tokens or passwords
  • Alerts so noisy that everyone ignores them
  • Common agent mistakes: logging a whole request object, which includes the Authorization header and cookies; an alert on every error log line; reporting only the average latency; catching an error just to log error.message, dropping the stack trace and context

Worked example#

Task: Users say checkout "sometimes fails." You hand it to an agent.

The app logs console.log("here") in a few places and has no error tracking and no request IDs. The agent reads the code, picks the most likely suspect, adds a retry around the payment call, and reports it fixed.

What a good result contains: first, evidence. Error tracking shows the exception and its context, structured logs let you follow one failing request by its ID, and a chart of the error rate shows when it began and whether the change helped. Then a fix with a test that reproduces the failure.

The wrong turn: nothing was observed, so the "fix" is a guess. The retry may hide the problem, or double-charge. And in trying to add logging, the agent logs the entire request object on every checkout, including the Authorization header, so tokens now sit in your logs. OWASP's logging guidance lists access tokens, session IDs, passwords, connection strings and payment data as things not to log.

How review catches it: ask what did you observe that showed this was the cause? Then add the missing signals: error tracking, a request ID on every log line, and a chart of error rate and latency. Search the logs for tokens. Re-run the investigation with real evidence, and only then fix it, with a failing test first.

Sample prompts#

Weak vs strong#

Strong prompt
Add observability to this app: Sentry for client and server errors with source
maps and release tracking; a structured logger (pino) with a requestId on every
log line; a /health endpoint that checks DB connectivity; and remove any logging
of secrets or PII. Show me where errors were previously being swallowed.

Why it works: It names the error tracker, a structured logger with a request ID on every line, a health check that tests the database, and tells the agent to remove secrets and personal data from logs.

What changed

  • Error tracking covers client and server, with source maps and release tracking
  • Structured logs carry a requestId on every line
  • A health endpoint checks the database, not just that the process is up
  • Secrets and PII are explicitly removed
  • Swallowed errors are found and reported
Prompt
Here's a Sentry error with stack trace and breadcrumbs: <paste>. Find the root
cause in this codebase, explain it, write a failing test that reproduces it, then
fix it.

Why it works: It hands over the evidence and requires a reproducing test before the fix, which stops the agent from changing code on a guess.

Audit logging and error handling#

Prompt
Audit logging and error handling in this codebase. Find: places that log whole request or response objects, headers, tokens, passwords, connection strings or personal data; empty catch blocks and errors that are caught and dropped; logs without a request ID; and error handlers that log only the message and lose the stack trace. List each finding with file and line, and the fix. Don't change anything yet.

Why it works: It targets the specific mistakes agents make with logging, and each finding is easy to check.

Decide what should page a human#

Prompt
Propose an alerting setup for this service. For every alert, answer: is it urgent, is it visible to users, does it need a person's judgement, and could it wait until morning? Alert on symptoms (error rate, latency, downtime), not on individual causes. Anything that doesn't need a person right now goes on a dashboard instead. List what we should watch for latency, traffic, errors and saturation.

Why it works: The questions come from Google's SRE guidance: a page should be urgent and actionable, and noisy pages get ignored.

Explain how to trace one request#

Prompt
Using only what the app currently logs and reports, explain how I would follow one failing checkout from the browser to the database. List each step, what evidence exists at each one, and where there is a gap. Then propose the smallest change that closes the biggest gap.

Why it works: It makes missing observability visible before the next incident does.

Check your understanding#

Check your understanding

1/4Which of these should page a person in the middle of the night?
2/4Which of these should not be written to logs?
3/4Why look at 95th or 99th percentile latency and not just the average?
4/4Which are the four golden signals?

Checklist#

  • Errors are tracked on the client and the server, with context
  • Every log line carries a request ID, and logs are structured
  • Nothing secret or personal is logged
  • I watch latency (including percentiles), traffic, errors and saturation
  • Alerts are symptoms that need a person, and everything else is on a dashboard
  • A health check tests the database, not just that the process is running

Go deeper#