Documentation ¶
Overview ¶
Go port of Coda Hale's Metrics library
<https://github.com/rcrowley/go-metrics>
Coda Hale's original work: <https://github.com/codahale/metrics>
Index ¶
- Variables
- func Get(name string) interface{}
- type Counter
- type DuplicateMetric
- type EWMA
- type EWMASnapshot
- type Gauge
- type GaugeFloat64
- type Healthcheck
- type Histogram
- type Meter
- type MeterSnapshot
- func (m *MeterSnapshot) Count() int64
- func (*MeterSnapshot) Mark(n int64)
- func (m *MeterSnapshot) Rate1() float64
- func (m *MeterSnapshot) Rate15() float64
- func (m *MeterSnapshot) Rate5() float64
- func (m *MeterSnapshot) RateMean() float64
- func (m *MeterSnapshot) Snapshot() Meter
- func (m *MeterSnapshot) Stop()
- type NilEWMA
- type NilMeter
- type Registry
- type ResettingTimer
- type Sample
- type StandardEWMA
- type StandardMeter
- func (m *StandardMeter) Count() int64
- func (m *StandardMeter) Mark(n int64)
- func (m *StandardMeter) Rate1() float64
- func (m *StandardMeter) Rate15() float64
- func (m *StandardMeter) Rate5() float64
- func (m *StandardMeter) RateMean() float64
- func (m *StandardMeter) Snapshot() Meter
- func (m *StandardMeter) Stop()
- type StandardRegistry
- func (r *StandardRegistry) Each(f func(string, interface{}))
- func (r *StandardRegistry) Get(name string) interface{}
- func (r *StandardRegistry) GetAll() map[string]map[string]interface{}
- func (r *StandardRegistry) GetOrRegister(name string, i interface{}) interface{}
- func (r *StandardRegistry) MarshalJSON() ([]byte, error)
- func (r *StandardRegistry) Register(name string, i interface{}) error
- func (r *StandardRegistry) RunHealthchecks()
- func (r *StandardRegistry) Unregister(name string)
- func (r *StandardRegistry) UnregisterAll()
- type Stoppable
- type Timer
Constants ¶
This section is empty.
Variables ¶
var ( DefaultRegistry = NewRegistry() EphemeralRegistry = NewRegistry() AccountingRegistry = NewRegistry() // registry used in swarm )
Functions ¶
Types ¶
type DuplicateMetric ¶
type DuplicateMetric string
DuplicateMetric is the error returned by Registry.Register when a metric already exists. If you mean to Register that metric you must first Unregister the existing metric.
func (DuplicateMetric) Error ¶
func (err DuplicateMetric) Error() string
type EWMA ¶
EWMAs continuously calculate an exponentially-weighted moving average based on an outside source of clock ticks.
func NewEWMA1 ¶
func NewEWMA1() EWMA
NewEWMA1 constructs a new EWMA for a one-minute moving average.
type EWMASnapshot ¶
type EWMASnapshot float64
EWMASnapshot is a read-only copy of another EWMA.
func (EWMASnapshot) Rate ¶
func (a EWMASnapshot) Rate() float64
Rate returns the rate of events per second at the time the snapshot was taken.
type GaugeFloat64 ¶
type GaugeFloat64 interface { Snapshot() GaugeFloat64 Update(float64) Value() float64 }
GaugeFloat64s hold a float64 value that can be set arbitrarily.
type Healthcheck ¶
Healthchecks hold an error value describing an arbitrary up/down status.
type Histogram ¶
type Histogram interface { Clear() Count() int64 Max() int64 Mean() float64 Min() int64 Percentile(float64) float64 Percentiles([]float64) []float64 Sample() Sample Snapshot() Histogram StdDev() float64 Sum() int64 Update(int64) Variance() float64 }
Histograms calculate distribution statistics from a series of int64 values.
type Meter ¶
type Meter interface { Count() int64 Mark(int64) Rate1() float64 Rate5() float64 Rate15() float64 RateMean() float64 Snapshot() Meter Stop() }
Meters count events to produce exponentially-weighted moving average rates at one-, five-, and fifteen-minutes and a mean rate.
func NewMeterForced ¶
func NewMeterForced() Meter
NewMeterForced constructs a new StandardMeter and launches a goroutine no matter the global switch is enabled or not. Be sure to call Stop() once the meter is of no use to allow for garbage collection.
type MeterSnapshot ¶
type MeterSnapshot struct {
// contains filtered or unexported fields
}
MeterSnapshot is a read-only copy of another Meter.
func (*MeterSnapshot) Count ¶
func (m *MeterSnapshot) Count() int64
Count returns the count of events at the time the snapshot was taken.
func (*MeterSnapshot) Rate1 ¶
func (m *MeterSnapshot) Rate1() float64
Rate1 returns the one-minute moving average rate of events per second at the time the snapshot was taken.
func (*MeterSnapshot) Rate15 ¶
func (m *MeterSnapshot) Rate15() float64
Rate15 returns the fifteen-minute moving average rate of events per second at the time the snapshot was taken.
func (*MeterSnapshot) Rate5 ¶
func (m *MeterSnapshot) Rate5() float64
Rate5 returns the five-minute moving average rate of events per second at the time the snapshot was taken.
func (*MeterSnapshot) RateMean ¶
func (m *MeterSnapshot) RateMean() float64
RateMean returns the meter's mean rate of events per second at the time the snapshot was taken.
func (*MeterSnapshot) Snapshot ¶
func (m *MeterSnapshot) Snapshot() Meter
Snapshot returns the snapshot.
type Registry ¶
type Registry interface { // Call the given function for each registered metric. Each(func(string, interface{})) // Get the metric by the given name or nil if none is registered. Get(string) interface{} // GetAll metrics in the Registry. GetAll() map[string]map[string]interface{} // Gets an existing metric or registers the given one. // The interface can be the metric to register if not found in registry, // or a function returning the metric for lazy instantiation. GetOrRegister(string, interface{}) interface{} // Register the given metric under the given name. Register(string, interface{}) error // Run all registered healthchecks. RunHealthchecks() // Unregister the metric with the given name. Unregister(string) // Unregister all metrics. (Mostly for testing.) UnregisterAll() }
A Registry holds references to a set of metrics by name and can iterate over them, calling callback functions provided by the user.
This is an interface so as to encourage other structs to implement the Registry API as appropriate.
type ResettingTimer ¶
type ResettingTimer interface { Values() []int64 Snapshot() ResettingTimer Percentiles([]float64) []int64 Mean() float64 Time(func()) Update(time.Duration) UpdateSince(time.Time) }
ResettingTimer is used for storing aggregated values for timers, which are reset on every flush interval.
type Sample ¶
type Sample interface { Clear() Count() int64 Max() int64 Mean() float64 Min() int64 Percentile(float64) float64 Percentiles([]float64) []float64 Size() int Snapshot() Sample StdDev() float64 Sum() int64 Update(int64) Values() []int64 Variance() float64 }
Samples maintain a statistically-significant selection of values from a stream.
type StandardEWMA ¶
type StandardEWMA struct {
// contains filtered or unexported fields
}
StandardEWMA is the standard implementation of an EWMA and tracks the number of uncounted events and processes them on each tick. It uses the sync/atomic package to manage uncounted events.
func (*StandardEWMA) Rate ¶
func (a *StandardEWMA) Rate() float64
Rate returns the moving average rate of events per second.
func (*StandardEWMA) Snapshot ¶
func (a *StandardEWMA) Snapshot() EWMA
Snapshot returns a read-only copy of the EWMA.
func (*StandardEWMA) Tick ¶
func (a *StandardEWMA) Tick()
Tick ticks the clock to update the moving average. It assumes it is called every five seconds.
func (*StandardEWMA) Update ¶
func (a *StandardEWMA) Update(n int64)
Update adds n uncounted events.
type StandardMeter ¶
type StandardMeter struct {
// contains filtered or unexported fields
}
StandardMeter is the standard implementation of a Meter.
func (*StandardMeter) Count ¶
func (m *StandardMeter) Count() int64
Count returns the number of events recorded. It updates the meter to be as accurate as possible
func (*StandardMeter) Mark ¶
func (m *StandardMeter) Mark(n int64)
Mark records the occurrence of n events.
func (*StandardMeter) Rate1 ¶
func (m *StandardMeter) Rate1() float64
Rate1 returns the one-minute moving average rate of events per second.
func (*StandardMeter) Rate15 ¶
func (m *StandardMeter) Rate15() float64
Rate15 returns the fifteen-minute moving average rate of events per second.
func (*StandardMeter) Rate5 ¶
func (m *StandardMeter) Rate5() float64
Rate5 returns the five-minute moving average rate of events per second.
func (*StandardMeter) RateMean ¶
func (m *StandardMeter) RateMean() float64
RateMean returns the meter's mean rate of events per second.
func (*StandardMeter) Snapshot ¶
func (m *StandardMeter) Snapshot() Meter
Snapshot returns a read-only copy of the meter.
func (*StandardMeter) Stop ¶
func (m *StandardMeter) Stop()
Stop stops the meter, Mark() will be a no-op if you use it after being stopped.
type StandardRegistry ¶
type StandardRegistry struct {
// contains filtered or unexported fields
}
The standard implementation of a Registry is a mutex-protected map of names to metrics.
func (*StandardRegistry) Each ¶
func (r *StandardRegistry) Each(f func(string, interface{}))
Call the given function for each registered metric.
func (*StandardRegistry) Get ¶
func (r *StandardRegistry) Get(name string) interface{}
Get the metric by the given name or nil if none is registered.
func (*StandardRegistry) GetAll ¶
func (r *StandardRegistry) GetAll() map[string]map[string]interface{}
GetAll metrics in the Registry
func (*StandardRegistry) GetOrRegister ¶
func (r *StandardRegistry) GetOrRegister(name string, i interface{}) interface{}
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 (*StandardRegistry) MarshalJSON ¶
func (r *StandardRegistry) MarshalJSON() ([]byte, error)
MarshalJSON returns a byte slice containing a JSON representation of all the metrics in the Registry.
func (*StandardRegistry) Register ¶
func (r *StandardRegistry) 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 (*StandardRegistry) RunHealthchecks ¶
func (r *StandardRegistry) RunHealthchecks()
Run all registered healthchecks.
func (*StandardRegistry) Unregister ¶
func (r *StandardRegistry) Unregister(name string)
Unregister the metric with the given name.
func (*StandardRegistry) UnregisterAll ¶
func (r *StandardRegistry) UnregisterAll()
Unregister all metrics. (Mostly for testing.)
type Stoppable ¶
type Stoppable interface {
Stop()
}
Stoppable defines the metrics which has to be stopped.
type Timer ¶
type Timer interface { Count() int64 Max() int64 Mean() float64 Min() int64 Percentile(float64) float64 Percentiles([]float64) []float64 Rate1() float64 Rate5() float64 Rate15() float64 RateMean() float64 Snapshot() Timer StdDev() float64 Stop() Sum() int64 Time(func()) Update(time.Duration) UpdateSince(time.Time) Variance() float64 }
Timers capture the duration and rate of events.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Hook go-metrics into expvar on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler
|
Hook go-metrics into expvar on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler |