stats_tracker

package module
v0.0.0-...-23465b2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StatsTracker

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

StatsTracker Keeps track of simple stats over its lifetime and a configurable time range. StatsTracker 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 NewStatsTracker

func NewStatsTracker(timeFrame time.Duration, bucketSize time.Duration) *StatsTracker

NewStatsTracker Creates a new StatsTracker instance

func NewStatsTrackerWithTimeProvider

func NewStatsTrackerWithTimeProvider(timeFrame time.Duration, bucketSize time.Duration, timeProvider timeProvider) *StatsTracker

NewStatsTrackerWithTimeProvider Creates a new StatsTracker instance with a time provider closure (mostly for testing)

func (*StatsTracker) Add

func (s *StatsTracker) Add(value int64)

Add Records a new value to the stats tracker

func (*StatsTracker) AllTimeAvg

func (s *StatsTracker) AllTimeAvg() int64

AllTimeAvg Gets the all time average of values seen so far

func (*StatsTracker) AllTimePeak

func (s *StatsTracker) AllTimePeak() int64

AllTimePeak Gets the largest value seen so far

func (*StatsTracker) Info

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

func (*StatsTracker) InfoKey

func (s *StatsTracker) InfoKey() string

func (*StatsTracker) MovingAvg

func (s *StatsTracker) MovingAvg() int64

MovingAvg Gets the moving average of values within the time frame

func (*StatsTracker) MovingPeak

func (s *StatsTracker) 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