viewer

package
v0.0.0-...-fffd70f Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTemplate = `` /* 923-byte string literal not displayed */

	DefaultMaxPoints  = 30
	DefaultTimeFormat = "15:04:05"
	DefaultInterval   = 2000
	DefaultAddr       = "localhost:18066"
	DefaultTheme      = ThemeMacarons
)
View Source
const (
	// VCStack is the name of StackViewer
	VCStack = "stack"
)
View Source
const (
	// VGCCPUFraction is the name of GCCPUFractionViewer
	VGCCPUFraction = "gccpufraction"
)
View Source
const (
	// VGCNum is the name of GCNumViewer
	VGCNum = "gcnum"
)
View Source
const (
	// VGCSzie is the name of GCSizeViewer
	VGCSize = "gcsize"
)
View Source
const (
	// VGoroutine is the name of GoroutinesViewer
	VGoroutine = "goroutine"
)
View Source
const (
	// VHeap is the name of HeapViewer
	VHeap = "heap"
)

Variables

This section is empty.

Functions

func Addr

func Addr() string

Addr returns the default server listening address

func ConvertStringToArray

func ConvertStringToArray(rawCsv string) []string

func Interval

func Interval() int

Interval returns the default collecting interval of ViewManager

func LinkAddr

func LinkAddr() string

LinkAddr returns the default html link address

func SetConfiguration

func SetConfiguration(opts ...Option)

Types

type CustomViewer

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

GCSizeViewer collects the GC size metric via `runtime.ReadMemStats()`

func (*CustomViewer) Name

func (vr *CustomViewer) Name() string

func (*CustomViewer) Serve

func (vr *CustomViewer) Serve(w http.ResponseWriter, _ *http.Request)

func (*CustomViewer) SetStatsMgr

func (vr *CustomViewer) SetStatsMgr(smgr *StatsMgr)

func (*CustomViewer) View

func (vr *CustomViewer) View() *charts.Line

type GCCPUFractionViewer

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

GCCPUFractionViewer collects the GC-CPU fraction metric via `runtime.ReadMemStats()`

func (*GCCPUFractionViewer) Name

func (vr *GCCPUFractionViewer) Name() string

func (*GCCPUFractionViewer) Serve

func (*GCCPUFractionViewer) SetStatsMgr

func (vr *GCCPUFractionViewer) SetStatsMgr(smgr *StatsMgr)

func (*GCCPUFractionViewer) View

func (vr *GCCPUFractionViewer) View() *charts.Line

type GCNumViewer

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

GCNumViewer collects the GC number metric via `runtime.ReadMemStats()`

func (*GCNumViewer) Name

func (vr *GCNumViewer) Name() string

func (*GCNumViewer) Serve

func (vr *GCNumViewer) Serve(w http.ResponseWriter, _ *http.Request)

func (*GCNumViewer) SetStatsMgr

func (vr *GCNumViewer) SetStatsMgr(smgr *StatsMgr)

func (*GCNumViewer) View

func (vr *GCNumViewer) View() *charts.Line

type GCSizeViewer

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

GCSizeViewer collects the GC size metric via `runtime.ReadMemStats()`

func (*GCSizeViewer) Name

func (vr *GCSizeViewer) Name() string

func (*GCSizeViewer) Serve

func (vr *GCSizeViewer) Serve(w http.ResponseWriter, _ *http.Request)

func (*GCSizeViewer) SetStatsMgr

func (vr *GCSizeViewer) SetStatsMgr(smgr *StatsMgr)

func (*GCSizeViewer) View

func (vr *GCSizeViewer) View() *charts.Line

type GoroutinesViewer

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

GoroutinesViewer collects the goroutine number metric via `runtime.NumGoroutine()`

func (*GoroutinesViewer) Name

func (vr *GoroutinesViewer) Name() string

func (*GoroutinesViewer) Serve

func (vr *GoroutinesViewer) Serve(w http.ResponseWriter, _ *http.Request)

func (*GoroutinesViewer) SetStatsMgr

func (vr *GoroutinesViewer) SetStatsMgr(smgr *StatsMgr)

func (*GoroutinesViewer) View

func (vr *GoroutinesViewer) View() *charts.Line

type HeapViewer

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

HeapViewer collects the heap-stats metrics via `runtime.ReadMemStats()`

func (*HeapViewer) Name

func (vr *HeapViewer) Name() string

func (*HeapViewer) Serve

func (vr *HeapViewer) Serve(w http.ResponseWriter, _ *http.Request)

func (*HeapViewer) SetStatsMgr

func (vr *HeapViewer) SetStatsMgr(smgr *StatsMgr)

func (*HeapViewer) View

func (vr *HeapViewer) View() *charts.Line

type Metrics

type Metrics struct {
	Values []float64 `json:"values"`
	Time   string    `json:"time"`
}

Metrics

type Option

type Option func(c *config)

func WithAddr

func WithAddr(addr string) Option

WithAddr sets the listening address and link address

func WithInterval

func WithInterval(interval int) Option

WithInterval sets the interval of collecting and pulling metrics

func WithLinkAddr

func WithLinkAddr(addr string) Option

WithLinkAddr sets the html link address

func WithMaxPoints

func WithMaxPoints(n int) Option

WithMaxPoints sets the maximum points of each chart series

func WithTemplate

func WithTemplate(t string) Option

WithTemplate sets the rendered template which fetching stats from the server and handling the metrics data

func WithTheme

func WithTheme(theme Theme) Option

WithTheme sets the theme of the charts

func WithTimeFormat

func WithTimeFormat(s string) Option

WithTimeFormat sets the time format for the line-chart Y-axis label

type StackViewer

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

StackViewer collects the stack-stats metrics via `runtime.ReadMemStats()`

func (*StackViewer) Name

func (vr *StackViewer) Name() string

func (*StackViewer) Serve

func (vr *StackViewer) Serve(w http.ResponseWriter, _ *http.Request)

func (*StackViewer) SetStatsMgr

func (vr *StackViewer) SetStatsMgr(smgr *StatsMgr)

func (*StackViewer) View

func (vr *StackViewer) View() *charts.Line

type StatsMgr

type StatsMgr struct {
	Ctx    context.Context
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

func NewStatsMgr

func NewStatsMgr(ctx context.Context) *StatsMgr

func (*StatsMgr) Tick

func (s *StatsMgr) Tick()

type Theme

type Theme string
const (
	ThemeWesteros Theme = types.ThemeWesteros
	ThemeMacarons Theme = types.ThemeMacarons
)

type Viewer

type Viewer interface {
	Name() string
	View() *charts.Line
	Serve(w http.ResponseWriter, _ *http.Request)
	SetStatsMgr(smgr *StatsMgr)
}

Viewer is the abstraction of a Graph which in charge of collecting metrics from somewhere

func NewCustom

func NewCustom() Viewer

NewGCSizeViewer returns the GCSizeViewer instance Series: GCSys / NextGC

func NewGCCPUFractionViewer

func NewGCCPUFractionViewer() Viewer

NewGCCPUFractionViewer returns the GCCPUFractionViewer instance Series: Fraction

func NewGCNumViewer

func NewGCNumViewer() Viewer

NewGCNumViewer returns the GCNumViewer instance Series: GcNum

func NewGCSizeViewer

func NewGCSizeViewer() Viewer

NewGCSizeViewer returns the GCSizeViewer instance Series: GCSys / NextGC

func NewGoroutinesViewer

func NewGoroutinesViewer() Viewer

NewGoroutinesViewer returns the GoroutinesViewer instance Series: Goroutines

func NewHeapViewer

func NewHeapViewer() Viewer

NewHeapViewer returns the HeapViewer instance Series: Alloc / Inuse / Sys / Idle

func NewStackViewer

func NewStackViewer() Viewer

NewStackViewer returns the StackViewer instance Series: StackSys / StackInuse / MSpanSys / MSpanInuse

Jump to

Keyboard shortcuts

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