metricstest

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	TagsSep  string
	TagKVSep string
	// contains filtered or unexported fields
}

A Backend is a metrics provider which aggregates data in-vm, and allows exporting snapshots to shove the data into a remote collector

func NewBackend

func NewBackend(collectionInterval time.Duration) *Backend

NewBackend returns a new Backend. The collectionInterval is the histogram time window for each timer.

func (*Backend) Clear

func (b *Backend) Clear()

Clear discards accumulated stats

func (*Backend) IncCounter

func (b *Backend) IncCounter(name string, tags map[string]string, delta int64)

IncCounter increments a counter value

func (*Backend) RecordHistogram

func (b *Backend) RecordHistogram(name string, tags map[string]string, v float64)

RecordHistogram records a timing duration

func (*Backend) RecordTimer

func (b *Backend) RecordTimer(name string, tags map[string]string, d time.Duration)

RecordTimer records a timing duration

func (*Backend) Snapshot

func (b *Backend) Snapshot() (counters, gauges map[string]int64)

Snapshot captures a snapshot of the current counter and gauge values

func (*Backend) Stop

func (b *Backend) Stop()

Stop cleanly closes the background goroutine spawned by NewBackend.

func (*Backend) UpdateGauge

func (b *Backend) UpdateGauge(name string, tags map[string]string, value int64)

UpdateGauge updates the value of a gauge

type ExpectedMetric

type ExpectedMetric struct {
	Name  string
	Tags  map[string]string
	Value int
}

ExpectedMetric contains metrics under test.

type Factory

type Factory struct {
	*Backend
	// contains filtered or unexported fields
}

Factory stats factory that creates metrics that are stored locally

func NewFactory

func NewFactory(collectionInterval time.Duration) *Factory

NewFactory returns a new LocalMetricsFactory

func (*Factory) AssertCounterMetrics

func (f *Factory) AssertCounterMetrics(t *testing.T, expectedMetrics ...ExpectedMetric)

AssertCounterMetrics checks if counter metrics exist.

func (*Factory) AssertGaugeMetrics

func (f *Factory) AssertGaugeMetrics(t *testing.T, expectedMetrics ...ExpectedMetric)

AssertGaugeMetrics checks if gauge metrics exist.

func (*Factory) Counter

func (l *Factory) Counter(options metrics.Options) metrics.Counter

Counter returns a local stats counter

func (*Factory) Gauge

func (l *Factory) Gauge(options metrics.Options) metrics.Gauge

Gauge returns a local stats gauge.

func (*Factory) Histogram

func (l *Factory) Histogram(options metrics.HistogramOptions) metrics.Histogram

Histogram returns a local stats histogram.

func (*Factory) Namespace

func (l *Factory) Namespace(scope metrics.NSOptions) metrics.Factory

Namespace returns a new namespace.

func (*Factory) Timer

func (l *Factory) Timer(options metrics.TimerOptions) metrics.Timer

Timer returns a local stats timer.

Jump to

Keyboard shortcuts

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