Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EWMA ¶
type EWMA interface { Snapshot() EWMASnapshot Tick() Update(int64) }
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.
func NewEWMA15 ¶
func NewEWMA15() EWMA
NewEWMA15 constructs a new EWMA for a fifteen-minute moving average.
type EWMASnapshot ¶
type EWMASnapshot interface {
Rate() float64
}
type Meter ¶
type Meter interface { Mark(int64) Snapshot() MeterSnapshot Stop() }
Meters count events to produce exponentially-weighted moving average rates at one-, five-, and fifteen-minutes and a mean rate.
func NewInactiveMeter ¶
func NewInactiveMeter() Meter
NewInactiveMeter returns a meter but does not start any goroutines. This method is mainly intended for testing.
type MeterSnapshot ¶
type NonStandardEWMA ¶
type NonStandardEWMA struct {
// contains filtered or unexported fields
}
NonStandardEWMA is a non-standard implementation of an EWMA and tracks the number of uncounted events and processes them on each tick. Differentially from StandardEWMA, it provides a method to update the rate based on the interval between ticks.
func (*NonStandardEWMA) SetInterval ¶
func (a *NonStandardEWMA) SetInterval(interval time.Duration) *NonStandardEWMA
func (*NonStandardEWMA) Snapshot ¶
func (a *NonStandardEWMA) Snapshot() EWMASnapshot
Snapshot returns a read-only copy of the EWMA.
func (*NonStandardEWMA) Tick ¶
func (a *NonStandardEWMA) Tick()
Tick ticks the clock to update the moving average. It assumes it is called every five seconds.
func (*NonStandardEWMA) Update ¶
func (a *NonStandardEWMA) Update(n int64)
Update adds n uncounted events.
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) Snapshot ¶
func (a *StandardEWMA) Snapshot() EWMASnapshot
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) Mark ¶
func (m *StandardMeter) Mark(n int64)
Mark records the occurrence of n events.
func (*StandardMeter) Snapshot ¶
func (m *StandardMeter) Snapshot() MeterSnapshot
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.