teststat

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package teststat provides helpers for testing metrics backends.

Index

Constants

This section is empty.

Variables

View Source
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
)

Functions

func ExpectedObservationsLessThan added in v0.3.0

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 added in v0.6.0

func FillCounter(counter metrics.Counter) float64

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

func LastLine added in v0.3.0

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

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 added in v0.3.0

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 added in v0.3.0

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 added in v0.3.0

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 added in v0.3.0

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 added in v0.3.0

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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