testmetrics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package testmetrics is for testing provider metrics with a test Provider that adheres to the Provider interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CardinalityCounter added in v0.0.62

type CardinalityCounter struct {
	Name string

	sync.RWMutex
	// contains filtered or unexported fields
}

CardinalityCounter provides a wrapper around a HyperLogLog probabalistic counter. It implements CardinalityCounter Interface.

func (*CardinalityCounter) Estimate added in v0.0.62

func (c *CardinalityCounter) Estimate() uint64

func (*CardinalityCounter) Insert added in v0.0.62

func (c *CardinalityCounter) Insert(i []byte)

Insert adds the item to the set to be counted.

func (*CardinalityCounter) With added in v0.0.62

func (c *CardinalityCounter) With(labelValues ...string) xmetrics.CardinalityCounter

With implements xmetrics.CardinalityCounter interface. It returns a CardinalityCounter based on the labelValues.

type Counter

type Counter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Counter accumulates a value based on Add calls.

func (*Counter) Add

func (c *Counter) Add(delta float64)

Add implements the metrics.Counter interface.

func (*Counter) With

func (c *Counter) With(labelValues ...string) metrics.Counter

With implements the metrics.Counter interface.

type Gauge

type Gauge struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Gauge stores a value based on Add/Set calls.

func (*Gauge) Add

func (g *Gauge) Add(delta float64)

Add implements the metrics.Gauge interface.

func (*Gauge) Set

func (g *Gauge) Set(v float64)

Set implements the metrics.Gauge interface.

func (*Gauge) With

func (g *Gauge) With(labelValues ...string) metrics.Gauge

With implements the metrics.Gauge interface.

type Histogram

type Histogram struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Histogram collects observations without computing quantiles so the observations can be checked by tests.

func (*Histogram) Observe

func (h *Histogram) Observe(v float64)

Observe implements the metrics.Histogram interface.

func (*Histogram) With

func (h *Histogram) With(labelValues ...string) metrics.Histogram

With implements the metrics.Histogram interface.

type Provider

type Provider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Provider collects registered metrics for testing.

func NewProvider

func NewProvider(t *testing.T) *Provider

NewProvider constructs a test provider which can later be checked.

func (*Provider) CheckCardinalityCounter

func (p *Provider) CheckCardinalityCounter(name string, estimate uint64, labelValues ...string)

CheckCardinalityCounter checks that there is a registered cardinality counter with the name and estimate provided.

func (*Provider) CheckCounter

func (p *Provider) CheckCounter(name string, v float64, labelValues ...string)

CheckCounter checks that there is a registered counter with the name and value provided.

func (*Provider) CheckCounterExists added in v0.2.7

func (p *Provider) CheckCounterExists(name string, labelValues ...string)

CheckCounterExists checks that there is registered counter with the name provided and value is not 0.

func (*Provider) CheckGauge

func (p *Provider) CheckGauge(name string, v float64, labelValues ...string)

CheckGauge checks that there is a registered gauge with the name and value provided.

func (*Provider) CheckGaugeNonZero

func (p *Provider) CheckGaugeNonZero(name string, labelValues ...string)

CheckGaugeNonZero checks that there is a registered gauge with the name provided whose value is != 0.

func (*Provider) CheckNoCounter

func (p *Provider) CheckNoCounter(name string, labelValues ...string)

CheckNoCounter checks that there is no registered counter with the name provided.

func (*Provider) CheckNoGauge

func (p *Provider) CheckNoGauge(name string, labelValues ...string)

CheckNoGauge checks that there is no registered gauge with the name provided.

func (*Provider) CheckObservationCount

func (p *Provider) CheckObservationCount(name string, n int, labelValues ...string)

CheckObservationCount checks that there is a histogram with the name and number of observations provided.

func (*Provider) CheckObservations

func (p *Provider) CheckObservations(name string, obs []float64, labelValues ...string)

CheckObservations checks that there is a histogram with the name and observations provided.

func (*Provider) CheckObservationsMatch

func (p *Provider) CheckObservationsMatch(name string, obs []float64, labelValues ...string)

CheckObservationsMatch checks that there is a histogram with the name and observations provided, ignoring order.

func (*Provider) CheckObservationsMinMax

func (p *Provider) CheckObservationsMinMax(name string, min, max float64, labelValues ...string)

CheckObservationsMinMax checks that there is a histogram with the name and that the values all fall within the min/max range.

func (*Provider) CheckStopped

func (p *Provider) CheckStopped()

CheckStopped verifies that a provider has been Stop'd.

func (*Provider) Flush added in v0.0.41

func (p *Provider) Flush() error

Flush makes it Provider compliant.

func (*Provider) NewCardinalityCounter

func (p *Provider) NewCardinalityCounter(name string) xmetrics.CardinalityCounter

NewCardinalityCounter implements metrics.Provider.

func (*Provider) NewCounter

func (p *Provider) NewCounter(name string) metrics.Counter

NewCounter implements go-kit's Provider interface.

func (*Provider) NewExplicitHistogram added in v0.0.48

func (p *Provider) NewExplicitHistogram(name string, _ xmetrics.DistributionFunc) metrics.Histogram

NewExplicitHistogram implements go-kit's Provider interface.

func (*Provider) NewGauge

func (p *Provider) NewGauge(name string) metrics.Gauge

NewGauge implements go-kit's Provider interface.

func (*Provider) NewHistogram

func (p *Provider) NewHistogram(name string, _ int) metrics.Histogram

NewHistogram implements go-kit's Provider interface.

func (*Provider) PrintCounterValue added in v0.0.10

func (p *Provider) PrintCounterValue(name string)

PrintCounterValue prints the value of the specified counter and their current counts

func (*Provider) Stop

func (p *Provider) Stop()

Stop makes it Provider compliant.

Jump to

Keyboard shortcuts

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