Capstone: Monitor an App End to End, Worked Example
Your team launches a small web shop next week, and someone asks: "If checkout breaks at 2 a.m., how will we know, and how fast can we find out why?" This capstone answers it by showing you how to monitor an app end to end: every idea from this course, applied in order to one small app, from the first target to a pretend incident.
Meet the example app
The shop has four parts. Shoppers' browsers call a frontend that serves pages and a small API. The frontend calls a checkout service written in Python, which keeps orders and stock in PostgreSQL and charges cards through an external payment provider's HTTPS API. You own the first three. The payment provider is someone else's code, so you can only measure it from your side.
Both services run the OpenTelemetry SDK from the previous lesson and send OTLP to one Collector, which feeds Prometheus, Loki and Jaeger. Checkout also runs the Pyroscope SDK for continuous profiling, and Grafana reads all four stores.
Steps 1 and 2: user journeys and SLOs
The method is a loop of seven steps. It starts from users, not servers, and each step uses the output of the one before it.
A user journey is a task a customer wants to complete. This shop has two that matter: browsing products and placing an order. Placing an order earns the money, so it gets the strictest targets, and every later step serves it. Next, write SLOs as in the SLI, SLO and SLA lesson, each with a precise SLI:
- Availability: 99.9% of checkout requests succeed over 30 days. The SLI is non-5xx responses divided by all responses. A 4xx answer, such as a declined card, means the system worked, so it counts as good.
- Latency: 95% of checkout requests finish in under 400 ms over 30 days, which is "p95 under 400 ms" from the percentiles lesson.
At 20,000 checkouts a day, the availability SLO allows 0.1% of 600,000 monthly requests to fail: 600 failed checkouts. Writing that number down turns a wish ("checkout should be reliable") into something you can alert on.
Steps 3 and 4: choose signals and instrument
Pick signals for each part, using RED and USE as the checklist. Every service gets RED metrics: rate, errors and duration. One OTel histogram, http.server.request.duration, provides all three: its count gives the rate, its status-code attribute splits out errors, and its buckets hold durations. PostgreSQL gets USE metrics, such as connections in use, from postgres_exporter, a Prometheus exporter.
Logs are JSON, as in the structured logging lesson, and the OTel logging instrumentation adds the current trace and span IDs to every line. That lets you jump from a slow trace straight to its log lines. Here is one checkout log line, wrapped for reading (in the file it is a single line):
{"timestamp":"2026-11-24T14:07:31.482Z","level":"INFO","service":"checkout",
"message":"discounts applied","order_id":"o-81723","rules_evaluated":4800,
"duration_ms":610,"trace_id":"4bf92f3577b34da6a3ce929d0e0e4736","span_id":"00f067aa0ba902b7"}
Order IDs and rule counts belong in logs and span attributes like these, never in metric labels, where every new value would create a new time series (see labels and cardinality). Checkout also gets manual spans around its business steps, reserve_stock, apply_discounts and charge_card. It is the only service with profiling, because its pricing rules make it the CPU-heavy one.
Amber cells are decisions, not failures. Frontend profiling can wait until its CPU grows. The browser row matters more: nothing measures what users see before a request reaches the frontend. Real-user monitoring, a small script in the page that reports load times and JavaScript errors, would fill it.
Steps 5 and 6: one dashboard and two pages
Build one overview dashboard that answers "is checkout healthy?" in five seconds, as in the dashboards lesson. The top row shows both SLIs and the error budget left this month, the second shows RED for frontend, checkout and the payment client, and the third shows PostgreSQL connections and checkout CPU. Deploy annotations draw a line across all panels for every release.
Then alert on symptoms, as the alerting lesson recommends. The Collector's Prometheus exporter, with resource_to_telemetry_conversion enabled, turns the histogram into http_server_request_duration_seconds_* series with a service_name label. Some Python instrumentation still needs OTEL_SEMCONV_STABILITY_OPT_IN=http to emit these stable names. The rules read:
groups:
- name: checkout-slo
rules:
- alert: CheckoutErrorBudgetBurn
expr: |
sum(rate(http_server_request_duration_seconds_count{service_name="checkout", http_response_status_code=~"5.."}[1h]))
/ sum(rate(http_server_request_duration_seconds_count{service_name="checkout"}[1h]))
> 14.4 * 0.001
for: 5m
labels: {severity: page}
annotations:
summary: "Checkout is spending its 30-day error budget 14x too fast"
runbook_url: "https://runbooks.example.com/checkout-errors"
- alert: CheckoutLatencyHigh
expr: |
histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name="checkout"}[5m])))
> 0.4
for: 10m
labels: {severity: page}
annotations:
summary: "Checkout p95 latency above 400 ms for 10 minutes"
runbook_url: "https://runbooks.example.com/checkout-latency"
The first rule is a burn-rate alert. It pages when the last hour's error ratio is 14.4 times the 0.1% budget, a pace that spends 2% of the month's budget in one hour. The second pages when p95 stays above 400 ms for ten minutes. A third rule, not shown, opens a ticket, not a page, for slow burns over three days.
Each rule links a runbook, the page of first steps for whoever is on call. One caveat: histogram_quantile estimates between bucket edges, and the default OTel buckets jump from 0.25 s to 0.5 s. Add a 0.4 s boundary with an SDK view if you want the latency SLI to be exact.
Step 7: a pretend incident, from alert to root cause
A plan is proven only when you use it. Run a drill: pick a realistic failure and follow the signals as an on-call engineer would. Here, a release at 14:02 changed how coupons are matched.
- Alert. At 14:15,
CheckoutLatencyHighpages. The burn-rate alert stays quiet: orders succeed, they are just slow. - Dashboard. Checkout p95 is 900 ms, up from 250 ms, starting at the 14:02 deploy line. PostgreSQL and payment latency are flat, but checkout CPU has jumped from 30% to 85%.
- Trace. In Jaeger you search service
checkoutwith a minimum duration of 500 ms. The waterfall showsapply_discountstaking 610 ms of an 880 ms request, whilecharge_cardtakes a normal 120 ms. - Logs. You search Loki for that trace ID with
{service_name="checkout"} |= "4bf92f3577b34da6a3ce929d0e0e4736". The line showsrules_evaluatedat 4,800, against about 40 before the release. - Profile. In Pyroscope you compare checkout's CPU after 14:02 with the hour before. The diff flame graph shows a new wide block: regular-expression compilation inside
match_coupon, using 55% of CPU. The new code checks all 4,800 coupon rules and compiles each pattern again on every request.
You roll back first, so p95 returns to 250 ms within minutes, and fix the code afterwards by compiling the patterns once at startup. Then list the gaps the drill exposed: the span had no rule-count attribute, profiles were not tagged with the release version, and no load test ran before the deploy. Each gap becomes a ticket, and the loop starts again.
Check yourself
Why does a declined card (a 4xx response) count as a good event in the checkout availability SLI?
The system worked and gave a correct answer; counting it as bad would let customer behaviour, not reliability, spend the error budget.
In the drill, why did the burn-rate alert stay quiet while the latency alert paged?
Orders still succeeded, so the error SLI was healthy and only the latency SLI was breached, which is why each SLO needs its own alert.
Why does the payment API have client metrics and spans but no profiles?
It is another company's code, so you can measure only your calls to it; profiles show where CPU goes inside code you run.
Go deeper
- Observability vs Monitoring: Understanding the Difference: how the monitoring plan you just built fits into the wider idea of observability.