Documentation ¶
Overview ¶
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 ¶
- Variables
- type Counter
- func (c *Counter) Delta10m() int64
- func (c *Counter) Delta1h() int64
- func (c *Counter) Delta1m() int64
- func (c *Counter) Incr(delta int64)
- func (c *Counter) LastUpdate() time.Time
- func (c *Counter) Rate10m() float64
- func (c *Counter) Rate1h() float64
- func (c *Counter) Rate1m() float64
- func (c *Counter) Reset()
- func (c *Counter) Set(value int64)
- func (c *Counter) TimeSeries10m() stats.TimeSeries
- func (c *Counter) TimeSeries1h() stats.TimeSeries
- func (c *Counter) TimeSeries1m() stats.TimeSeries
- func (c *Counter) Value() int64
- type Tracker
- func (t *Tracker) LastUpdate() time.Time
- func (t *Tracker) Max() int64
- func (t *Tracker) Max10m() int64
- func (t *Tracker) Max1h() int64
- func (t *Tracker) Max1m() int64
- func (t *Tracker) Min() int64
- func (t *Tracker) Min10m() int64
- func (t *Tracker) Min1h() int64
- func (t *Tracker) Min1m() int64
- func (t *Tracker) Push(value int64)
- func (t *Tracker) Reset()
Constants ¶
This section is empty.
Variables ¶
var ( // TimeNow is used for testing. TimeNow func() time.Time = time.Now )
Functions ¶
This section is empty.
Types ¶
type Counter ¶
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 (*Counter) LastUpdate ¶
LastUpdate returns the last update time of the counter.
func (*Counter) TimeSeries10m ¶
func (c *Counter) TimeSeries10m() stats.TimeSeries
TimeSeries10m returns the time series data in the last 10 minutes.
func (*Counter) TimeSeries1h ¶
func (c *Counter) TimeSeries1h() stats.TimeSeries
TimeSeries1h returns the time series data in the last hour.
func (*Counter) TimeSeries1m ¶
func (c *Counter) TimeSeries1m() stats.TimeSeries
TimeSeries1m returns the time series data in the last minute.
type Tracker ¶
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 (*Tracker) LastUpdate ¶
LastUpdate returns the last update time of the range.