Documentation ¶
Overview ¶
Package zprof serves runtime profiling data.
Index ¶
- Constants
- Variables
- func Profile(addr string, opts ...HandlerOpt)
- type Handler
- func (h Handler) Index(w http.ResponseWriter, r *http.Request) error
- func (h Handler) PProf(name string) func(w http.ResponseWriter, r *http.Request) error
- func (h Handler) Profile(w http.ResponseWriter, r *http.Request) error
- func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h Handler) SetProfileRates(w http.ResponseWriter, r *http.Request) error
- func (h Handler) Symbol(w http.ResponseWriter, r *http.Request) error
- func (h Handler) Trace(w http.ResponseWriter, r *http.Request) error
- type HandlerOpt
Constants ¶
const ( ReportBinary = "bin" ReportDebug = "dbg" ReportDebug2 = "dbg2" ReportTop = "top" ReportTraces = "traces" ReportSVG = "svg" )
Variables ¶
var ( // Prefix sets the prefix to the path you serve the profiles on, for example // "/profile". Prefix = func(prefix string) HandlerOpt { return func(h *Handler) { h.prefix = strings.TrimRight(prefix, "/") } } // Auth adds HTTP Basic auth. Auth = func(user, passwd string) HandlerOpt { return func(h *Handler) { h.user, h.passwd = []byte(user), []byte(passwd) } } // HTTPS enforces using https:// links; this can't always be reliably // detected. HTTPS = func(https bool) HandlerOpt { return func(h *Handler) { h.https = https } } )
var BlockRate *int64 = func() *int64 { var z int64 return &z }()
BlockRate remembers the current block profile rate.
There is no way to query the block profile rate; so keep track of it here. If you call SetBlockProfileRate() in your program then you may want to set this value as well to ensure the UI is displayed correct.
Use atomic.StoreInt64() and atomic.LoadInt64() to set and get the value.
Functions ¶
func Profile ¶
func Profile(addr string, opts ...HandlerOpt)
Profile starts a new HTTP server on addr to profile this application.
Errors are considered non-fatal, but will be printed to stderr. "localhost:6060" will be used if addr is an empty string.
The auth can be used to set up HTTP Basic auth; the format is as "user:password". No auth is added if this is an empty string.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(opts ...HandlerOpt) Handler
NewHandler creates a new Handler instance.
func (Handler) PProf ¶
PProf serves pprof profiles based on the name.
Available profiles: goroutine, threadcreate, heap, allocs, block, mutex
func (Handler) Profile ¶
Profile creates a pprof formatted CPU profile.
Profiling lasts for duration specified in seconds GET parameter, or for 30 seconds if not specified.
func (Handler) SetProfileRates ¶
SetProfileRates sets the block and mutex profile rates.
type HandlerOpt ¶
type HandlerOpt func(*Handler)
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
profile
Package profile provides a representation of github.com/google/pprof/proto/profile.proto and methods to encode/decode/merge profiles in this format.
|
Package profile provides a representation of github.com/google/pprof/proto/profile.proto and methods to encode/decode/merge profiles in this format. |