The runtime/trace package allows you to produce a trace of each goroutine's execution over a period of time. This is useful for identifying concurrency bottlenecks, such as goroutines blocking on channels, which might not be visible in CPU profiles. You can visualize these traces using the go tool trace command or the gotraceui tool.
To correlate high-level application logic with low-level execution details, you can instrument your code using:
import "runtime/trace"
// Use trace.Task, trace.WithRegion, or trace.Log to instrument your program.