debug

package
v0.0.0-...-9649366 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugURL is the url for the debug dump endpoint.
	DebugURL = "/debug/dump"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ProfileSource

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

ProfileSource defines a custom source of a runtime/pprof Profile. This can either be part of a predefined or custom profile.

func NewProfileSource

func NewProfileSource(name string, debug int) (*ProfileSource, error)

NewProfileSource returns a ProfileSource with a name and debug level, where the verbosity of the final stack information increases with value. Will return an error if name is an empty string.

func (*ProfileSource) Profile

func (p *ProfileSource) Profile() *pprof.Profile

Profile returns a *pprof.Profile according the the name of the ProfileSource. This will first try find an existing profile, creating one if it can't be found.

func (*ProfileSource) Write

func (p *ProfileSource) Write(w io.Writer, _ *http.Request) error

Write writes a pprof-formatted snapshot of the profile to w. If a write to w returns an error, Write returns that error. Otherwise, Write returns nil.

type Source

type Source interface {
	// Write writes it's debug information into the provided writer.
	Write(w io.Writer, r *http.Request) error
}

Source is the interface that must be implemented to provide a new debug source. Each debug source's Write method will be called to write out a debug file for that source into the overall debug zip file.

func NewCPUProfileSource

func NewCPUProfileSource(h time.Duration) Source

NewCPUProfileSource returns a Source for CPU Profiling, measured over the passed duration.

func NewHeapDumpSource

func NewHeapDumpSource() Source

NewHeapDumpSource returns a Source for heapdump.

func NewHostInfoSource

func NewHostInfoSource() Source

NewHostInfoSource returns a Source for host information

func NewNamespaceInfoSource

func NewNamespaceInfoSource(
	clusterClient clusterclient.Client,
	instrumentOpts instrument.Options,
) Source

NewNamespaceInfoSource returns a Source for namespace information.

func NewPlacementInfoSource

func NewPlacementInfoSource(
	service handler.ServiceNameAndDefaults,
	placementOpts placement.HandlerOptions,
	iopts instrument.Options,
) (Source, error)

NewPlacementInfoSource returns a Source for placement information.

type ZipWriter

type ZipWriter interface {
	// WriteZip writes a ZIP file in the provided writer.
	// The archive contains the dumps of all sources in separate files.
	WriteZip(io.Writer, *http.Request) error
	// RegisterSource adds a new source to the produced archive.
	RegisterSource(fileName string, source Source) error
	// HTTPHandler sends out the ZIP file as raw bytes.
	HTTPHandler() http.Handler
	// RegisterHandler wires the HTTPHandlerFunc with the given router.
	RegisterHandler(handlerPath string, router *http.ServeMux) error
}

ZipWriter aggregates sources and writes them in a zip file.

func NewPlacementAndNamespaceZipWriterWithDefaultSources

func NewPlacementAndNamespaceZipWriterWithDefaultSources(
	cpuProfileDuration time.Duration,
	clusterClient clusterclient.Client,
	placementsOpts placement.HandlerOptions,
	services []handler.ServiceNameAndDefaults,
	instrumentOpts instrument.Options,
) (ZipWriter, error)

NewPlacementAndNamespaceZipWriterWithDefaultSources returns a zipWriter with the following debug sources already registered: CPU, heap, host, goroutines, namespace and placement info.

func NewZipWriter

func NewZipWriter(iopts instrument.Options) ZipWriter

NewZipWriter returns an instance of an ZipWriter. The passed prefix indicates the folder where to save the zip files.

func NewZipWriterWithDefaultSources

func NewZipWriterWithDefaultSources(
	cpuProfileDuration time.Duration,
	iopts instrument.Options,
) (ZipWriter, error)

NewZipWriterWithDefaultSources returns a zipWriter with the following debug sources already registered: CPU, heap, host, goroutines.

Jump to

Keyboard shortcuts

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