profiling

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProfilerAlreadyStarted = errors.New("profiler already started")
	ErrUnknownProfile         = errors.New("unknown profile")
	ErrNoDumpersActive        = errors.New("there are no dumpers active")
)

Functions

func OverrideDumper

func OverrideDumper(name string, dumper Dumper) error

OverrideDumper overrides the implementation for the dumper which has the specified profile name. This method must be called before calling Start() to take effect. Valid values for name are: "goroutine", "threadcreate", "heap", "block", "mutex", "trace" and "cpu".

func Run

func Run(ctx context.Context, conf *Config) error

Run runs the profiling using the provided configuration until the context has been cancelled.

Types

type Config

type Config struct {
	// Used to tag the profile in some manner. Its meaning depends on how it is used
	// by the dumpers implementations.
	Tag string
	// Number of seconds that have to elapse between profiles generation. In other words,
	// each time Frequency seconds elapse, a profiling tick happens and hence the profiles
	// generation.
	Frequency int
	// DebugLevel is used as the second parameter when calling profile.WriteTo to write
	// a profile. NOTE: This affects the format of the profiling output.
	DebugLevel int
	// If true, runs the garbage collector before writing a "heap" profile.
	RunGCBeforeHeapProfile bool
	// Profiles is an array of the names of the profiles that will get generated on
	// each profiling tick.
	// Available values for each element:
	// "goroutine", "threadcreate", "heap", "block", "mutex", "trace", "cpu"
	Profiles []string
}

type Dumper

type Dumper interface {
	// Prepares the Dumper before any profiling tick takes place.
	Prepare() error
	// Dumps the profiling data to some destination.
	// timestamp - string containing the time where the profiling tick begun executing,
	//             in the format yyyy-MM-dd_mmhhss.
	// name - name of the profile that is currently dumping data.
	Dump(timestamp string, name string) error
	// Releases any resources associated with this Dumper.
	Release() error
}

Dumper defines the interface that are used to dump profiling data of some kind.

Jump to

Keyboard shortcuts

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