How to Use go tool trace for Goroutine and Latency Analysis

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.