monitoring

package
v6.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2017 License: Apache-2.0 Imports: 9 Imported by: 4,445

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = NewRegistry()

Default is the global default metrics registry provided by the monitoring package.

Functions

func Clear

func Clear() error

func CollectStructSnapshot

func CollectStructSnapshot(r *Registry, mode Mode, expvar bool) map[string]interface{}

CollectStructSnapshot collects a structured metrics snaphot of a metrics tree starting with the given registry. Empty namespaces will be omitted.

func Do

func Do(mode Mode, f func(string, interface{}))

func DoExpvars

func DoExpvars(f func(string, interface{}))

func DoNotReport

func DoNotReport(o options) options

func IgnorePublishExpvar

func IgnorePublishExpvar(o options) options

IgnorePublishExpvar disables publishing expvar variables in a sub-registry.

func PublishExpvar

func PublishExpvar(o options) options

PublishExpvar enables publishing all registered variables via expvar interface. Note: expvar does not allow removal of any stats.

func Remove

func Remove(name string)

func Report

func Report(o options) options

func ReportBool

func ReportBool(V Visitor, name string, value bool)

func ReportFloat

func ReportFloat(V Visitor, name string, value float64)

func ReportInt

func ReportInt(V Visitor, name string, value int64)

func ReportNamespace

func ReportNamespace(V Visitor, name string, f func())

func ReportString

func ReportString(V Visitor, name string, value string)

func ReportVar

func ReportVar(V Visitor, name string, m Mode, v Var)

func Visit

func Visit(vs Visitor)

func VisitExpvars

func VisitExpvars(vs Visitor)

VisitExpvars iterates all expvar metrics using the Visitor interface. The top-level metrics "memstats" and "cmdline", plus all monitoring.X metric types are ignored.

func VisitMode

func VisitMode(mode Mode, vs Visitor)

Types

type FlatSnapshot

type FlatSnapshot struct {
	Bools   map[string]bool
	Ints    map[string]int64
	Floats  map[string]float64
	Strings map[string]string
}

FlatSnapshot represents a flatten snapshot of all metrics. Names in the tree will be joined with `.` .

func CollectFlatSnapshot

func CollectFlatSnapshot(r *Registry, mode Mode, expvar bool) FlatSnapshot

CollectFlatSnapshot collects a flattened snapshot of a metrics tree start with the given registry.

func MakeFlatSnapshot

func MakeFlatSnapshot() FlatSnapshot

type Float

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

Float is a 64 bit float variable satisfying the Var interface.

func NewFloat

func NewFloat(r *Registry, name string, opts ...Option) *Float

NewFloat creates and registers a new float variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*Float) Add

func (v *Float) Add(delta float64)

func (*Float) Get

func (v *Float) Get() float64

func (*Float) Set

func (v *Float) Set(value float64)

func (*Float) Sub

func (v *Float) Sub(delta float64)

func (*Float) Visit

func (v *Float) Visit(_ Mode, vs Visitor)

type Func

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

func NewFunc

func NewFunc(r *Registry, name string, f func(Mode, Visitor), opts ...Option) *Func

func (*Func) Visit

func (f *Func) Visit(m Mode, vs Visitor)

type FuncVar

type FuncVar func(Mode, Visitor)

func (FuncVar) Visit

func (f FuncVar) Visit(m Mode, vs Visitor)

type Int

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

Int is a 64 bit integer variable satisfying the Var interface.

func NewInt

func NewInt(r *Registry, name string, opts ...Option) *Int

NewInt creates and registers a new integer variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*Int) Add

func (v *Int) Add(delta int64)

func (*Int) Dec

func (v *Int) Dec()

func (*Int) Get

func (v *Int) Get() int64

func (*Int) Inc

func (v *Int) Inc()

func (*Int) Set

func (v *Int) Set(value int64)

func (*Int) Sub

func (v *Int) Sub(delta int64)

func (*Int) Visit

func (v *Int) Visit(_ Mode, vs Visitor)

type KeyValueVisitor

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

func NewKeyValueVisitor

func NewKeyValueVisitor(cb func(string, interface{})) *KeyValueVisitor

func (*KeyValueVisitor) OnBool

func (vs *KeyValueVisitor) OnBool(b bool)

func (*KeyValueVisitor) OnFloat

func (vs *KeyValueVisitor) OnFloat(f float64)

func (*KeyValueVisitor) OnInt

func (vs *KeyValueVisitor) OnInt(i int64)

func (*KeyValueVisitor) OnKey

func (vs *KeyValueVisitor) OnKey(name string)

func (*KeyValueVisitor) OnNil

func (vs *KeyValueVisitor) OnNil()

func (*KeyValueVisitor) OnRegistryFinished

func (vs *KeyValueVisitor) OnRegistryFinished()

func (*KeyValueVisitor) OnRegistryStart

func (vs *KeyValueVisitor) OnRegistryStart()

func (*KeyValueVisitor) OnString

func (vs *KeyValueVisitor) OnString(s string)

type Mode

type Mode uint8
const (
	// Reported mode, is lowest report level with most basic metrics only
	Reported Mode = iota

	// Full reports all metrics
	Full
)

func (Mode) String

func (i Mode) String() string

type Option

type Option func(options) options

Option type for passing additional options to NewRegistry.

type Registry

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

Registry to store variables and sub-registries. When adding or retrieving variables, all names are split on the `.`-symbol and intermediate registries will be generated.

func GetRegistry

func GetRegistry(name string) *Registry

func NewRegistry

func NewRegistry(opts ...Option) *Registry

NewRegistry create a new empty unregistered registry

func (*Registry) Add

func (r *Registry) Add(name string, v Var, m Mode)

Add adds a new variable to the registry. The method panics if the variables name is already in use.

func (*Registry) Clear

func (r *Registry) Clear() error

Clear removes all entries from the current registry

func (*Registry) Do

func (r *Registry) Do(mode Mode, f func(string, interface{}))

func (*Registry) Get

func (r *Registry) Get(name string) Var

Get tries to find a registered variable by name.

func (*Registry) GetRegistry

func (r *Registry) GetRegistry(name string) *Registry

GetRegistry tries to find a sub-registry by name.

func (*Registry) NewRegistry

func (r *Registry) NewRegistry(name string, opts ...Option) *Registry

NewRegistry creates and register a new registry

func (*Registry) Remove

func (r *Registry) Remove(name string)

Remove removes a variable or a sub-registry by name

func (*Registry) Visit

func (r *Registry) Visit(mode Mode, vs Visitor)

Visit uses the Visitor interface to iterate the complete metrics hieararchie. In case of the visitor reporting an error, Visit will return immediately, reporting the very same error.

type RegistryVisitor

type RegistryVisitor interface {
	OnRegistryStart()
	OnRegistryFinished()
	OnKey(s string)
}

type String

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

String is a string variable satisfying the Var interface.

func NewString

func NewString(r *Registry, name string, opts ...Option) *String

NewString creates and registers a new string variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*String) Clear

func (v *String) Clear()

func (*String) Fail

func (v *String) Fail(err error)

func (*String) Get

func (v *String) Get() string

func (*String) Set

func (v *String) Set(s string)

func (*String) Visit

func (v *String) Visit(_ Mode, vs Visitor)

type Uint

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

Uint is a 64bit unsigned integer variable satisfying the Var interface.

func NewUint

func NewUint(r *Registry, name string, opts ...Option) *Uint

NewUint creates and registers a new unsigned integer variable.

Note: If the registry is configured to publish variables to expvar, the variable will be available via expvars package as well, but can not be removed anymore.

func (*Uint) Add

func (v *Uint) Add(delta uint64)

func (*Uint) Dec

func (v *Uint) Dec()

func (*Uint) Get

func (v *Uint) Get() uint64

func (*Uint) Inc

func (v *Uint) Inc()

func (*Uint) Set

func (v *Uint) Set(value uint64)

func (*Uint) Sub

func (v *Uint) Sub(delta uint64)

func (*Uint) Visit

func (v *Uint) Visit(_ Mode, vs Visitor)

type ValueVisitor

type ValueVisitor interface {
	OnString(s string)
	OnBool(b bool)
	OnInt(i int64)
	OnFloat(f float64)
}

type Var

type Var interface {
	Visit(Mode, Visitor)
}

Var interface required for every metric to implement.

func Get

func Get(name string) Var

type Visitor

type Visitor interface {
	ValueVisitor
	RegistryVisitor
}

Visitor interface supports traversing a monitoring registry

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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