Documentation ¶
Overview ¶
Package chrometracing writes per-process Chrome trace_event files that can be loaded into chrome://tracing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close() error
Close overwrites the trailing (,\n) with (]\n) and closes the trace file. Close is implemented in a separate file to keep a separation between custom code and upstream from github.com/google/chrometracing. Additionally, we can enable linting for code we author, while leaving upstream code alone.
func EnableTracing ¶
func EnableTracing()
EnableTracing turns on tracing, regardless of running in a test or not. Tracing is enabled by default if the CHROMETRACING_DIR environment variable is present and non-empty.
Types ¶
type PendingEvent ¶
type PendingEvent struct {
// contains filtered or unexported fields
}
A PendingEvent represents an ongoing unit of work. The begin trace event has already been written, and calling Done will write the end trace event.
func Event ¶
func Event(name string) *PendingEvent
Event logs a unit of work. To instrument a Go function, use e.g.:
func calcPi() { defer chrometracing.Event("calculate pi").Done() // … }
For more finely-granular traces, use e.g.:
for _, cmd := range commands { ev := chrometracing.Event("initialize " + cmd.Name) cmd.Init() ev.Done() }
func (*PendingEvent) Done ¶
func (pe *PendingEvent) Done()
Done writes the end trace event for this unit of work.