Documentation ¶
Overview ¶
Package stats supports the collection of metrics from a running component.
Index ¶
- Variables
- func DecCounter(name string)
- func IncCounter(name string)
- func Initialize()
- func MarkMeter(name string)
- func NewRegistry() metrics.Registry
- func SetString(name, tag, value string)
- func SetTimeout(name string, ttl uint)
- func UpdateHistogram(name string, value int64)
- type NilString
- type StandardString
- type String
- type StringSnapshot
- type TTNRegistry
- func (r *TTNRegistry) Each(f func(string, interface{}))
- func (r *TTNRegistry) Get(name string) interface{}
- func (r *TTNRegistry) GetOrRegister(name string, i interface{}) interface{}
- func (r *TTNRegistry) Register(name string, i interface{}) error
- func (r *TTNRegistry) Renew(name string)
- func (r *TTNRegistry) RunHealthchecks()
- func (r *TTNRegistry) SetDefaultTTL(ticks uint)
- func (r *TTNRegistry) SetTTL(name string, ticks uint)
- func (r *TTNRegistry) Tick()
- func (r *TTNRegistry) Unregister(name string)
- func (r *TTNRegistry) UnregisterAll()
- type Ticker
Constants ¶
This section is empty.
Variables ¶
var DefaultTTL uint = 0
DefaultTTL for the registry
var Enabled = true
Enabled activates stats collection
var Registry = NewRegistry()
Registry is the default metrics registry
Functions ¶
func NewRegistry ¶
func NewRegistry() metrics.Registry
NewRegistry reates a new registry and starts a goroutine for the TTL.
func UpdateHistogram ¶
UpdateHistogram registers a new value for a histogram
Types ¶
type StandardString ¶
type StandardString struct {
// contains filtered or unexported fields
}
StandardString is the standard implementation of a String.
func (*StandardString) Get ¶
func (m *StandardString) Get() map[string]string
Get returns the number of events recorded.
func (*StandardString) Set ¶
func (m *StandardString) Set(tag, str string)
Set sets the String to the given value.
func (*StandardString) Snapshot ¶
func (m *StandardString) Snapshot() String
Snapshot returns a read-only copy of the string.
type String ¶
String stores a string
func GetOrRegisterString ¶
GetOrRegisterString returns an existing String or constructs and registers a new StandardString.
func NewRegisteredString ¶
NewRegisteredString constructs and registers a new StandardString.
type StringSnapshot ¶
type StringSnapshot struct {
// contains filtered or unexported fields
}
StringSnapshot is a read-only copy of another String.
func (*StringSnapshot) Get ¶
func (m *StringSnapshot) Get() map[string]string
Get returns the value of events at the time the snapshot was taken.
func (*StringSnapshot) Snapshot ¶
func (m *StringSnapshot) Snapshot() String
Snapshot returns the snapshot.
type TTNRegistry ¶
type TTNRegistry struct {
// contains filtered or unexported fields
}
TTNRegistry is a mutex-protected map of names to metrics. It is basically an extension of https://github.com/rcrowley/go-metrics/blob/master/registry.go
func (*TTNRegistry) Each ¶
func (r *TTNRegistry) Each(f func(string, interface{}))
Each calls the given function for each registered metric.
func (*TTNRegistry) Get ¶
func (r *TTNRegistry) Get(name string) interface{}
Get the metric by the given name or nil if none is registered.
func (*TTNRegistry) GetOrRegister ¶
func (r *TTNRegistry) GetOrRegister(name string, i interface{}) interface{}
GetOrRegister gets an existing metric or creates and registers a new one. Threadsafe alternative to calling Get and Register on failure. The interface can be the metric to register if not found in registry, or a function returning the metric for lazy instantiation.
func (*TTNRegistry) Register ¶
func (r *TTNRegistry) Register(name string, i interface{}) error
Register the given metric under the given name. Returns a DuplicateMetric if a metric by the given name is already registered.
func (*TTNRegistry) Renew ¶
func (r *TTNRegistry) Renew(name string)
Renew sets the TTL of a metric to the default value
func (*TTNRegistry) RunHealthchecks ¶
func (r *TTNRegistry) RunHealthchecks()
RunHealthchecks runs all registered healthchecks.
func (*TTNRegistry) SetDefaultTTL ¶
func (r *TTNRegistry) SetDefaultTTL(ticks uint)
SetDefaultTTL sets a default TTL of a number of ticks for all new metrics
func (*TTNRegistry) SetTTL ¶
func (r *TTNRegistry) SetTTL(name string, ticks uint)
SetTTL sets a TTL of a number of ticks for a given metric
func (*TTNRegistry) Tick ¶
func (r *TTNRegistry) Tick()
Tick decreases the TTL of all metrics that have one If the TTL becomes zero, the metric is deleted
func (*TTNRegistry) Unregister ¶
func (r *TTNRegistry) Unregister(name string)
Unregister the metric with the given name.
func (*TTNRegistry) UnregisterAll ¶
func (r *TTNRegistry) UnregisterAll()
UnregisterAll unregisters all metrics. (Mostly for testing.)