The go tool trace utility

The go tool trace utility is a tool for viewing trace files that can be generated in any one of the following three ways:

  • Using the runtime/trace package
  • Using the net/http/pprof package
  • Executing the go test -trace command

This section will use the first technique only. The output of the following command will greatly help you to understand what the Go execution tracer does:

    $ go doc runtime/trace
    package trace // import "runtime/trace"
    
    Package trace contains facilities for programs to generate traces for the Go
    execution tracer.
    
    
    Tracing runtime activities
    
    The execution trace captures a wide range of execution events such as
    goroutine creation/blocking/unblocking, syscall enter/exit/block, GC-related
    events, ...

Get Mastering Go - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.