autopprof: github.com/rakyll/autopprof Index | Examples | Files

package autopprof

import "github.com/rakyll/autopprof"

Package autopprof provides a development-time library to collect pprof profiles from Go programs.

This package is experimental and APIs may change.

Code:

// Add the following to your main, then
// use CTRL+\ to intercept and capture.
// Pprof UI will start in 15 seconds once
// the profile is captured.
autopprof.Capture(autopprof.CPUProfile{
    Duration: 15 * time.Second,
})

Index

Examples

Package Files

autopprof.go

func Capture Uses

func Capture(p Profile)

Capture captures the given profiles at SIGINT and opens a browser with the collected profiles.

Capture should be used in development-time and shouldn't be in production binaries.

type BlockProfile Uses

type BlockProfile struct {
    // Rate is the fraction of goroutine blocking events that
    // are reported in the blocking profile. The profiler aims to
    // sample an average of one blocking event per rate nanoseconds spent blocked.
    //
    // If zero value is provided, it will include every blocking event
    // in the profile.
    Rate int
}

BlockProfile captures stack traces that led to blocking on synchronization primitives.

func (BlockProfile) Capture Uses

func (p BlockProfile) Capture() (string, error)

type CPUProfile Uses

type CPUProfile struct {
    Duration time.Duration // 30 seconds by default
}

CPUProfile captures the CPU profile.

func (CPUProfile) Capture Uses

func (p CPUProfile) Capture() (string, error)

type GoroutineProfile Uses

type GoroutineProfile struct{}

GoroutineProfile captures stack traces of all current goroutines.

func (GoroutineProfile) Capture Uses

func (p GoroutineProfile) Capture() (string, error)

type HeapProfile Uses

type HeapProfile struct{}

HeapProfile captures the heap profile.

func (HeapProfile) Capture Uses

func (p HeapProfile) Capture() (string, error)

type MutexProfile Uses

type MutexProfile struct{}

MutexProfile captures stack traces of holders of contended mutexes.

func (MutexProfile) Capture Uses

func (p MutexProfile) Capture() (string, error)

type Profile Uses

type Profile interface {
    Capture() (profile string, err error)
}

Profile represents a pprof profile.

type ThreadcreateProfile Uses

type ThreadcreateProfile struct{}

Threadcreate profile captures the stack traces that led to the creation of new OS threads.

func (ThreadcreateProfile) Capture Uses

func (p ThreadcreateProfile) Capture() (string, error)

Package autopprof imports 10 packages (graph). Updated 2018-11-26. Refresh now. Tools for package owners.