v.io: v.io/x/ref/lib/stats/counter Index | Files

package counter

import "v.io/x/ref/lib/stats/counter"

Package counter implements counters that keeps track of their recent values over different periods of time. Example: c := counter.New() c.Incr(n) ... delta1h := c.Delta1h() delta10m := c.Delta10m() delta1m := c.Delta1m() and: rate1h := c.Rate1h() rate10m := c.Rate10m() rate1m := c.Rate1m()

Index

Package Files

counter.go timeseries.go tracker.go

Variables

var (
    // TimeNow is used for testing.
    TimeNow func() time.Time = time.Now
)

type Counter Uses

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

Counter is a counter that keeps track of its recent values over a given period of time, and with a given resolution. Use New() to instantiate.

func New Uses

func New() *Counter

New returns a new Counter.

func (*Counter) Delta10m Uses

func (c *Counter) Delta10m() int64

Delta10m returns the delta for the last 10 minutes.

func (*Counter) Delta1h Uses

func (c *Counter) Delta1h() int64

Delta1h returns the delta for the last hour.

func (*Counter) Delta1m Uses

func (c *Counter) Delta1m() int64

Delta1m returns the delta for the last minute.

func (*Counter) Incr Uses

func (c *Counter) Incr(delta int64)

Incr increments the current value of the counter by 'delta'.

func (*Counter) LastUpdate Uses

func (c *Counter) LastUpdate() time.Time

LastUpdate returns the last update time of the counter.

func (*Counter) Rate10m Uses

func (c *Counter) Rate10m() float64

Rate10m returns the rate of change of the counter in the last 10 minutes.

func (*Counter) Rate1h Uses

func (c *Counter) Rate1h() float64

Rate1h returns the rate of change of the counter in the last hour.

func (*Counter) Rate1m Uses

func (c *Counter) Rate1m() float64

Rate1m returns the rate of change of the counter in the last minute.

func (*Counter) Reset Uses

func (c *Counter) Reset()

Reset resets the counter to an empty state.

func (*Counter) Set Uses

func (c *Counter) Set(value int64)

Set updates the current value of the counter.

func (*Counter) TimeSeries10m Uses

func (c *Counter) TimeSeries10m() stats.TimeSeries

TimeSeries10m returns the time series data in the last 10 minutes.

func (*Counter) TimeSeries1h Uses

func (c *Counter) TimeSeries1h() stats.TimeSeries

TimeSeries1h returns the time series data in the last hour.

func (*Counter) TimeSeries1m Uses

func (c *Counter) TimeSeries1m() stats.TimeSeries

TimeSeries1m returns the time series data in the last minute.

func (*Counter) Value Uses

func (c *Counter) Value() int64

Value returns the current value of the counter.

type Tracker Uses

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

Tracker is a min/max value tracker that keeps track of its min/max values over a given period of time, and with a given resolution. The initial min and max values are math.MaxInt64 and math.MinInt64 respectively.

func NewTracker Uses

func NewTracker() *Tracker

NewTracker returns a new Tracker.

func (*Tracker) LastUpdate Uses

func (t *Tracker) LastUpdate() time.Time

LastUpdate returns the last update time of the range.

func (*Tracker) Max Uses

func (t *Tracker) Max() int64

Max returns the maximum value of the tracker.

func (*Tracker) Max10m Uses

func (t *Tracker) Max10m() int64

Max10m returns the maximum value for the last 10 minutes.

func (*Tracker) Max1h Uses

func (t *Tracker) Max1h() int64

Max1h returns the maximum value for the last hour.

func (*Tracker) Max1m Uses

func (t *Tracker) Max1m() int64

Max1m returns the maximum value for the last 1 minute.

func (*Tracker) Min Uses

func (t *Tracker) Min() int64

Min returns the minimum value of the tracker

func (*Tracker) Min10m Uses

func (t *Tracker) Min10m() int64

Min10m returns the minimum value for the last 10 minutes.

func (*Tracker) Min1h Uses

func (t *Tracker) Min1h() int64

Min1h returns the minimum value for the last hour.

func (*Tracker) Min1m Uses

func (t *Tracker) Min1m() int64

Min1m returns the minimum value for the last 1 minute.

func (*Tracker) Push Uses

func (t *Tracker) Push(value int64)

Push adds a new value if it is a new minimum or maximum.

func (*Tracker) Reset Uses

func (t *Tracker) Reset()

Reset resets the range to an empty state.

Package counter imports 4 packages (graph) and is imported by 22 packages. Updated 2020-06-09. Refresh now. Tools for package owners.