Documentation ¶
Index ¶
- type Accumulator
- type Average
- type TimedFloat64Buckets
- func (t *TimedFloat64Buckets) ForEachBucket(now time.Time, accs ...Accumulator) bool
- func (t *TimedFloat64Buckets) IsEmpty(now time.Time) bool
- func (t *TimedFloat64Buckets) Record(now time.Time, value float64)
- func (t *TimedFloat64Buckets) ResizeWindow(w time.Duration)
- func (t *TimedFloat64Buckets) String() string
- func (t *TimedFloat64Buckets) WindowAverage(now time.Time) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accumulator ¶
Accumulator is a function accumulating buckets and their time.
func YoungerThan ¶
func YoungerThan(oldest time.Time, acc Accumulator) Accumulator
YoungerThan only applies the accumulator to buckets that are younger than the given time.
type Average ¶
type Average struct {
// contains filtered or unexported fields
}
Average is used to keep the values necessary to compute an average.
func (*Average) Accumulate ¶
Accumulate accumulates the values needed to compute an average.
type TimedFloat64Buckets ¶
type TimedFloat64Buckets struct {
// contains filtered or unexported fields
}
TimedFloat64Buckets keeps buckets that have been collected at a certain time.
func NewTimedFloat64Buckets ¶
func NewTimedFloat64Buckets(window, granularity time.Duration) *TimedFloat64Buckets
NewTimedFloat64Buckets generates a new TimedFloat64Buckets with the given granularity.
func (*TimedFloat64Buckets) ForEachBucket ¶
func (t *TimedFloat64Buckets) ForEachBucket(now time.Time, accs ...Accumulator) bool
ForEachBucket calls the given Accumulator function for each bucket. Returns true if any data was recorded.
func (*TimedFloat64Buckets) IsEmpty ¶
func (t *TimedFloat64Buckets) IsEmpty(now time.Time) bool
IsEmpty returns if no data has been recorded for the `window` period.
func (*TimedFloat64Buckets) Record ¶
func (t *TimedFloat64Buckets) Record(now time.Time, value float64)
Record adds a value with an associated time to the correct bucket.
func (*TimedFloat64Buckets) ResizeWindow ¶ added in v0.12.0
func (t *TimedFloat64Buckets) ResizeWindow(w time.Duration)
ResizeWindow resizes the window. This is an O(N) operation, and is not supposed to be executed very often.
func (*TimedFloat64Buckets) String ¶ added in v0.12.0
func (t *TimedFloat64Buckets) String() string
Implements stringer interface.
func (*TimedFloat64Buckets) WindowAverage ¶ added in v0.12.0
func (t *TimedFloat64Buckets) WindowAverage(now time.Time) float64
WindowAverage returns the average bucket value over the window.