Use logs, metrics, and traces to understand production behavior.
Lesson goal
Use metrics, a trace, and logs to investigate a slow profile request and decide when a responder needs an alert.
Before you begin — Scaling and Traffic Distribution.
A user reports that their profile took a long time to load. Was this an isolated request, or did many users experience the same delay? Observability lets you investigate questions about a running system through the signals it emits.
A metric is a numerical measurement. For a user-facing service, track request rate (how much traffic arrived), errors (how often requests failed), and duration (how long requests took). Together these are called the RED signals. Resource saturation, such as a busy disk with work waiting, helps investigate a possible cause.
Averages can hide a group of slow requests. The 95th percentile (p95) is the time at or below which roughly 95% of the observed requests finished. Compare the same operation over comparable time windows. If profile p95 rises while request volume is steady, the delay deserves investigation even when most users still get a fast response.
A trace records the path of one request. Each timed operation in that path is a span. In one example trace, the profile request takes 240 ms from start to finish. A database read inside that request takes 180 ms, consuming three quarters of its elapsed time. The read is included in the 240 ms total. Adding the two numbers would count that time twice. OpenTelemetry's guide to traces and spans
A log records an event at a particular time. Structured fields such as the operation, timestamp, and trace ID let you find events for the database read. Use that trace ID to examine what happened in this request. Compare it with other slow requests before attributing the service-wide p95 increase to the database.
An alert should tell a responder which user operation needs attention. Sustained slow profile loads can justify a page if they cross the service's agreed threshold. CPU and disk metrics can help the responder investigate. A runbook records how to check impact, what action is available, and how to verify recovery.
You have one slow trace with a long database span. What would tell you whether other profile users are affected, and what would help explain this particular database call?
Check profile latency and error metrics over the incident window to establish impact. Follow the trace ID into the logs for details of that call. The same span appearing across many slow traces would strengthen the case for investigating the database path.