Version: v0.0.0-...-70f07a2 Latest Latest

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

Go to latest
Published: Mar 6, 2016 License: MIT Imports: 4 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Number

type Number struct {
	Buckets map[int64]*numberBucket
	Mutex   *sync.RWMutex

Number tracks a numberBucket over a bounded number of time buckets. Currently the buckets are one second long and only the last 10 seconds are kept.

func NewNumber

func NewNumber() *Number

NewNumber initializes a RollingNumber struct.

func (*Number) Avg

func (r *Number) Avg(now time.Time) float64

func (*Number) Increment

func (r *Number) Increment(i float64)

Increment increments the number in current timeBucket.

func (*Number) Max

func (r *Number) Max(now time.Time) float64

Max returns the maximum value seen in the last 10 seconds.

func (*Number) Sum

func (r *Number) Sum(now time.Time) float64

Sum sums the values over the buckets in the last 10 seconds.

func (*Number) UpdateMax

func (r *Number) UpdateMax(n float64)

UpdateMax updates the maximum value in the current bucket.

type Timing

type Timing struct {
	Buckets map[int64]*timingBucket
	Mutex   *sync.RWMutex

	CachedSortedDurations []time.Duration
	LastCachedTime        int64

Timing maintains time Durations for each time bucket. The Durations are kept in an array to allow for a variety of statistics to be calculated from the source data.

func NewTiming

func NewTiming() *Timing

NewTiming creates a RollingTiming struct.

func (*Timing) Add

func (r *Timing) Add(duration time.Duration)

Add appends the time.Duration given to the current time bucket.

func (*Timing) Mean

func (r *Timing) Mean() uint32

Mean computes the average timing in the last 60 seconds.

func (*Timing) Percentile

func (r *Timing) Percentile(p float64) uint32

Percentile computes the percentile given with a linear interpolation.

func (*Timing) SortedDurations

func (r *Timing) SortedDurations() []time.Duration

SortedDurations returns an array of time.Duration sorted from shortest to longest that have occurred in the last 60 seconds.

Jump to

Keyboard shortcuts

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