Documentation ¶
Index ¶
- Constants
- Variables
- func BlockProfile() blockProfile
- func CpuProfile() cpuProfile
- func EnableCapture(options ...Option) error
- func GoroutineProfile() goroutineProfile
- func HeapProfile() heapProfile
- func MutexProfile() mutexProfile
- func ThreadcreateProfile() threadcreateProfile
- type FileStorage
- type IntervalTrigger
- type Logger
- type Option
- type RandomIntervalTrigger
- type Storage
- type Trigger
Constants ¶
const ( EnvPprofPrefix = "PPROF_PREFIX" EnvPprofDir = "PPROF_DIR" EnvPprofTtl = "PPROF_TTL" )
Variables ¶
var ( ErrAlreadyEnabled = errors.New("already enabled") ErrInvalidOption = errors.New("invalid option") )
Functions ¶
func EnableCapture ¶
EnableCapture will capture the given profiles periodically.
func GoroutineProfile ¶
func GoroutineProfile() goroutineProfile
GoroutineProfile captures the goroutine profile.
func ThreadcreateProfile ¶
func ThreadcreateProfile() threadcreateProfile
ThreadcreateProfile captures the threadcreate profile.
Types ¶
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage stores the profile results to file with automatic cleaning.
func NewFileStorage ¶
func NewFileStorage(prefix, dir string, ttl time.Duration) *FileStorage
NewFileStorage return a FileStorage, prefix indicates the prefix of the files, dir indicates where to save the files, ttl indicates the time-to-live of the files.
func NewFileStorageFromEnv ¶
func NewFileStorageFromEnv() *FileStorage
NewFileStorageFromEnv return a FileStorage, it read arguments from environment variables.
func (*FileStorage) WriteCloser ¶
func (s *FileStorage) WriteCloser(name string, t time.Time) (io.WriteCloser, error)
WriteCloser implements Storage.
type IntervalTrigger ¶
type IntervalTrigger struct {
// contains filtered or unexported fields
}
IntervalTrigger will trigger periodically with constant interval.
func NewIntervalTrigger ¶
func NewIntervalTrigger(interval time.Duration) *IntervalTrigger
NewIntervalTrigger returns a IntervalTrigger.
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger is an abstraction of log output.
type Option ¶
type Option func(c *capturer)
func WithProfiles ¶
func WithProfiles(profiles ...profile) Option
WithProfiles specifies the pprof profiles.
type RandomIntervalTrigger ¶
type RandomIntervalTrigger struct {
// contains filtered or unexported fields
}
RandomIntervalTrigger will trigger periodically with random interval.
func NewRandomIntervalTrigger ¶
func NewRandomIntervalTrigger(min, max time.Duration) *RandomIntervalTrigger
NewRandomIntervalTrigger returns a IntervalTrigger.
func (*RandomIntervalTrigger) Wait ¶
func (t *RandomIntervalTrigger) Wait() error
Wait implements Trigger.