Documentation ¶
Index ¶
- Constants
- Variables
- func Alias(_ *Context, series ts.SeriesList, a string) (ts.SeriesList, error)
- func AliasByMetric(ctx *Context, series ts.SeriesList) (ts.SeriesList, error)
- func AliasByNode(_ *Context, seriesList ts.SeriesList, nodes ...int) (ts.SeriesList, error)
- func AliasSub(_ *Context, input ts.SeriesList, search, replace string) (ts.SeriesList, error)
- func Changed(ctx *Context, seriesList ts.SeriesList, renamer SeriesRenamer) (ts.SeriesList, error)
- func CompareOutputsAndExpected(t *testing.T, step int, start time.Time, expected []TestSeries, ...)
- func ConstantLine(ctx *Context, value float64) (*ts.Series, error)
- func ConstantSeries(ctx *Context, value float64) (*ts.Series, error)
- func Count(ctx *Context, seriesList ts.SeriesList, renamer SeriesListRenamer) (ts.SeriesList, error)
- func ErrInvalidPercentile(percentile float64) error
- func FetchWithBootstrap(ctx *Context, seriesList ts.SeriesList, duration time.Duration) (ts.SeriesList, error)
- func GetPercentile(input []float64, percentile float64, interpolate bool) float64
- func GreaterThan(v, threshold float64) bool
- func Head(series ts.SeriesList, n int) (ts.SeriesList, error)
- func Identity(ctx *Context, name string) (ts.SeriesList, error)
- func LessThan(v, threshold float64) bool
- func NPercentile(ctx *Context, in ts.SeriesList, percentile float64, pn PercentileNamer) (ts.SeriesList, error)
- func NewTestSeriesList(ctx *Context, start time.Time, inputs []TestSeries, step int) []*ts.Series
- func NewTestSeriesValues(ctx context.Context, millisPerStep int, values []float64) ts.Values
- func Normalize(ctx *Context, input ts.SeriesList) (ts.SeriesList, time.Time, time.Time, int, error)
- func ParseInterval(s string) (time.Duration, error)
- func PerSecond(ctx *Context, in ts.SeriesList, renamer SeriesRenamer) (ts.SeriesList, error)
- func Range(ctx *Context, series ts.SeriesList, renamer SeriesListRenamer) (*ts.Series, error)
- func RemoveByPercentile(ctx *Context, in ts.SeriesList, percentile float64, pn PercentileNamer, ...) (ts.SeriesList, error)
- func RemoveEmpty(ctx *Context, input ts.SeriesList) (ts.SeriesList, error)
- func SafeSort(input []float64) int
- func Stdev(ctx *Context, in ts.SeriesList, points int, windowTolerance float64, ...) (ts.SeriesList, error)
- func Transform(ctx *Context, in ts.SeriesList, t Transformer, renamer SeriesRenamer) (ts.SeriesList, error)
- type ChildContextOptions
- type Context
- func (c *Context) AddAsyncTasks(count int)
- func (c *Context) Close() error
- func (c *Context) DoneAsyncTask()
- func (c *Context) NewChildContext(opts ChildContextOptions) *Context
- func (c *Context) RegisterCloser(closer context.Closer)
- func (c *Context) RequestContext() ctx.Context
- func (c *Context) SetRequestContext(reqCtx ctx.Context)
- func (c *Context) TracingEnabled() bool
- type ContextOptions
- type Engine
- type MovingAverageStorage
- type PercentileNamer
- type PredicateFn
- type QueryEngine
- type RenamerWithNumPoints
- type SeriesListRenamer
- type SeriesRenamer
- type TestSeries
- type ThresholdComparator
- type TimeRangeAdjustment
- type Trace
- type TraceStats
- type Tracer
- type TransformFunc
- func Derivative() TransformFunc
- func Filter(fn PredicateFn) TransformFunc
- func Integral() TransformFunc
- func IsNonNull() TransformFunc
- func Logarithm() TransformFunc
- func MaintainNaNTransformer(f TransformFunc) TransformFunc
- func NonNegativeDerivative(maxValue float64) TransformFunc
- func Offset(factor float64) TransformFunc
- func Scale(scale float64) TransformFunc
- func TransformNull(value float64) TransformFunc
- type TransformFuncFactory
- type Transformer
Constants ¶
const ( // MillisPerSecond is for millis per second MillisPerSecond = 1000 // SecondsPerMinute is for seconds per minute SecondsPerMinute = 60 // MillisPerMinute is for milliseconds per minute MillisPerMinute = MillisPerSecond * SecondsPerMinute )
const (
// FloatingPointFormat is the floating point format for naming
FloatingPointFormat = "%.3f"
)
Variables ¶
var ( // ErrNegativeCount occurs when the request count is < 0. ErrNegativeCount = errors.NewInvalidParamsError(errors.New("n must be positive")) // ErrEmptySeriesList occurs when a function requires a series as input ErrEmptySeriesList = errors.NewInvalidParamsError(errors.New("empty series list")) // ErrInvalidIntervalFormat occurs when invalid interval string encountered ErrInvalidIntervalFormat = errors.NewInvalidParamsError(errors.New("invalid format")) )
Functions ¶
func Alias ¶
func Alias(_ *Context, series ts.SeriesList, a string) (ts.SeriesList, error)
Alias takes one metric or a wildcard seriesList and a string in quotes. Prints the string instead of the metric name in the legend.
func AliasByMetric ¶
func AliasByMetric(ctx *Context, series ts.SeriesList) (ts.SeriesList, error)
AliasByMetric takes a seriesList and applies an alias derived from the base metric name.
func AliasByNode ¶
func AliasByNode(_ *Context, seriesList ts.SeriesList, nodes ...int) (ts.SeriesList, error)
AliasByNode renames a time series result according to a subset of the nodes in its hierarchy.
func AliasSub ¶
func AliasSub(_ *Context, input ts.SeriesList, search, replace string) (ts.SeriesList, error)
AliasSub runs series names through a regex search/replace.
func Changed ¶
func Changed(ctx *Context, seriesList ts.SeriesList, renamer SeriesRenamer) (ts.SeriesList, error)
Changed will output a 1 if the value changed or 0 if not
func CompareOutputsAndExpected ¶
func CompareOutputsAndExpected(t *testing.T, step int, start time.Time, expected []TestSeries, actual []*ts.Series)
CompareOutputsAndExpected compares the actual output with the expected output.
func ConstantLine ¶
ConstantLine draws a horizontal line at a specified value
func ConstantSeries ¶
ConstantSeries returns a new constant series with a granularity of one data point per second
func Count ¶
func Count(ctx *Context, seriesList ts.SeriesList, renamer SeriesListRenamer) (ts.SeriesList, error)
Count draws a horizontal line representing the number of nodes found in the seriesList.
func ErrInvalidPercentile ¶
ErrInvalidPercentile is used when the percentile specified is incorrect
func FetchWithBootstrap ¶
func FetchWithBootstrap(ctx *Context, seriesList ts.SeriesList, duration time.Duration) (ts.SeriesList, error)
FetchWithBootstrap requests the same data but with a bootstrap period at the beginning.
func GetPercentile ¶
GetPercentile computes the percentile cut off for an array of floats
func GreaterThan ¶
GreaterThan is a ThresholdComparator function for when a value is greater than a threshold
func Head ¶
func Head(series ts.SeriesList, n int) (ts.SeriesList, error)
Head returns the first n elements of a series list or the entire list
func Identity ¶
func Identity(ctx *Context, name string) (ts.SeriesList, error)
Identity returns datapoints where the value equals the timestamp of the datapoint.
func LessThan ¶
LessThan is a ThresholdComparator function for when a value is less than a threshold
func NPercentile ¶
func NPercentile(ctx *Context, in ts.SeriesList, percentile float64, pn PercentileNamer) (ts.SeriesList, error)
NPercentile returns percentile-percent of each series in the seriesList.
func NewTestSeriesList ¶
NewTestSeriesList creates a test series and values from a set of inputs
func NewTestSeriesValues ¶
NewTestSeriesValues creates a new ts.Values with given step size and values.
func Normalize ¶
Normalize normalizes all input series to the same start time, step size, and end time.
func ParseInterval ¶
ParseInterval parses an interval string and returns the corresponding duration.
func PerSecond ¶
func PerSecond(ctx *Context, in ts.SeriesList, renamer SeriesRenamer) (ts.SeriesList, error)
PerSecond computes the derivative between consecutive values in the a time series, taking into account the time interval between the values. It skips missing values, and calculates the derivative between consecutive non-missing values.
func Range ¶
func Range(ctx *Context, series ts.SeriesList, renamer SeriesListRenamer) (*ts.Series, error)
Range distills down a set of inputs into the range of the series.
func RemoveByPercentile ¶
func RemoveByPercentile( ctx *Context, in ts.SeriesList, percentile float64, pn PercentileNamer, tc ThresholdComparator, ) (ts.SeriesList, error)
RemoveByPercentile removes all series above or below the given percentile, as determined by the PercentileComparator
func RemoveEmpty ¶
func RemoveEmpty(ctx *Context, input ts.SeriesList) (ts.SeriesList, error)
RemoveEmpty removes all series that have NaN data
func Stdev ¶
func Stdev(ctx *Context, in ts.SeriesList, points int, windowTolerance float64, renamer RenamerWithNumPoints) (ts.SeriesList, error)
Stdev takes one metric or a wildcard seriesList followed by an integer N. Draw the standard deviation of all metrics passed for the past N datapoints. If the ratio of null points in the window is greater than windowTolerance, skip the calculation.
func Transform ¶
func Transform(ctx *Context, in ts.SeriesList, t Transformer, renamer SeriesRenamer) (ts.SeriesList, error)
Transform applies a specified ValueTransform to all values in each series, renaming each series with the given SeriesRenamer.
Types ¶
type ChildContextOptions ¶
type ChildContextOptions struct {
// contains filtered or unexported fields
}
ChildContextOptions is a set of options to pass when creating a child context.
func NewChildContextOptions ¶
func NewChildContextOptions() ChildContextOptions
NewChildContextOptions returns an initialized ChildContextOptions struct.
func (*ChildContextOptions) AdjustTimeRange ¶
func (o *ChildContextOptions) AdjustTimeRange( shiftStart, shiftEnd, expandStart, expandEnd time.Duration, )
AdjustTimeRange will adjust the child context's time range.
type Context ¶
Context is the parameters to a query evaluation.
func NewConsolidationTestSeries ¶
func NewConsolidationTestSeries(start, end time.Time, duration time.Duration) (*Context, []*ts.Series)
NewConsolidationTestSeries returns multiple static series for consolidation
func NewContext ¶
func NewContext(options ContextOptions) *Context
NewContext creates a new context.
func (*Context) AddAsyncTasks ¶
AddAsyncTasks adds tracked asynchronous task(s)
func (*Context) DoneAsyncTask ¶
func (c *Context) DoneAsyncTask()
DoneAsyncTask marks a single tracked asynchronous task complete
func (*Context) NewChildContext ¶
func (c *Context) NewChildContext(opts ChildContextOptions) *Context
NewChildContext creates a child context. Child contexts can have any of their parameters modified, but share the same underlying storage context.
func (*Context) RegisterCloser ¶
RegisterCloser registers a new Closer with the context.
func (*Context) RequestContext ¶
RequestContext will provide the wrapped request context. Used for calls to m3 storage wrapper.
func (*Context) SetRequestContext ¶
SetRequestContext sets the given context as the request context for this execution context. This is used for calls to the m3 storage wrapper.
func (*Context) TracingEnabled ¶
TracingEnabled checks whether tracing is enabled for this context.
type ContextOptions ¶
type ContextOptions struct { Start time.Time End time.Time Engine QueryEngine Timeout time.Duration }
ContextOptions provides the options to create the context with
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
The Engine for running queries
type MovingAverageStorage ¶
type MovingAverageStorage struct { StepMillis int Bootstrap []float64 Values []float64 BootstrapStart time.Time }
MovingAverageStorage is a special test construct for the moving average function
func (*MovingAverageStorage) FetchByPath ¶
func (s *MovingAverageStorage) FetchByPath( ctx context.Context, path string, opts storage.FetchOptions, ) (*storage.FetchResult, error)
FetchByPath builds a new series from the input path
func (*MovingAverageStorage) FetchByQuery ¶
func (s *MovingAverageStorage) FetchByQuery( ctx context.Context, query string, opts storage.FetchOptions, ) (*storage.FetchResult, error)
FetchByQuery builds a new series from the input query
type PercentileNamer ¶
PercentileNamer formats a string with a percentile
type QueryEngine ¶
type QueryEngine interface { FetchByQuery( ctx context.Context, query string, start, end time.Time, timeout time.Duration, ) (*storage.FetchResult, error) }
QueryEngine is the generic engine interface.
type RenamerWithNumPoints ¶
RenamerWithNumPoints is a signature for renaming a single series that is passed to Stdev
type SeriesListRenamer ¶
type SeriesListRenamer func(series ts.SeriesList) string
SeriesListRenamer is a signature for renaming multiple series into a single name
type SeriesRenamer ¶
SeriesRenamer is a signature for renaming a single series
type TestSeries ¶
TestSeries is used to create a tsdb.timeSeries
type ThresholdComparator ¶
ThresholdComparator compares two floats for other comparison functions such as Percentile checks.
type TimeRangeAdjustment ¶
type TimeRangeAdjustment struct { OriginalStart time.Time OriginalEnd time.Time ShiftStart time.Duration ShiftEnd time.Duration ExpandStart time.Duration ExpandEnd time.Duration }
TimeRangeAdjustment is an applied time range adjustment.
type Trace ¶
type Trace struct { // ActivityName is the name of the activity being traced. ActivityName string // Duration is the amount of time it took to execute the activity. Duration time.Duration // Inputs are the number of timeseries processed by the trace. Inputs []TraceStats // Outputs is the number of timeseries returned by the trace. Outputs TraceStats }
A Trace is tracing information about a function or fetch within a query.
type TraceStats ¶
type TraceStats struct {
NumSeries int // number of timeseries being acted on
}
TraceStats tracks the number of timeseries used by a trace.
type TransformFunc ¶
TransformFunc is used by Transform to apply a function to all values in a series.
func Derivative ¶
func Derivative() TransformFunc
Derivative returns a function that computes the derivative among the values it has seen
func Filter ¶
func Filter(fn PredicateFn) TransformFunc
Filter removes data that does not satisfy a given predicate.
func Integral ¶
func Integral() TransformFunc
Integral returns a function that accumulates values it has seen
func IsNonNull ¶
func IsNonNull() TransformFunc
IsNonNull replaces datapoints that are non-null with 1, and null values with 0. This is useful for understanding which series have data at a given point in time (i.e. to count which servers are alive).
func Logarithm ¶
func Logarithm() TransformFunc
Logarithm takes one series or a series list, and draws the y-axis in logarithmic format. Only support base 10 logarithms.
func MaintainNaNTransformer ¶
func MaintainNaNTransformer(f TransformFunc) TransformFunc
MaintainNaNTransformer only applies a given ValueTransformer to non-NaN values.
func NonNegativeDerivative ¶
func NonNegativeDerivative(maxValue float64) TransformFunc
NonNegativeDerivative returns a function that computes the derivative among the values it has seen but ignores datapoints that trend down
func Offset ¶
func Offset(factor float64) TransformFunc
Offset adds a value to each element of a series list.
func Scale ¶
func Scale(scale float64) TransformFunc
Scale multiplies each element of a series list by a given value.
func TransformNull ¶
func TransformNull(value float64) TransformFunc
TransformNull transforms all nulls in a series to a value.
type TransformFuncFactory ¶
type TransformFuncFactory func() TransformFunc
TransformFuncFactory creates transformation functions
type Transformer ¶
type Transformer interface { // Apply applies the transformation Apply(value float64) float64 // Reset resets the state Reset() }
Transformer transforms a value
func NewStatelessTransformer ¶
func NewStatelessTransformer(fn TransformFunc) Transformer
NewStatelessTransformer creates a new stateless transformer