import "v.io/x/ref/lib/stats"
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")
counter.go float.go func.go glob.go histogram.go integer.go map.go stats.go string.go
Delete deletes a StatsObject and all its children, if any.
NewCounter creates a new Counter StatsObject with the given name and returns a pointer to it.
NewHistogram creates a new Histogram StatsObject with the given name and returns a pointer to it.
Value returns the value of an object, or an error if the object doesn't exist.
type Float struct {
// contains filtered or unexported fields
}
Float implements the StatsObject interface.
NewFloat creates a new Float StatsObject with the given name and returns a pointer to it.
Incr increments the value of the object.
LastUpdate returns the time at which the object was last updated.
Set sets the value of the object.
Value returns the current value of the object.
type GlobIterator struct {
// contains filtered or unexported fields
}
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 (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 (i GlobIterator) Err() error
Err returns a non-nil error iff the stream encountered any errors. Err does not block.
func (i GlobIterator) Value() KeyValue
Value returns the element that was staged by Advance. Value does not block.
type Integer struct {
// contains filtered or unexported fields
}
Integer implements the StatsObject interface.
NewInteger creates a new Integer StatsObject with the given name and returns a pointer to it.
Incr increments the value of the object.
LastUpdate returns the time at which the object was last updated.
Set sets the value of the object.
Value returns the current value of the object.
KeyValue stores a Key and a Value.
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.
NewMap creates a new Map StatsObject with the given name and returns a pointer to it.
Delete deletes the given keys from the map object.
Incr increments the value of the given key and returns the new value.
Keys returns a sorted list of all the keys in the map.
LastUpdate always returns a zero-value Time for a Map.
Set sets the values of the given keys. There must be exactly one value for each key.
Value always returns nil for a Map.
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. nolint:golint // API change required.
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(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(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(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 struct {
// contains filtered or unexported fields
}
String implements the StatsObject interface.
NewString creates a new String StatsObject with the given name and returns a pointer to it.
LastUpdate returns the time at which the object was last updated.
Set sets the value of the object.
Value returns the current value of the object.
Path | Synopsis |
---|---|
counter | Package counter implements counters that keeps track of their recent values over different periods of time. |
histogram | Package histogram implements a basic histogram to keep track of data distribution. |
sysstats | Package sysstats implements system statistics and updates them periodically. |
Package stats imports 10 packages (graph) and is imported by 41 packages. Updated 2020-10-22. Refresh now. Tools for package owners.