watching

package
v1.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelInfo = iota
	LogLevelDebug
)
View Source
const (
	// TrimResultTopN trimResult return only reserve the top n.
	TrimResultTopN = 10

	// NotSupportTypeMaxConfig means this profile type is
	// not support control dump profile by max parameter.
	NotSupportTypeMaxConfig = 0

	// UniformLogFormat is the format of uniform logging.
	UniformLogFormat = "[Watching] %v %v, config_min : %v, config_diff : %v, config_abs : %v, config_max : %v, previous : %v, current: %v"
)

Variables

This section is empty.

Functions

func WithBinaryDump

func WithBinaryDump() options.Option

WithBinaryDump set dump mode to binary.

func WithCGroup

func WithCGroup(useCGroup bool) options.Option

WithCGroup set Watching use cgroup or not.

func WithCPUCore added in v1.1.8

func WithCPUCore(cpuCore float64) options.Option

WithCPUCore overwrite the system level CPU core number when it > 0. it's not a good idea to modify it on fly since it affects the CPU percent caculation.

func WithCPUDump

func WithCPUDump(min int, diff int, abs int) options.Option

WithCPUDump set the cpu dump options.

func WithCPUMax added in v1.1.8

func WithCPUMax(max int) options.Option

WithCPUMax : set the CPUMaxPercent parameter as max

func WithCollectInterval

func WithCollectInterval(interval string) options.Option

WithCollectInterval : interval must be valid time duration string, eg. "ns", "us" (or "µs"), "ms", "s", "m", "h".

func WithCoolDown

func WithCoolDown(coolDown string) options.Option

WithCoolDown : coolDown must be valid time duration string, eg. "ns", "us" (or "µs"), "ms", "s", "m", "h".

func WithDumpPath

func WithDumpPath(dumpPath string, loginfo ...string) options.Option

WithDumpPath set the dump path for Watching.

func WithFullStack added in v1.1.8

func WithFullStack(isFull bool) options.Option

WithFullStack set to dump full stack or top 10 stack, when dump in text mode.

func WithGCHeapDump added in v1.1.6

func WithGCHeapDump(min int, diff int, abs int) options.Option

WithGCHeapDump set the GC heap dump options.

func WithGoProcAsCPUCore added in v1.1.8

func WithGoProcAsCPUCore(enabled bool) options.Option

WithGoProcAsCPUCore set Watching use cgroup or not.

func WithGoroutineDump

func WithGoroutineDump(min int, diff int, abs int, max int) options.Option

WithGoroutineDump set the goroutine dump options.

func WithLoggerLevel

func WithLoggerLevel(level int) options.Option

WithLoggerLevel set logger level

func WithLoggerSplit

func WithLoggerSplit(enable bool, shardLoggerSize string) options.Option

WithLoggerSplit set the split log options. eg. "b/B", "k/K" "kb/Kb" "mb/Mb", "gb/Gb" "tb/Tb" "pb/Pb".

func WithMemDump

func WithMemDump(min int, diff int, abs int) options.Option

WithMemDump set the memory dump options.

func WithMemoryLimit added in v1.1.6

func WithMemoryLimit(limit uint64) options.Option

WithMemoryLimit overwrite the system level memory limit when it > 0.

func WithProfileReporter added in v1.1.8

func WithProfileReporter(r ProfileReporter) options.Option

WithProfileReporter will enable reporter reopens profile reporter through WithProfileReporter(h.opts.rptOpts.reporter)

func WithShrinkThread added in v1.1.8

func WithShrinkThread(enable bool, threshold int, delay time.Duration) options.Option

WithShrinkThread enable/disable shrink thread when the thread number exceed the max threshold.

func WithTextDump

func WithTextDump() options.Option

WithTextDump set dump mode to text.

func WithThreadDump

func WithThreadDump(min, diff, abs int) options.Option

WithThreadDump set the thread dump options.

Types

type DumpConfigs added in v1.1.8

type DumpConfigs struct {
	// full path to put the profile files, default /tmp
	DumpPath string
	// default dump to binary profile, set to true if you want a text profile
	DumpProfileType dumpProfileType
	// only dump top 10 if set to false, otherwise dump all, only effective when in_text = true
	DumpFullStack bool
}

DumpConfigs contains configuration about dump file.

type HttpReporter added in v1.1.8

type HttpReporter struct {
	// contains filtered or unexported fields
}

func (*HttpReporter) Report added in v1.1.8

func (r *HttpReporter) Report(ptype string, buf []byte, reason string, eventID string) error

type ProfileReporter added in v1.1.8

type ProfileReporter interface {
	Report(pType string, buf []byte, reason string, eventID string) error
}

func NewReporter added in v1.1.8

func NewReporter(token string, url string) ProfileReporter

type ReporterConfigs added in v1.1.8

type ReporterConfigs struct {
	// contains filtered or unexported fields
}

type Response added in v1.1.8

type Response struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type ShrinkThrConfigs added in v1.1.8

type ShrinkThrConfigs struct {
	// shrink the thread number when it exceeds the max threshold that specified in Threshold
	Enable    bool
	Threshold int
	Delay     time.Duration // start to shrink thread after the delay time.
}

ShrinkThrConfigs contains the configuration about shrink thread

type Watching

type Watching struct {

	// lock Protect the following
	sync.Mutex
	// contains filtered or unexported fields
}

func NewWatching

func NewWatching(opts ...options.Option) *Watching

func (*Watching) DisableCPUDump

func (w *Watching) DisableCPUDump() *Watching

DisableCPUDump disables the CPU dump.

func (*Watching) DisableGCHeapDump added in v1.1.8

func (w *Watching) DisableGCHeapDump() *Watching

DisableGCHeapDump disables the GC heap dump.

func (*Watching) DisableGoroutineDump

func (w *Watching) DisableGoroutineDump() *Watching

DisableGoroutineDump disables the goroutine dump.

func (*Watching) DisableMemDump

func (w *Watching) DisableMemDump() *Watching

DisableMemDump disables the mem dump.

func (*Watching) DisableProfileReporter added in v1.1.8

func (w *Watching) DisableProfileReporter()

func (*Watching) DisableThreadDump

func (w *Watching) DisableThreadDump() *Watching

DisableThreadDump disables the goroutine dump.

func (*Watching) EnableCPUDump

func (w *Watching) EnableCPUDump() *Watching

EnableCPUDump enables the CPU dump.

func (*Watching) EnableDump

func (w *Watching) EnableDump(curCPU int) (err error)

func (*Watching) EnableGCHeapDump added in v1.1.6

func (w *Watching) EnableGCHeapDump() *Watching

EnableGCHeapDump enables the GC heap dump.

func (*Watching) EnableGoroutineDump

func (w *Watching) EnableGoroutineDump() *Watching

EnableGoroutineDump enables the goroutine dump.

func (*Watching) EnableMemDump

func (w *Watching) EnableMemDump() *Watching

EnableMemDump enables the mem dump.

func (*Watching) EnableProfileReporter added in v1.1.8

func (w *Watching) EnableProfileReporter()

func (*Watching) EnableThreadDump

func (w *Watching) EnableThreadDump() *Watching

EnableThreadDump enables the goroutine dump.

func (*Watching) Start

func (w *Watching) Start()

Start starts the dump loop of Watching.

func (*Watching) Stop

func (w *Watching) Stop()

Stop the dump loop.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL