Documentation
¶
Overview ¶
Package profiling provides a self-contained pprof profiling server and periodic profile dump facility for CloudZero Agent components.
Usage:
stop := profiling.Start(profiling.Options{
Enabled: true,
Port: 6060,
Dir: "/var/lib/agent/profiles",
HeapInterval: 30 * time.Second,
CPUInterval: 5 * time.Minute,
CPUDuration: 30 * time.Second,
})
defer stop()
When Enabled is false, Start returns immediately with a no-op stop function and starts no goroutines or listeners.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start(opts Options) (stop func())
Start launches the profiling subsystem according to opts and returns a stop function that shuts everything down cleanly.
If opts.Enabled is false, Start is a no-op and the returned function does nothing. No goroutines are started and no ports are opened.
Types ¶
type Options ¶
type Options struct {
// Enabled is the master switch. Nothing runs unless this is true.
Enabled bool
// Port is the TCP port for the pprof HTTP server. Defaults to 6060 when zero.
Port int
// Dir is the output directory for periodic profile dumps. Heap and CPU dumps
// are disabled when Dir is empty.
Dir string
// HeapInterval is the interval between heap profile snapshots. Defaults to
// 30 seconds when zero. Heap dumps are only written when Dir is set.
HeapInterval time.Duration
// CPUInterval is the interval between CPU capture sessions. CPU profiling is
// disabled when CPUInterval is zero or Dir is empty.
CPUInterval time.Duration
// CPUDuration is the length of each CPU capture window. Defaults to 30 seconds
// when zero (only meaningful when CPUInterval > 0).
CPUDuration time.Duration
}
Options configures the profiling server and periodic profile dumps.
Click to show internal directories.
Click to hide internal directories.