promtest

package module
v0.0.0-...-a7f2423 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Snapshot

type Snapshot struct {
	MetricMap map[string]*dto.MetricFamily
	// contains filtered or unexported fields
}

Snapshot provides methods for asserting on metrics

func (*Snapshot) AssertCount

func (s *Snapshot) AssertCount(name string, labels map[string]string, value float64)

AssertCount asserts existence and count of a counter in the snapshot.

func (*Snapshot) AssertGauge

func (s *Snapshot) AssertGauge(name string, labels map[string]string, value float64)

AssertGauge asserts existence and value of a gauge in the snapshot.

func (*Snapshot) AssertHistogram

func (s *Snapshot) AssertHistogram(name string, labels map[string]string, sum float64, count uint64)

AssertHistogram asserts that the existence and the sample sum and count of a histogram in the snapshot.

func (*Snapshot) AssertHistogramSampleCount

func (s *Snapshot) AssertHistogramSampleCount(name string, sampleCount uint64)

AssertHistogramSampleCount asserts that the histogram exists and contains exact number of samples

func (*Snapshot) AssertSummary

func (s *Snapshot) AssertSummary(name string, labels map[string]string, sum float64, count uint64)

AssertSummary asserts that the existence and the sample sum and count of a summary in the snapshot.

func (*Snapshot) AssertSummaryNonZero

func (s *Snapshot) AssertSummaryNonZero(name string, labels map[string]string)

AssertSummaryNonZero asserts that the summary exists and its value is non-zero

func (*Snapshot) GetMetric

func (s *Snapshot) GetMetric(metricType dto.MetricType, name string, labels map[string]string) *dto.Metric

GetMetric returns a matching metric from the snapshot

type TestRegistry

type TestRegistry struct {
	*prometheus.Registry
	// contains filtered or unexported fields
}

TestRegistry is a prometheus registry meant to be used for testing

func NewTestRegistry

func NewTestRegistry(t *testing.T) *TestRegistry

NewTestRegistry allocates and initializes a new TestRegistry

func (*TestRegistry) TakeSnapshot

func (r *TestRegistry) TakeSnapshot() (*Snapshot, error)

TakeSnapshot takes a snapshot of the current values of metrics for testing

Jump to

Keyboard shortcuts

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