debug

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package debug wraps the gops agent for use as a cmdutil-compatible Server.

The debug server will be started on DEBUG_PORT (default 9999). Get a stack trace, profile memory, etc. by running the gops command line connected to locahost:9999 like:

$ gops stack localhost:9999
goroutine 50 [running]:
  runtime/pprof.writeGoroutineStacks(0x4a18a20, 0xc000010138, 0x0, 0x0)
  	/usr/local/Cellar/go/1.13.5/libexec/src/runtime/pprof/pprof.go:679 +0x9d
  runtime/pprof.writeGoroutine(0x4a18a20, 0xc000010138, 0x2, 0x0, 0x0)
  ...

Learn more about gops at https://github.com/google/gops.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port int `env:"DEBUG_PORT,default=9999"`
	PProf
}

Config describes the configurable parameters for debugging.

type PProf added in v0.2.6

type PProf struct {
	Port int `env:"DEBUG_PPROF_PORT,default=9998"`
	// This controls how much of fraction of mutexes we need to consider for profiling.
	MutexProfileFraction int `env:"DBEUG_PPROF_MUTEX_PROFILE_FRACTION,default=2"`
	// This controls how much blocking time in nano seconds we need to consider.
	// Default 10 indicates, we consider all 10 ns blocking events .
	BlockProfileRate int `env:"DBEUG_PPROF_BLOCK_PROFILE_RATE,default=10"`
	// Heap Profiling is enabled by default.
	// This controls the frequency of heap allocation sampling.
	// It defines the number of bytes allocated between samples.
	// Default is actual default value of MemProfileRate
	MemProfileRate int  `env:"DBEUG_PPROF_MEM_PROFILE_RATE,default=524288"`
	Enabled        bool `env:"DEBUG_PPROF_ENABLE,default=false"`
	// Mutex Profiling is not enabled by default
	EnableMutexProfiling bool `env:"DEBUG_PPROF_MUTEX_PROFILE_ENABLE,default=false"`
	// Block Profiling is not enabled default
	EnableBlockProfiling bool `env:"DEBUG_PPROF_BLOCK_PROFILE_ENABLE,default=false"`
}

type PProfServer added in v0.2.5

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

PProfServer wraps a pprof server.

func NewPProfServer added in v0.2.5

func NewPProfServer(l logrus.FieldLogger, pprofConfig *PProf) *PProfServer

NewPProfServer sets up a pprof server with configurable profiling types and returns a PProfServer instance.

func (*PProfServer) Run added in v0.2.5

func (s *PProfServer) Run() error

Run starts the pprof server.

func (*PProfServer) Stop added in v0.2.5

func (s *PProfServer) Stop(_ error)

Stop shuts down the pprof server.

type Server

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

Server wraps a gops server for easy use with oklog/group.

func New

func New(l logrus.FieldLogger, config Config) *Server

New inializes a debug server listening on the provided port.

Connect to the debug server with gops:

gops stack localhost:PORT

Connect to the pprof server with pprof.port when pprof enabled

func (*Server) Run

func (s *Server) Run() error

Run starts the debug server.

It implements oklog group's runFn and pprof.

func (*Server) RunGOPS added in v0.2.6

func (s *Server) RunGOPS() error

Run starts the debug server.

It implements oklog group's runFn.

func (*Server) Stop

func (s *Server) Stop(_ error)

Stop shuts down the debug server.

It implements oklog group's interruptFn and pprof stop.

Jump to

Keyboard shortcuts

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