Documentation ¶
Overview ¶
Package stats implements a global repository of stats objects. Each object has a name and a value. Example:
bar1 := stats.NewInteger("foo/bar1") bar2 := stats.NewFloat("foo/bar2") bar3 := stats.NewCounter("foo/bar3") bar1.Set(1) bar2.Set(2) bar3.Set(3)
The values can be retrieved with:
v, err := stats.Value("foo/bar1")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCounter ¶
NewCounter creates a new Counter StatsObject with the given name and returns a pointer to it.
func NewHistogram ¶
NewHistogram creates a new Histogram StatsObject with the given name and returns a pointer to it.
Types ¶
type Float ¶
type Float struct {
// contains filtered or unexported fields
}
Float implements the StatsObject interface.
func NewFloat ¶
NewFloat creates a new Float StatsObject with the given name and returns a pointer to it.
func (*Float) LastUpdate ¶
LastUpdate returns the time at which the object was last updated.
type GlobIterator ¶
type GlobIterator struct {
// contains filtered or unexported fields
}
func Glob ¶
Glob returns the name and (optionally) the value of all the objects that match the given pattern and have been updated since 'updatedSince'. The 'root' argument is the name of the object where the pattern starts. Example:
a/b/c a/b/d b/e/f
Glob("", "...", time.Time{}, true) will return "a/b/c", "a/b/d", "b/e/f" and their values. Glob("a/b", "*", time.Time{}, true) will return "c", "d" and their values.
func (*GlobIterator) Advance ¶
func (i *GlobIterator) Advance() bool
Advance stages the next element so that the client can retrieve it with Value(). It returns true iff there is an element to retrieve. The client must call Advance() before calling Value(). Advance may block if an element is not immediately available.
func (GlobIterator) Err ¶
func (i GlobIterator) Err() error
Err returns a non-nil error iff the stream encountered any errors. Err does not block.
func (GlobIterator) Value ¶
func (i GlobIterator) Value() KeyValue
Value returns the element that was staged by Advance. Value does not block.
type Integer ¶
type Integer struct {
// contains filtered or unexported fields
}
Integer implements the StatsObject interface.
func NewInteger ¶
NewInteger creates a new Integer StatsObject with the given name and returns a pointer to it.
func (*Integer) LastUpdate ¶
LastUpdate returns the time at which the object was last updated.
type KeyValue ¶
type KeyValue struct { Key string Value interface{} }
KeyValue stores a Key and a Value.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map implements the StatsObject interface. The map keys are strings and the values can be bool, int64, uint64, float64, string, or time.Time.
func (*Map) LastUpdate ¶
LastUpdate always returns a zero-value Time for a Map.
type StatsObject ¶
type StatsObject interface { // LastUpdate is used by WatchGlob to decide which updates to send. LastUpdate() time.Time // Value returns the current value of the object. Value() interface{} }
StatsObject is the interface for objects stored in the stats repository.
func GetStatsObject ¶
func GetStatsObject(name string) (StatsObject, error)
GetStatsObject returns the object with that given name, or an error if the object doesn't exist.
func NewFloatFunc ¶
func NewFloatFunc(name string, function func() float64) StatsObject
NewFloatFunc creates a new StatsObject with the given name. The function argument must return a float64 value.
func NewIntegerFunc ¶
func NewIntegerFunc(name string, function func() int64) StatsObject
NewIntegerFunc creates a new StatsObject with the given name. The function argument must return an int64 value.
func NewStringFunc ¶
func NewStringFunc(name string, function func() string) StatsObject
NewStringFunc creates a new StatsObject with the given name. The function argument must return a string value.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String implements the StatsObject interface.
func NewString ¶
NewString creates a new String StatsObject with the given name and returns a pointer to it.
func (*String) LastUpdate ¶
LastUpdate returns the time at which the object was last updated.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package counter implements counters that keeps track of their recent values over different periods of time.
|
Package counter implements counters that keeps track of their recent values over different periods of time. |
Package histogram implements a basic histogram to keep track of data distribution.
|
Package histogram implements a basic histogram to keep track of data distribution. |
Package sysstats implements system statistics and updates them periodically.
|
Package sysstats implements system statistics and updates them periodically. |