statstracker

package module
v0.52.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package statstracker keeps track of simple stats in the Agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker Keeps track of simple stats over its lifetime and a configurable time range. Tracker is designed to be memory efficient by aggregating data into buckets. For example a time frame of 24 hours with a bucketFrame of 1 hour will ensure that only 24 points are ever kept in memory. New data is considered in the stats immediately while old data is removed by dropping expired aggregated buckets.

func NewTracker

func NewTracker(timeFrame time.Duration, bucketSize time.Duration) *Tracker

NewTracker Creates a new Tracker instance

func NewTrackerWithTimeProvider

func NewTrackerWithTimeProvider(timeFrame time.Duration, bucketSize time.Duration, timeProvider timeProvider) *Tracker

NewTrackerWithTimeProvider Creates a new Tracker instance with a time provider closure (mostly for testing)

func (*Tracker) Add

func (s *Tracker) Add(value int64)

Add Records a new value to the stats tracker

func (*Tracker) AllTimeAvg

func (s *Tracker) AllTimeAvg() int64

AllTimeAvg Gets the all time average of values seen so far

func (*Tracker) AllTimePeak

func (s *Tracker) AllTimePeak() int64

AllTimePeak Gets the largest value seen so far

func (*Tracker) Info

func (s *Tracker) Info() []string

Info returns the Tracker as a formatted string slice.

func (*Tracker) InfoKey

func (s *Tracker) InfoKey() string

InfoKey returns the key

func (*Tracker) MovingAvg

func (s *Tracker) MovingAvg() int64

MovingAvg Gets the moving average of values within the time frame

func (*Tracker) MovingPeak

func (s *Tracker) MovingPeak() int64

MovingPeak Gets the largest value seen within the time frame

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL