1. A development team wants to identify which specific functions in their Go-based Cloud Run service are consuming the most CPU time under production load, without adding manual instrumentation code. Which GCP tool provides this capability with the least operational overhead?
- A. Cloud Profiler, which continuously collects CPU and heap profiles from running services with minimal performance overhead and no code changes beyond adding the agent import.✓ Correct
- B. Cloud Trace, which records the latency of individual requests and can identify slow spans that correspond to high CPU functions.
- C. Cloud Monitoring custom metrics, where the team manually records CPU usage per function using the Cloud Monitoring API.
- D. Cloud Debugger, which allows setting logpoints in production code to capture variable state and infer CPU usage.
Explanation
Option A is correct because Cloud Profiler is specifically designed for continuous CPU (and heap) profiling of production applications. For Go, it requires importing the profiler agent package and initializing it—no manual instrumentation of individual functions is needed. It uses statistical sampling with very low overhead and presents a flame graph identifying hot functions. Option B is wrong because Cloud Trace measures request latency across distributed services and records span durations; it does not profile CPU usage at the function level within a single service. Option C is wrong because recording custom metrics manually per function requires significant code instrumentation effort, which the question explicitly asks to minimize, and it measures throughput/count rather than CPU profiling data. Option D is wrong because Cloud Debugger (now deprecated as Cloud Debugger, succeeded by snapshot-based debugging) captures program state at specific points; it does not measure CPU time or produce profiling data.