runtime

package
v0.0.0-...-c330695 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Monitor

func Monitor(ctx context.Context, cfg Config) error

Monitor will start the runtime monitoring process to publish metrics

Types

type Config

type Config struct {
	Name     string        `toml:"-"`
	ID       string        `toml:"-"`
	Version  string        `toml:"-"`
	Revision string        `toml:"-"`
	Interval time.Duration `toml:"interval" default:"20s" comment:"Refresh interval for runtime metrics update"`
}

Config holds the runtime metric exporter informations

func (*Config) Validate

func (c *Config) Validate() error

Validate rntime config parameters

type Publisher

type Publisher interface {
	Publish(rs *Stats)
}

Publisher defines metric publisher contract

func OpenCensus

func OpenCensus(cfg Config) Publisher

OpenCensus initialize an opencensus metric publisher

type Stats

type Stats struct {
	// Go
	Goarch  string `json:"runtime.arch"`
	Goos    string `json:"runtime.os"`
	Version string `json:"runtime.go_version"`
	// CPU
	NumCPU       int64 `json:"runtime.cpu"`
	NumGoRoutine int64 `json:"runtime.goroutines"`
	NumCGOCall   int64 `json:"runtime.cgo_calls"`
	// Memory
	MemAlloc      int64 `json:"mem.alloc"`
	MemTotalAlloc int64 `json:"mem.total"`
	MemSys        int64 `json:"mem.sys"`
	MemLookups    int64 `json:"mem.lookups"`
	MemMallocs    int64 `json:"mem.malloc"`
	MemFrees      int64 `json:"mem.free"`
	// Heap
	HeapAlloc    int64 `json:"mem.heap.alloc"`
	HeapSys      int64 `json:"mem.heap.sys"`
	HeapIdle     int64 `json:"mem.heap.idle"`
	HeapInuse    int64 `json:"mem.heap.inuse"`
	HeapReleased int64 `json:"mem.heap.released"`
	HeapObjects  int64 `json:"mem.heap.objects"`
	// Stack
	StackInuse  int64 `json:"mem.stack.inuse"`
	StackSys    int64 `json:"mem.stack.sys"`
	MSpanInuse  int64 `json:"mem.stack.mspan_inuse"`
	MSpanSys    int64 `json:"mem.stack.mspan_sys"`
	MCacheInuse int64 `json:"mem.stack.mcache_inuse"`
	MCacheSys   int64 `json:"mem.stack.mcache_sys"`
	OtherSys    int64 `json:"mem.othersys"`
	// GC
	GCSys         int64   `json:"mem.gc.sys"`
	NextGC        int64   `json:"mem.gc.next"`
	LastGC        int64   `json:"mem.gc.last"`
	PauseTotalNs  int64   `json:"mem.gc.pause_total"`
	PauseNs       int64   `json:"mem.gc.pause"`
	NumGC         int64   `json:"mem.gc.count"`
	GCCPUFraction float64 `json:"mem.gc.cpu_fraction"`
}

Stats represents collected statistics

func (*Stats) Collect

func (s *Stats) Collect()

Collect is used to fill the struct with current metrics

Jump to

Keyboard shortcuts

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