Documentation ¶
Index ¶
- type Accumulator
- func (ac *Accumulator) GetAllSamples() *SampleGroup
- func (ac *Accumulator) GetLastSamples(n int) *SampleGroup
- func (ac *Accumulator) GetSamplesSince(t time.Time) *SampleGroup
- func (ac *Accumulator) Increment()
- func (ac *Accumulator) IncrementBy(acc int64)
- func (ac *Accumulator) Run()
- func (ac *Accumulator) RunOnce(t time.Time)
- func (ac *Accumulator) Sum() int64
- type Sample
- type SampleGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accumulator ¶
type Accumulator struct { sync.RWMutex Label string // used to identify the owner of an accumulator Samples []*Sample // contains filtered or unexported fields }
Accumulator stores data on an interval and allows you to access it.
func NewAccumulator ¶
func NewAccumulator(ctx context.Context, storedSamples int, interval time.Duration, label string) *Accumulator
NewAccumulator creates an accumulator. This does not automatically call Run.
func (*Accumulator) GetAllSamples ¶
func (ac *Accumulator) GetAllSamples() *SampleGroup
GetAllSamples returns all samples from the accumulator.
func (*Accumulator) GetLastSamples ¶
func (ac *Accumulator) GetLastSamples(n int) *SampleGroup
GetLastSamples returns the last N samples from the accumulator.
func (*Accumulator) GetSamplesSince ¶
func (ac *Accumulator) GetSamplesSince(t time.Time) *SampleGroup
GetSamplesSince returns the last N samples from the accumulator in the specified time.
func (*Accumulator) Increment ¶
func (ac *Accumulator) Increment()
Increment increments the accumulator by 1.
func (*Accumulator) IncrementBy ¶
func (ac *Accumulator) IncrementBy(acc int64)
IncrementBy increments the accumulator by a specified number.
func (*Accumulator) Run ¶
func (ac *Accumulator) Run()
Run starts the accumulator which will process the accumulator and store it appropriately.
func (*Accumulator) RunOnce ¶
func (ac *Accumulator) RunOnce(t time.Time)
RunOnce allows you to manually call the accumulator task in the event you already have a task running every interval.
func (*Accumulator) Sum ¶
func (ac *Accumulator) Sum() int64
Sum returns the total number of increments the Accumulator has ever seen.
type SampleGroup ¶
SampleGroup holds a group of samples.
func (*SampleGroup) Avg ¶
func (sg *SampleGroup) Avg() float64
Avg returns the average of all samples in a samplegroup object.
func (*SampleGroup) Since ¶
func (sg *SampleGroup) Since(t time.Time) *SampleGroup
Since returns a samplegroup with all samples after a specified time.
func (*SampleGroup) Sum ¶
func (sg *SampleGroup) Sum() int64
Sum returns the sum of all samples in a samplegroup object.