net: golang.org/x/net/internal/timeseries Index | Files

package timeseries

import "golang.org/x/net/internal/timeseries"

Package timeseries implements a time series structure for stats collection.

Index

Package Files

timeseries.go

type Clock Uses

type Clock interface {
    Time() time.Time
}

A Clock tells the current time.

type Float Uses

type Float float64

Float attaches the methods of Observable to a float64.

func (*Float) Add Uses

func (f *Float) Add(other Observable)

func (*Float) Clear Uses

func (f *Float) Clear()

func (*Float) CopyFrom Uses

func (f *Float) CopyFrom(other Observable)

func (*Float) Multiply Uses

func (f *Float) Multiply(ratio float64)

func (*Float) String Uses

func (f *Float) String() string

String returns the float as a string.

func (*Float) Value Uses

func (f *Float) Value() float64

Value returns the float's value.

type MinuteHourSeries Uses

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

MinuteHourSeries tracks data at granularities of 1 minute and 1 hour.

func NewMinuteHourSeries Uses

func NewMinuteHourSeries(f func() Observable) *MinuteHourSeries

NewMinuteHourSeries creates a new MinuteHourSeries using the function provided for creating new Observable.

func NewMinuteHourSeriesWithClock Uses

func NewMinuteHourSeriesWithClock(f func() Observable, clock Clock) *MinuteHourSeries

NewMinuteHourSeriesWithClock creates a new MinuteHourSeries using the function provided for creating new Observable and the clock for assigning timestamps.

func (*MinuteHourSeries) Add Uses

func (ts *MinuteHourSeries) Add(observation Observable)

Add records an observation at the current time.

func (*MinuteHourSeries) AddWithTime Uses

func (ts *MinuteHourSeries) AddWithTime(observation Observable, t time.Time)

AddWithTime records an observation at the specified time.

func (*MinuteHourSeries) Clear Uses

func (ts *MinuteHourSeries) Clear()

Clear removes all observations from the time series.

func (*MinuteHourSeries) ComputeRange Uses

func (ts *MinuteHourSeries) ComputeRange(start, finish time.Time, num int) []Observable

ComputeRange computes a specified number of values into a slice using the observations recorded over the specified time period. The return values are approximate if the start or finish times don't fall on the bucket boundaries at the same level or if the number of buckets spanning the range is not an integral multiple of num.

func (*MinuteHourSeries) Hour Uses

func (ts *MinuteHourSeries) Hour() Observable

func (*MinuteHourSeries) Latest Uses

func (ts *MinuteHourSeries) Latest(level, num int) Observable

Latest returns the sum of the num latest buckets from the level.

func (*MinuteHourSeries) LatestBuckets Uses

func (ts *MinuteHourSeries) LatestBuckets(level, num int) []Observable

LatestBuckets returns a copy of the num latest buckets from level.

func (*MinuteHourSeries) Minute Uses

func (ts *MinuteHourSeries) Minute() Observable

func (*MinuteHourSeries) Range Uses

func (ts *MinuteHourSeries) Range(start, finish time.Time) Observable

Range returns the sum of observations added over the specified time range. If start or finish times don't fall on bucket boundaries of the same level, then return values are approximate answers.

func (*MinuteHourSeries) Recent Uses

func (ts *MinuteHourSeries) Recent(delta time.Duration) Observable

Recent returns the sum of observations from the last delta.

func (*MinuteHourSeries) RecentList Uses

func (ts *MinuteHourSeries) RecentList(delta time.Duration, num int) []Observable

RecentList returns the specified number of values in slice over the most recent time period of the specified range.

func (*MinuteHourSeries) ScaleBy Uses

func (ts *MinuteHourSeries) ScaleBy(factor float64)

ScaleBy updates observations by scaling by factor.

func (*MinuteHourSeries) Total Uses

func (ts *MinuteHourSeries) Total() Observable

Total returns the total of all observations.

type Observable Uses

type Observable interface {
    Multiply(ratio float64)    // Multiplies the data in self by a given ratio
    Add(other Observable)      // Adds the data from a different observation to self
    Clear()                    // Clears the observation so it can be reused.
    CopyFrom(other Observable) // Copies the contents of a given observation to self
}

An Observable is a kind of data that can be aggregated in a time series.

func NewFloat Uses

func NewFloat() Observable

NewFloat returns a Float.

type TimeSeries Uses

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

TimeSeries tracks data at granularities from 1 second to 16 weeks.

func NewTimeSeries Uses

func NewTimeSeries(f func() Observable) *TimeSeries

NewTimeSeries creates a new TimeSeries using the function provided for creating new Observable.

func NewTimeSeriesWithClock Uses

func NewTimeSeriesWithClock(f func() Observable, clock Clock) *TimeSeries

NewTimeSeriesWithClock creates a new TimeSeries using the function provided for creating new Observable and the clock for assigning timestamps.

func (*TimeSeries) Add Uses

func (ts *TimeSeries) Add(observation Observable)

Add records an observation at the current time.

func (*TimeSeries) AddWithTime Uses

func (ts *TimeSeries) AddWithTime(observation Observable, t time.Time)

AddWithTime records an observation at the specified time.

func (*TimeSeries) Clear Uses

func (ts *TimeSeries) Clear()

Clear removes all observations from the time series.

func (*TimeSeries) ComputeRange Uses

func (ts *TimeSeries) ComputeRange(start, finish time.Time, num int) []Observable

ComputeRange computes a specified number of values into a slice using the observations recorded over the specified time period. The return values are approximate if the start or finish times don't fall on the bucket boundaries at the same level or if the number of buckets spanning the range is not an integral multiple of num.

func (*TimeSeries) Latest Uses

func (ts *TimeSeries) Latest(level, num int) Observable

Latest returns the sum of the num latest buckets from the level.

func (*TimeSeries) LatestBuckets Uses

func (ts *TimeSeries) LatestBuckets(level, num int) []Observable

LatestBuckets returns a copy of the num latest buckets from level.

func (*TimeSeries) Range Uses

func (ts *TimeSeries) Range(start, finish time.Time) Observable

Range returns the sum of observations added over the specified time range. If start or finish times don't fall on bucket boundaries of the same level, then return values are approximate answers.

func (*TimeSeries) Recent Uses

func (ts *TimeSeries) Recent(delta time.Duration) Observable

Recent returns the sum of observations from the last delta.

func (*TimeSeries) RecentList Uses

func (ts *TimeSeries) RecentList(delta time.Duration, num int) []Observable

RecentList returns the specified number of values in slice over the most recent time period of the specified range.

func (*TimeSeries) ScaleBy Uses

func (ts *TimeSeries) ScaleBy(factor float64)

ScaleBy updates observations by scaling by factor.

func (*TimeSeries) Total Uses

func (ts *TimeSeries) Total() Observable

Total returns the total of all observations.

Package timeseries imports 3 packages (graph) and is imported by 1 packages. Updated 2017-09-15. Refresh now. Tools for package owners.