chrometracing

package
v0.0.0-...-afecb3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2024 License: MPL-2.0 Imports: 8 Imported by: 0

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.

func Path

func Path() string

Path returns the full path of the chrome://tracing trace_event file for display in log messages.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL