Metrics, logs and traces
Start with a question, not a dashboard
Observability is the ability to reason about the internal behavior of a system using evidence it emits. Monitoring checks known conditions; observability helps investigate new questions. A fictional bookstore has an API, inventory service and database. A customer reports slow checkout. Before changing infrastructure, ask: Which requests are slow? When did it start? Which dependency contributed to the delay? Was there a recent configuration change?
Every measurement below is deliberately synthetic, not a measurement of any real system. You can analyze it offline without an account.
Choose the signal
| Signal | Example | Best use |
|---|---|---|
| Metric | checkout requests per minute | Trends and alert conditions |
| Log | inventory timeout event with timestamp | Detailed event investigation |
| Trace | API span and child inventory span | Request path and dependency timings |
| Audit event | Role or configuration changed by an actor | Accountability and change history |
A counter increases as events occur (with resets possible), a gauge represents a current value such as queue depth, and a histogram groups observations into buckets. A rate is the change in a counter over elapsed time, with reset-aware calculation. A log is a timestamped record, preferably structured with consistent fields. A span describes a unit of work with timing and context; a trace links related spans. An audit event is not a complete application request log. Its availability depends on service, event category, configuration, and permissions.
OpenTelemetry (OTel) provides instrumentation APIs, SDKs, conventions and a Collector that receives, processes and exports telemetry. It is not itself a storage or dashboard service. OTLP is its telemetry transport protocol; exporters send signals to configured backends. Use consistent service names, timestamps and environment labels across the pipeline.
Correlate the synthetic incident
Assume these records all refer to 10:00 UTC on an invented day. Request IDs are short symbolic values for readability, not valid W3C trace IDs.
| Metric window | Route | Requests | Failed | p95 latency |
|---|---|---|---|---|
| 10:00–10:05 | /checkout | 200 | 8 | 850 ms |
| 10:00–10:05 | /catalog | 500 | 1 | 90 ms |
| Time UTC | Service | Request ID | Trace | Event |
|---|---|---|---|---|
| 10:01:04.000 | API | r17 | t17 | checkout started |
| 10:01:04.820 | inventory | r17 | t17 | dependency timeout |
| 10:01:04.900 | API | r17 | t17 | response 503 |
| 10:01:05.000 | API | r18 | t18 | catalog started |
| Trace | Span | Parent | Start offset | Duration |
|---|---|---|---|---|
| t17 | s1 (API) | none | 0 ms | 900 ms |
| t17 | s2 (inventory) | s1 | 20 ms | 800 ms |
| t17 | s3 (DB call) | s2 | 40 ms | 760 ms |
Begin with the metric window (4% checkout failures versus 0.2% catalog failures). Filter logs on route, service and time, then follow r17/t17. The inventory operation consumed much of this request's latency; the DB child is nested within it, so do not sum all three durations. The evidence suggests a slow dependency but does not establish why it was slow or whether all eight failures share this cause. Compare additional samples and inspect resource saturation and recent changes. A metric normally aggregates many requests and does not carry a unique request ID as a label. A supported exemplar can link an individual observation to trace context; otherwise correlation uses time, service and route, then IDs in logs/traces.
Propagate context carefully
At each service boundary, propagate trace context (for example the W3C traceparent header) using an instrumentation library. A trace ID identifies a trace; span IDs identify operations. A business request ID may be a separate correlation field. Async messages need explicit context propagation; a retry may produce a new span while retaining the logical operation ID. Clock skew, missing instrumentation, late arrivals, sampling and dropped records can produce incomplete timelines. Never trust caller-supplied IDs for authorization. Avoid propagating secrets or personal data in baggage or headers; apply bounded validation and allowlists.
Compare provider roles
| Role | AWS | Azure | Google Cloud |
|---|---|---|---|
| Operational metrics and dashboards | CloudWatch | Azure Monitor | Cloud Monitoring |
| Application logs | CloudWatch Logs | Azure Monitor Logs / Log Analytics | Cloud Logging |
| Application tracing | AWS X-Ray / supported CloudWatch integrations | Application Insights | Cloud Trace |
| Cloud audit activity | CloudTrail | Activity Log (control plane); relevant resource logs | Cloud Audit Logs |
These are functional comparisons, not identical products. CloudTrail records supported API activity; its management and data events have different collection options. Azure Activity Log records management-plane events; resource logs and application telemetry are separate sources. Google Cloud Audit Logs distinguish Admin Activity, Data Access, System Event and Policy Denied. Verify which events are emitted, enabled, routed and accessible. Audit events can be routed into operational logging tools, but their provenance and retention should remain clear. Query languages, ingestion policies and access scopes differ. Check the evidence register for official documentation excerpts.
Practice
Use the synthetic records to explain which route is affected, calculate both failure rates, and find the slow span for r17. State two alternative explanations (database contention or network latency, for example) and what evidence would distinguish them. Explain why the trace duration is 900 ms rather than 2,460 ms. Do not disclose real logs.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Metrics, logs and traces — knowledge check
Choose the best answer for each offline scenario.
Which signal best identifies a slow child operation in a request?
Which is the checkout failure rate in the example?
Why not sum the three span durations?
What is Azure Activity Log mainly used for?
Where should a unique request ID normally be stored?