package testonly

import "github.com/google/trillian/monitoring/testonly"

Package testonly contains test-only code.

Index

Functions

func TestCounter

func TestCounter(t *testing.T, factory monitoring.MetricFactory)

TestCounter runs a test on a Counter produced from the provided MetricFactory.

func TestGauge

func TestGauge(t *testing.T, factory monitoring.MetricFactory)

TestGauge runs a test on a Gauge produced from the provided MetricFactory.

func TestHistogram

func TestHistogram(t *testing.T, factory monitoring.MetricFactory)

TestHistogram runs a test on a Histogram produced from the provided MetricFactory.

Types

type CounterSnapshot

type CounterSnapshot struct {
	// contains filtered or unexported fields
}

CounterSnapshot records the latest value from a time series in a counter. This value can then be compared with future values. Note that a counter can contain many time series, but a CounterSnapshot will track only one. A CounterSnapshot is useful in tests because counters do not reset between test cases, and so their absolute value is not amenable to testing. Instead, the delta between the value at the start and end of the test should be used. This assumes that multiple tests that all affect the counter are not run in parallel.

func NewCounterSnapshot

func NewCounterSnapshot(c monitoring.Counter, labels ...string) CounterSnapshot

NewCounterSnapshot records the latest value of a time series in c identified by the given labels. This value can be compared to future values to determine how it has changed over time.

func (CounterSnapshot) Delta

func (s CounterSnapshot) Delta() float64

Delta returns the difference between the latest value of the time series and the value when the CounterSnapshot was created.

Source Files

delta.go doc.go metrics.go

Version
v1.7.1 (latest)
Published
Jan 9, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
5 days ago

Tools for package owners.