metricstest

package
v1.23.0-rc5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMetricNotFound      = errors.New("metric not found")
	ErrMetricTypeMismatch  = errors.New("metric is not the expected type")
	ErrMetricLabelMismatch = errors.New("metric labels do not match expected labels")
)

Potential errors that the test handler can return trying to find a metric to return.

Functions

This section is empty.

Types

type Capture added in v1.22.0

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

Capture is a specific capture instance.

func (*Capture) Snapshot added in v1.22.0

func (c *Capture) Snapshot() map[string][]*CapturedRecording

Snapshot returns a copy of all metrics recorded, keyed by name.

type CaptureHandler added in v1.22.0

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

CaptureHandler is a metrics.Handler that captures each metric recording.

func NewCaptureHandler added in v1.22.0

func NewCaptureHandler() *CaptureHandler

NewCaptureHandler creates a new metrics.Handler that captures.

func (*CaptureHandler) Counter added in v1.22.0

func (c *CaptureHandler) Counter(name string) metrics.CounterIface

Counter implements metrics.Handler.Counter.

func (*CaptureHandler) Gauge added in v1.22.0

func (c *CaptureHandler) Gauge(name string) metrics.GaugeIface

Gauge implements metrics.Handler.Gauge.

func (*CaptureHandler) Histogram added in v1.22.0

func (c *CaptureHandler) Histogram(name string, unit metrics.MetricUnit) metrics.HistogramIface

Histogram implements metrics.Handler.Histogram.

func (*CaptureHandler) StartCapture added in v1.22.0

func (c *CaptureHandler) StartCapture() *Capture

StartCapture returns a started capture. StopCapture should be called on complete.

func (*CaptureHandler) Stop added in v1.22.0

func (*CaptureHandler) Stop(log.Logger)

Stop implements metrics.Handler.Stop.

func (*CaptureHandler) StopCapture added in v1.22.0

func (c *CaptureHandler) StopCapture(capture *Capture)

StopCapture stops capturing metrics for the given capture instance.

func (*CaptureHandler) Timer added in v1.22.0

func (c *CaptureHandler) Timer(name string) metrics.TimerIface

Timer implements metrics.Handler.Timer.

func (*CaptureHandler) WithTags added in v1.22.0

func (c *CaptureHandler) WithTags(tags ...metrics.Tag) metrics.Handler

WithTags implements metrics.Handler.WithTags.

type CapturedRecording added in v1.22.0

type CapturedRecording struct {
	Value any
	Tags  map[string]string
	Unit  metrics.MetricUnit
}

CapturedRecording is a single recording. Fields here should not be mutated.

type Handler

type Handler struct {
	metrics.Handler
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(logger log.Logger, clientConfig metrics.ClientConfig) (*Handler, error)

func (*Handler) Snapshot

func (h *Handler) Snapshot() (Snapshot, error)

func (*Handler) Stop

func (*Handler) Stop(log.Logger)

type HistogramBucket added in v1.21.0

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

type Snapshot

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

func (Snapshot) Counter

func (s Snapshot) Counter(name string, tags ...metrics.Tag) (float64, error)

func (Snapshot) Gauge

func (s Snapshot) Gauge(name string, tags ...metrics.Tag) (float64, error)

func (Snapshot) Histogram added in v1.21.0

func (s Snapshot) Histogram(name string, tags ...metrics.Tag) ([]HistogramBucket, error)

func (Snapshot) String

func (s Snapshot) String() string

Jump to

Keyboard shortcuts

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