Use go tool trace with a trace file to visualize goroutine scheduling and latency for performance debugging.
Run go tool trace with a trace file generated by go test -trace or runtime/pprof.StartTrace to visualize goroutine scheduling and latency.
go test -trace=trace.out ./myapp
go tool trace trace.out
The browser opens automatically; use the "Goroutines" tab to see stack traces and the "Latency" tab to identify blocking operations.
go tool trace records a timeline of your Go program's execution to help you find performance bottlenecks. It shows exactly when goroutines start, stop, and wait, acting like a video replay of your code's activity. You use it when your application feels slow or unresponsive to pinpoint the specific function causing the delay.