Documentation ¶
Overview ¶
selfstat is a package for tracking and collecting internal statistics about the agent. Metrics can be registered using this package, and then incremented or set within your code. If the inputs.internal plugin is enabled, then all registered stats will be collected as they would by any other input plugin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Stat ¶
type Stat interface { // Name is the name of the measurement Name() string // FieldName is the name of the measurement field FieldName() string // Tags is a tag map. Each time this is called a new map is allocated. Tags() map[string]string // Incr increments a regular stat by 'v'. // in the case of a timing stat, increment adds the timing to the cache. Incr(v int64) // Set sets a regular stat to 'v'. // in the case of a timing stat, set adds the timing to the cache. Set(v int64) // Get gets the value of the stat. In the case of timings, this returns // an average value of all timings received since the last call to Get(). // If no timings were received, it returns the previous value. Get() int64 }
Stat is an interface for dealing with agent statistics collected on itself.
func Register ¶
Register registers the given measurement, field, and tags in the selfstat registry. If given an identical measurement, it will return the stat that's already been registered.
The returned Stat can be incremented by the consumer of Register(), and it's value will be returned as an agent metric when Metrics() is called.
func RegisterTiming ¶
RegisterTiming registers the given measurement, field, and tags in the selfstat registry. If given an identical measurement, it will return the stat that's already been registered.
Timing stats differ from regular stats in that they accumulate multiple "timings" added to them, and will return the average when Get() is called. After Get() is called, the average is cleared and the next timing returned from Get() will only reflect timings added since the previous call to Get(). If Get() is called without receiving any new timings, then the previous value is used.
In other words, timings are an averaged metric that get cleared on each call to Get().
The returned Stat can be incremented by the consumer of Register(), and it's value will be returned as an agent metric when Metrics() is called.