Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefProfileDuration = time.Second
DefProfileDuration exports for testing.
Functions ¶
func ProfileHTTPHandler ¶
func ProfileHTTPHandler(w http.ResponseWriter, r *http.Request)
ProfileHTTPHandler is same as pprof.Profile. The difference is ProfileHTTPHandler uses cpuprofile.GetCPUProfile to fetch profile data.
func Register ¶
func Register(ch ProfileConsumer)
Register register a ProfileConsumer into the global CPU profiler. Normally, the registered ProfileConsumer will receive the cpu profile data per second. If the ProfileConsumer (channel) is full, the latest cpu profile data will not be sent to it. This function is thread-safe. WARN: ProfileConsumer should not be closed before unregister.
func StartCPUProfiler ¶
func StartCPUProfiler() error
StartCPUProfiler uses to start to run the global parallelCPUProfiler.
func StopCPUProfiler ¶
func StopCPUProfiler()
StopCPUProfiler uses to stop the global parallelCPUProfiler.
func Unregister ¶
func Unregister(ch ProfileConsumer)
Unregister unregister a ProfileConsumer from the global CPU profiler. The unregistered ProfileConsumer won't receive the cpu profile data any more. This function is thread-safe.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector is a cpu profile collector, it collect cpu profile data from globalCPUProfiler.
func (*Collector) StartCPUProfile ¶
StartCPUProfile is a substitute for the `pprof.StartCPUProfile` function. You should use this function instead of `pprof.StartCPUProfile`. Otherwise you may fail, or affect the TopSQL feature and pprof profile HTTP API . WARN: this function is not thread-safe.
func (*Collector) StopCPUProfile ¶
StopCPUProfile is a substitute for the `pprof.StopCPUProfile` function. WARN: this function is not thread-safe.
type ProfileConsumer ¶
type ProfileConsumer = chan *ProfileData
ProfileConsumer is a channel that will receive profiling data from the CPU profiler periodically. If the channel is full, then the channel won't receive the latest profile data until it is not blocked.
type ProfileData ¶
ProfileData contains the cpu profile data between the start and end time, usually the interval between start and end is about 1 second.