A team operates several services that each write structured JSON logs to CloudWatch Logs and are traced end to end with AWS X-Ray. During an incident an operator finds a slow trace in the X-Ray console and now wants to jump straight to the exact log lines emitted while handling that one request, across all the services it touched. The developer must make each log line correlate to its trace. Which value should the application include in every structured log entry to enable this correlation?
- AThe CloudWatch Logs log stream name, so the operator can open the same stream that recorded the trace and scroll to the matching time window.
- BThe X-Ray trace ID for the current request, so logs from every service handling that request can be filtered to the same trace identifier. Correct
- CA freshly generated UUID created in each service, so every service stamps its own unique identifier onto the log lines it writes for the request.
- DThe wall-clock timestamp at millisecond precision, so the operator can align log entries to the trace by matching their recorded times.
Why A is wrong: A stream name groups logs by execution environment, not by request, so it cannot tie a specific trace to the precise log lines for that one request.
Why B is correct: The trace ID is unique per request and shared across services, so logging it lets an operator pivot from a trace directly to all matching log lines.
Why C is wrong: Per-service UUIDs differ between services, so they cannot join logs from multiple services to one trace; only a shared identifier works.
Why D is wrong: Timestamps alone are ambiguous under concurrency because many requests overlap in time, so matching by time cannot reliably isolate one request's logs.