The go tool trace Utility

Let’s learn about code tracing and the go tool trace utility.

What is code tracing?

Code tracing is a process that allows us to learn information such as the operation of the garbage collector, the lifetime of goroutines, the activity of each logical processor, and the number of operating system threads used. The go tool trace utility is a tool for viewing the data stored in trace files, which can be generated in any one of the following three ways:

  • With the runtime/trace package

  • With the net/http/pprof package

  • With the go test -trace command

Coding example

This lesson illustrates the use of the first technique using the code of traceCLA.go:

Get hands-on with 1400+ tech skills courses.