graphite

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: AGPL-3.0 Imports: 14 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestForLocalTesting added in v0.13.0

func RequestForLocalTesting(base, target, from string) *http.Request

func RequestForLocalTestingGraphite added in v0.13.0

func RequestForLocalTestingGraphite(target, from string) *http.Request

func RequestForLocalTestingGraphite8080 added in v0.13.0

func RequestForLocalTestingGraphite8080(target, from string) *http.Request

func RequestForLocalTestingMT added in v0.13.0

func RequestForLocalTestingMT(target, from string) *http.Request

Types

type CheckResults

type CheckResults struct {
	Validators []Validator
	Valid      []int // each position corresponds to a validator
	// categories of invalid responses
	Empty      int
	Timeout    int
	Other      int
	FirstOther *Response
}

final outcome of check results

func CheckMT

func CheckMT(endpoints []int, query, from string, dur time.Duration, reqs int, validators ...Validator) CheckResults

checkMT queries all provided MT endpoints and provides a summary of all the outcomes; meaning the counts of each response matching each validator function, and the number of timeouts, and finally all others (non-timeouting invalid responses) we recommend for 60s duration to use 6000 requests, e.g. 100 per second

type Comparator

type Comparator struct {
	Name string
	Fn   func(p float64) bool
}

func Eq

func Eq(good float64) Comparator

Eq returns a comparator that checks whether a float equals the given float

func Ge

func Ge(good float64) Comparator

Eq returns a comparator that checks whether a float is bigger or equal than the given float (or both are NaN)

type Data

type Data []Series

type Point

type Point struct {
	Val float64
	Ts  uint32
}

func (*Point) UnmarshalJSON

func (p *Point) UnmarshalJSON(data []byte) error

type Response

type Response struct {
	HTTPErr   error
	DecodeErr error
	Code      int
	TraceID   string
	Decoded   Data
	BodyErr   string // set if we could not decode json
}

Response is a convenience type: it provides original http and json decode errors, if applicable and also the decoded response body, if any

func ExecuteRenderQuery added in v0.13.0

func ExecuteRenderQuery(req *http.Request) Response

func Retry added in v0.13.0

func Retry(req *http.Request, times int, validate Validator) (Response, bool)

func (Response) StringWithoutData added in v0.13.0

func (r Response) StringWithoutData() string

type Series

type Series struct {
	Target     string
	Datapoints []Point
}

type Validator

type Validator struct {
	Name string
	Fn   func(resp Response) bool
}

func ValidateCode

func ValidateCode(code int) Validator

ValidaterCode returns a validator that validates whether the response has the given code

func ValidateCorrect

func ValidateCorrect(num float64) Validator

ValidateCorrect returns a validator with a min number, which will validate whether we received a "sufficiently correct" response. We assume the response corresponds to a sumSeries() query of multiple series, typically across shards across different instances. the number denotes the minimum accepted value. e.g. with 12, all points must equal 12 (i.e. for the use case of 12 series (1 for each shard, and each series valued at 1) all data from all shards is incorporated) to allow 4 shards being down and unaccounted for, pass 8. NOTE: 8 points are ignored (see comments further down) so you should only call this for sufficiently long series, e.g. 15 points or so.

func ValidateTargets

func ValidateTargets(targets []string) Validator

ValidateTargets returns a function that validates that the response contains exactly all named targets

func ValidatorAnd added in v0.13.0

func ValidatorAnd(vals ...Validator) Validator

ValidatorAnd returns a validator that returns whether all given validators return true it runs them in the order given and returns as soon as one fails.

func ValidatorAndExhaustive added in v0.13.0

func ValidatorAndExhaustive(vals ...Validator) Validator

ValidatorAndExhaustive returns a validator that returns whether all given validators return true it runs them in the order given, always runs all of them, and prints a log at each run showing the intermediate status

func ValidatorAvgWindowed

func ValidatorAvgWindowed(numPoints int, cmp Comparator) Validator

ValidatorAvgWindowed returns a validator that validates the number of series and the avg value of each series it is windowed to allow the dataset to include one or two values that would be evened out by a value just outside of the response. For example: response: NaN 4 4 4 5 3 4 4 4 5 clearly here we can trust that if the avg value should be 4, that there would be a 3 coming after the response but we don't want to wait for that. NOTE: ignores up to 2 points from each series, adjust your input size accordingly for desired confidence

func ValidatorLenNulls

func ValidatorLenNulls(prefix, l int) Validator

ValidatorLenNulls returns a validator that validates that any of the series contained within the response, has a length of l and no more than prefix nulls up front.

func (Validator) Equal added in v0.13.0

func (v1 Validator) Equal(v2 Validator) bool

Equal returns whether v1 equals v2 workaround for go-cmp which treats Validators unequal even if they have the same function pointer. not sure why

Jump to

Keyboard shortcuts

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