Exercise 6 of 8 · Structured JSON logs · About 12 min
A log line and its trace
Correlate an individual customer outcome with work performed by the downstream service.
Keep your stack running. In Codespaces, use labs/observability and the Ports tab for tool URLs; locally, use the extracted baodium-observability folder. Earlier exercises establish the signals used here.
Before you run it
If payment returns 500 and checkout maps it to 502, what values should the two services log for the same request?
Some requests fail
Inject payment errors and generate traffic. Keep the trace ID printed by the traffic command.
node lab.mjs fault errors
node lab.mjs traffic 10Checkout records HTTP 502 when the payment service returns its injected HTTP 500.
Help with this exercise
Not every line is an application event: startup and exporter diagnostics may be plain text. The verifier parses JSON event records and ignores other lines.
Need a hint or a troubleshooting path?
Not every line is an application event: startup and exporter diagnostics may be plain text. The verifier parses JSON event records and ignores other lines.
Check a common misconception
Equal timestamps or matching status strings do not establish request identity. Use the actual trace ID and service-specific span IDs.
Before you move on
- What to keep
- Preserve a pair of JSON events from different services with the same trace_id, distinct span_id values and their individual status codes.
- What to explain
- Connect the dependency failure to the customer-facing response. Distinguish observed facts from an inferred cause.
- A question to take further
- What useful evidence would remain if trace export failed but both applications still wrote their structured logs?
Write what you found
Explain why searching only for the string 500 would miss checkout’s 502 response and lose the relationship between the two events.
Stop the stack when you finish
Continue to the next exercise with the stack running. When finished, stop and remove only this lab’s Compose services and volumes.
node lab.mjs down