kit: github.com/go-kit/kit/metrics/teststat Index | Files

package teststat

import "github.com/go-kit/kit/metrics/teststat"

Package teststat provides helpers for testing metrics backends.

Index

Package Files

buffers.go populate.go teststat.go

Variables

var (
    // Count is the number of observations.
    Count = 12345

    // Mean is the center of the normal distribution of observations.
    Mean = 500

    // Stdev of the normal distribution of observations.
    Stdev = 25
)

func ExpectedObservationsLessThan Uses

func ExpectedObservationsLessThan(bucket int64) int64

ExpectedObservationsLessThan returns the number of observations that should have a value less than or equal to the given value, given a normal distribution of observations described by Count, Mean, and Stdev.

func FillCounter Uses

func FillCounter(counter metrics.Counter) float64

FillCounter puts some deltas through the counter and returns the total value.

func LastLine Uses

func LastLine(w io.WriterTo, regex string) func() float64

LastLine expects a regex whose first capture group can be parsed as a float64. It will dump the WriterTo and parse each line, expecting to find a match. It returns the final captured float.

func PopulateNormalHistogram Uses

func PopulateNormalHistogram(h metrics.Histogram, seed int)

PopulateNormalHistogram makes a series of normal random observations into the histogram. The number of observations is determined by Count. The randomness is determined by Mean, Stdev, and the seed parameter.

This is a low-level function, exported only for metrics that don't perform dynamic quantile computation, like a Prometheus Histogram (c.f. Summary). In most cases, you don't need to use this function, and can use TestHistogram instead.

func Quantiles Uses

func Quantiles(w io.WriterTo, regex string, buckets int) func() (float64, float64, float64, float64)

Quantiles expects a regex whose first capture group can be parsed as a float64. It will dump the WriterTo and parse each line, expecting to find a match. It observes all captured floats into a generic.Histogram with the given number of buckets, and returns the 50th, 90th, 95th, and 99th quantiles from that histogram.

func SumLines Uses

func SumLines(w io.WriterTo, regex string) func() float64

SumLines expects a regex whose first capture group can be parsed as a float64. It will dump the WriterTo and parse each line, expecting to find a match. It returns the sum of all captured floats.

func TestCounter Uses

func TestCounter(counter metrics.Counter, value func() float64) error

TestCounter puts some deltas through the counter, and then calls the value func to check that the counter has the correct final value.

func TestGauge Uses

func TestGauge(gauge metrics.Gauge, value func() float64) error

TestGauge puts some values through the gauge, and then calls the value func to check that the gauge has the correct final value.

func TestHistogram Uses

func TestHistogram(histogram metrics.Histogram, quantiles func() (p50, p90, p95, p99 float64), tolerance float64) error

TestHistogram puts some observations through the histogram, and then calls the quantiles func to checks that the histogram has computed the correct quantiles within some tolerance

Package teststat imports 12 packages (graph). Updated 2017-07-04. Refresh now. Tools for package owners.