diagnostics

package
v1.4.5-alpha1216-hooks... Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareRecorderCosts

func CompareRecorderCosts(database, memory *Recorder)

func DumpHeap

func DumpHeap(opts ...HeapDumpOption) bool

func Enabled

func Enabled(lvl Level) bool

Enabled determines if messages at the requested level should be emitted.

func LogRecorder

func LogRecorder(label string, recorders ...*Recorder)

func SetLevel

func SetLevel(lvl Level)

SetLevel overrides the diagnostics log level manually.

func SetLevelFromString

func SetLevelFromString(raw string) error

SetLevelFromString parses a string and applies the log level if valid.

func StartHeapMonitor

func StartHeapMonitor(interval time.Duration, opts ...HeapDumpOption) context.CancelFunc

func Track

func Track(name string, steps ...func() error) error

func TrackHigh

func TrackHigh(name string, steps ...func() error) error

func TrackLow

func TrackLow(name string, steps ...func() error) error

Types

type HeapDumpOption

type HeapDumpOption func(*heapDumpConfig)

func WithDisable

func WithDisable(disable ...bool) HeapDumpOption

func WithDumpCount

func WithDumpCount(count int) HeapDumpOption

func WithFileName

func WithFileName(name string) HeapDumpOption

func WithHTTPServer

func WithHTTPServer(addr string) HeapDumpOption

func WithHeapFile

func WithHeapFile(name string) HeapDumpOption

func WithHeapLimit

func WithHeapLimit(memThreshold uint64) HeapDumpOption

func WithName

func WithName(name string) HeapDumpOption

func WithRuntimeGC

func WithRuntimeGC(enable ...bool) HeapDumpOption

type Level

type Level int

Level controls the detail tier used when recording diagnostics measurements.

const (
	LevelLow    Level = iota
	LevelNormal       // default
	LevelHigh
	LevelOff
)

func GetLevel

func GetLevel() Level

GetLevel returns the current diagnostics log level.

func (Level) String

func (lvl Level) String() string

type Measurement

type Measurement struct {
	Name       string
	Total      time.Duration
	Count      uint64
	ErrorCount uint64
	Steps      []time.Duration
}

func (Measurement) Average

func (m Measurement) Average() time.Duration

func (Measurement) String

func (m Measurement) String() string

type Recorder

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

func DefaultRecorder

func DefaultRecorder() *Recorder

func NewRecorder

func NewRecorder() *Recorder

func ReplaceDefault

func ReplaceDefault(rec *Recorder) *Recorder

func ResetDefaultRecorder

func ResetDefaultRecorder() *Recorder

func (*Recorder) Log

func (rec *Recorder) Log(label ...string)

func (*Recorder) Reset

func (r *Recorder) Reset()

func (*Recorder) Snapshot

func (r *Recorder) Snapshot() []Measurement

func (*Recorder) Track

func (r *Recorder) Track(name string, steps ...func() error) error

func (*Recorder) TrackHigh

func (r *Recorder) TrackHigh(name string, steps ...func() error) error

func (*Recorder) TrackLow

func (r *Recorder) TrackLow(name string, steps ...func() error) error

Jump to

Keyboard shortcuts

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