Page 6 of 8~104 min topic

API errors & retries

Add observability and tests

Metrics for retry_attempts_total{outcome} and p95 wall_ms ≤ 8000 must distinguish bad input from component failure for mobile client waiting on a grounded answer.

~13 min this pageObservability

1Learn the idea

Read

Golden signals for this system

Instrument resilient TypeScript fetch wrapper around POST /v1/chat so mobile client waiting on a grounded answer can answer: demand, errors, latency/age, saturation. Emit fields needed by retry_attempts_total{outcome} and p95 wall_ms ≤ 8000 with bounded labels. Sample successful high-volume traces; keep errors and rollout transitions denser within policy.

Read

Alert path worth paging

Define at least one alert that would fire for INC-429-2026-07-11, with a for/pending window that survives deploy blips. Missing scrape or missing revision labels must not look like health. Include a trace/log example id format you will actually search.

Read

Implementation artifact

metrics.increment("retry_attempts_total", { outcome: result.ok ? "ok" : result.code, attempts: String(result.attempts) });
span.setAttributes({ "http.retry_attempts": result.attempts, "http.retry_after_ms": result.retryAfterMs ?? 0 });

Read

Tests for telemetry

Add a unit/integration check that metrics increment on the happy path and on the 429 storm with missing Retry-After that would amplify to 40 calls branch. Store machine-readable output in CI artifacts when practical.

Read

Stage depth

Cardinality discipline: tenant and revision are usually enough; raw question text is not a label. Exemplars or trace links beat screenshots alone when debugging INC-429-2026-07-11. Define who owns alert fatigue review. If you export to a vendor, record retention and access. Synthetic probes should use non-sensitive fixtures and still exercise POST /v1/chat. Practice the query you will type at 2am once, while calm.

Read

Field notes for `api-error-handling` / `observability`

Document the exact PromQL or log query in the runbook stub for this service. Verify histograms have buckets around your SLO target. Add a canary synthetic check that exercises the oracle path every few minutes in staging. Confirm that PII redaction happens before export. Track build/version as a label on the golden signals. Delete noisy debug logs before they become accidental product dependencies. In this chapter the product is resilient TypeScript fetch wrapper around POST /v1/chat, the human stakeholder is mobile client waiting on a grounded answer, and the incident id you design against is INC-429-2026-07-11. Re-state the oracle in your notes — 429 + Retry-After:2 → sleep once → 200 with attempts=2 — and keep the invariant visible: attempts ≤ 3, wall budget ≤ 8s, non-idempotent POSTs never replay without Idempotency-Key. Track retry_attempts_total{outcome} and p95 wall_ms ≤ 8000 as the scoreboard. Surface under change control: POST /v1/chat. If you only have forty minutes, finish the fixture for 429 storm with missing Retry-After that would amplify to 40 calls before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.

Go deeper

Before you start

Why this matters

Name the dashboard row or log line mobile client waiting on a grounded answer opens first during INC-429-2026-07-11. It must include a correlation id and a bounded label from retry_attempts_total{outcome} and p95 wall_ms ≤ 8000. If telemetry is missing, write whether you promote, hold, or roll back — and why hold is the default.

In the wild

See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Can you jump from alert to INC-429-2026-07-11-class evidence?
2. Do labels stay low-cardinality?
3. Is missing telemetry treated as hold?

All responses are required.