teststatsd

package
v0.55.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package teststatsd provides a statsd client that maintains internal stats for unit testing various packages. It was pulled out of testutil to avoid a cyclic dependency with the `timing` package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	statsd.NoOpClient

	GaugeErr       error
	GaugeCalls     []MetricsArgs
	CountErr       error
	CountCalls     []MetricsArgs
	HistogramErr   error
	HistogramCalls []MetricsArgs
	TimingErr      error
	TimingCalls    []MetricsArgs
	// contains filtered or unexported fields
}

Client is a mocked StatsClient that records all calls and replies with configurable error return values. Don't create this Client directly. Instead, use the constructor provided through `testutil.WithStatsClient`.

func (*Client) Count

func (c *Client) Count(name string, value int64, tags []string, rate float64) error

Count records a call to a Count operation and replies with CountErr

func (*Client) Flush

func (c *Client) Flush() error

Flush implements metrics.StatsClient

func (*Client) Gauge

func (c *Client) Gauge(name string, value float64, tags []string, rate float64) error

Gauge records a call to a Gauge operation and replies with GaugeErr

func (*Client) GetCountSummaries

func (c *Client) GetCountSummaries() map[string]*CountSummary

GetCountSummaries computes summaries for all names supplied as parameters to Count calls.

func (*Client) GetGaugeSummaries

func (c *Client) GetGaugeSummaries() map[string]*GaugeSummary

GetGaugeSummaries computes summaries for all names supplied as parameters to Gauge calls.

func (*Client) Histogram

func (c *Client) Histogram(name string, value float64, tags []string, rate float64) error

Histogram records a call to a Histogram operation and replies with HistogramErr

func (*Client) Reset

func (c *Client) Reset()

Reset resets client's internal records.

func (*Client) Timing

func (c *Client) Timing(name string, value time.Duration, tags []string, rate float64) error

Timing records a call to a Timing operation.

type CountSummary

type CountSummary struct {
	Calls []MetricsArgs
	Sum   int64
}

CountSummary contains a summary of all Count method calls to a particular StatsClient for a particular key.

type GaugeSummary

type GaugeSummary struct {
	Calls []MetricsArgs
	Last  float64
	Max   float64
}

GaugeSummary contains a summary of all Gauge method calls to a particular StatsClient for a particular key.

type MetricsArgs

type MetricsArgs struct {
	Name  string
	Value float64
	Tags  []string
	Rate  float64
}

MetricsArgs represents arguments to a StatsClient Gauge method call.

Jump to

Keyboard shortcuts

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