diag

package
v0.0.0-...-915fa77 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package diag implements functions for dumping crash information into various formats.

Index

Constants

View Source
const STACK_BUFFERS = 2045

Maximum number of stack records to hold.

View Source
const TRACE_BUFFER_LEN_B = 1 * 1024 * 1024 // 1MB

Buffer size, in bytes, for storing stack traces.

Variables

This section is empty.

Functions

func AsJson

func AsJson(diagData *DiagData) string

AsJson aggregates and returns diagnostics information in json format. Diagnostic information includes hostname, CPU count, environment data, stack traces for all running goroutines, and memory allocation statistics.

func AsString

func AsString(diagData *DiagData) string

AsString aggregates and returns text-based diagnostics information. Diagnostic information includes hostname, CPU count, environment data, stack traces for all running goroutines, and memory allocation statistics.

func FmtMallocStatsStr

func FmtMallocStatsStr(data *runtime.MemStats) string

FmtMallocStatsStr outputs the extended malloc information from a given MemStats instance as basic text.

func FmtMemStatsStr

func FmtMemStatsStr(data *runtime.MemStats) string

FmtMemStatsStr dumps memory allocation statistics and formats it as text. Malloc information is not included for brevity. Get it by calling FmtMallocStatsStr.

func InitWebDiag

func InitWebDiag()

InitWebDiag initializes the web diag uris within an active web server.

func NewBlockedData

func NewBlockedData() string

NewBlockData returns call stack information for any go routines which are currently blocking.

func NewMemData

func NewMemData() *runtime.MemStats

NewMemData creates and populates a new runtime.MemStats object and returns a pointer to it for use.

func NewStackString

func NewStackString() string

NewStackString dumps stack traces for all active go routines.

Types

type DiagData

type DiagData struct {
	System      *SysData
	Environment *EnvData
	Perfs       *perf.Snapshot
	StackTrace  []*StackTrace
	Memory      *runtime.MemStats
}

DiagData represents all aggregated diagnostic information.

func New

func New() *DiagData

New is a helper function that creates and populates a new DiagData object and returns a pointer to it.

type EnvData

type EnvData struct {
	Vars map[string]string
}

EnvData represents keyval pairs in the environment.

func NewEnvData

func NewEnvData() *EnvData

NewEnvData creates and populates a new EnvData object and returns a pointer to it for use.

func (*EnvData) String

func (this *EnvData) String() string

String pretty-prints the EnvData object.

type StackFrame

type StackFrame struct {
	File string
	Line int
	Name string
}

StackFrame represents the function name, file and line number information for a given frame within a stack trace.

func (*StackFrame) String

func (this *StackFrame) String() string

String pretty-prints a StackFrame object.

type StackTrace

type StackTrace struct {
	Frames []*StackFrame
}

StackTrace represents the collection of stack frame data associated with a single goroutine.

func NewStackTrace

func NewStackTrace() []*StackTrace

NewStackTrace is a constructor function which queries the Go runtime for goroutine information and builds a StackTrace object for each. A slice of StackTraces, one for each running goroutine, is returned.

func (*StackTrace) String

func (this *StackTrace) String() string

String pretty-prints a StackTrace object.

type SysData

type SysData struct {
	Arch       string
	CGOCalls   int64
	CPUCount   int
	Error      string
	GoRoutines int
	GoVersion  string
	Hostname   string
	OS         string
}

SysData represents basic information about the system.

func NewSysData

func NewSysData() *SysData

NewSysData creatse and populates a new SysData object and returns a pointer to it for use.

func (*SysData) String

func (this *SysData) String() string

String pretty-prints the SysData object.

type UriInfo

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

UriInfo represents the data associated with a given Uri in the web server.

Jump to

Keyboard shortcuts

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