GCP Professional Cloud DevOps Engineer Practice Question 6: Trace Log Correlation
Google Cloud Professional Cloud DevOps Engineer · Test 1 · question 6 of 10
A checkout flow on GKE spans six microservices. Cloud Trace shows a p99 latency spike, and the waterfall points at a slow span inside the inventory service. All services emit structured logs to Cloud Logging, but at peak the inventory service handles hundreds of concurrent requests, so an engineer inspecting the slow span cannot tell which log entries belong to that specific request.
What is the most effective way to make the relevant log entries reachable from the trace?
Show answer and explanation
Answer:
Trace-to-log correlation is driven by three fields on the LogEntry: trace (the trace ID), spanId (a 16-character hex span identifier), and traceSampled. When they are set, the Trace details pane can show the matching log entries next to the waterfall, and Logs Explorer can filter to a single trace, which is exactly what is needed to isolate one request out of hundreds running concurrently. In practice these fields are populated automatically: OpenTelemetry instrumentation and the Cloud Logging client libraries propagate the incoming traceparent or X-Cloud-Trace-Context header into the log entry, so the fix is usually enabling that integration rather than writing the fields by hand.
Option B increases cost and data volume without solving the problem. The slow request was already traced, the stem says the waterfall shows the span, so sampling is not the gap; the missing link is between the span and the log entries.
Option C measures how often the problem occurs but provides no path from a trace to the log lines of an individual request. It is a reasonable complementary alert, not a diagnosis tool for this situation.
Option D is the manual approximation engineers fall back on when correlation is not configured, and it fails precisely under the conditions described: with high concurrency, the timestamp window of one slow span contains log entries from many other in-flight requests, leaving the engineer to guess which lines belong together.
Reference: Correlate traces and logs