Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnsupportedProfileType is returned when an unsupported profile type is used. ErrUnsupportedProfileType = errors.New("unsupported profile type") // ErrStartCPUProfile is returned when CPU profiling fails to start. ErrStartCPUProfile = errors.New("failed to start CPU profile") // ErrStartTraceProfile is returned when trace profiling fails to start. ErrStartTraceProfile = errors.New("failed to start trace profile") // ErrCreateProfileFile is returned when profile file creation fails. ErrCreateProfileFile = errors.New("failed to create profile file") )
Profiler-specific errors.
Functions ¶
func IsValidProfileType ¶
func IsValidProfileType(profileType ProfileType) bool
IsValidProfileType checks if the given profile type is supported.
Types ¶
type Config ¶
type Config struct {
Enabled bool `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
Port int `json:"port" yaml:"port" mapstructure:"port"`
Host string `json:"host" yaml:"host" mapstructure:"host"`
File string `json:"file" yaml:"file" mapstructure:"file"`
ProfileType ProfileType `json:"profile_type" yaml:"profile_type" mapstructure:"profile_type"`
}
Config holds the configuration for the profiler.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default profiler configuration.
type ProfileType ¶
type ProfileType string
ProfileType represents the type of profile to collect.
const ( // DefaultProfilerPort is the default port for the profiler server. DefaultProfilerPort = 6060 // DefaultReadHeaderTimeout is the default timeout for reading request headers. DefaultReadHeaderTimeout = 10 * time.Second // ProfileTypeCPU collects CPU profile data. ProfileTypeCPU ProfileType = "cpu" // ProfileTypeHeap collects heap memory profile data. ProfileTypeHeap ProfileType = "heap" // ProfileTypeAllocs collects allocation profile data. ProfileTypeAllocs ProfileType = "allocs" // ProfileTypeGoroutine collects goroutine profile data. ProfileTypeGoroutine ProfileType = "goroutine" // ProfileTypeBlock collects blocking profile data. ProfileTypeBlock ProfileType = "block" // ProfileTypeMutex collects mutex contention profile data. ProfileTypeMutex ProfileType = "mutex" // ProfileTypeThreadCreate collects thread creation profile data. ProfileTypeThreadCreate ProfileType = "threadcreate" // ProfileTypeTrace collects execution trace data. ProfileTypeTrace ProfileType = "trace" )
func GetSupportedProfileTypes ¶
func GetSupportedProfileTypes() []ProfileType
GetSupportedProfileTypes returns a list of all supported profile types.
func ParseProfileType ¶
func ParseProfileType(s string) (ProfileType, error)
ParseProfileType converts a string to ProfileType, with case-insensitive matching.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a pprof profiling server.
func (*Server) GetAddress ¶
GetAddress returns the address the profiler server is listening on.
func (*Server) IsRunning ¶
IsRunning returns true if the profiler (server or file-based) is currently running.
Click to show internal directories.
Click to hide internal directories.