stats

package
v1.66.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package stats implements a TestMetricsRecorder utility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricsData

type MetricsData struct {
	Handle *estats.MetricDescriptor

	// Only set based on the type of metric. So only one of IntIncr or FloatIncr
	// is set.
	IntIncr   int64
	FloatIncr float64

	LabelKeys []string
	LabelVals []string
}

type NoopMetricsRecorder

type NoopMetricsRecorder struct{}

NoopMetricsRecorder is a noop MetricsRecorder to be used in tests to prevent nil panics.

func (*NoopMetricsRecorder) RecordFloat64Count

func (r *NoopMetricsRecorder) RecordFloat64Count(*estats.Float64CountHandle, float64, ...string)

func (*NoopMetricsRecorder) RecordFloat64Histo

func (r *NoopMetricsRecorder) RecordFloat64Histo(*estats.Float64HistoHandle, float64, ...string)

func (*NoopMetricsRecorder) RecordInt64Count

func (r *NoopMetricsRecorder) RecordInt64Count(*estats.Int64CountHandle, int64, ...string)

func (*NoopMetricsRecorder) RecordInt64Gauge

func (r *NoopMetricsRecorder) RecordInt64Gauge(*estats.Int64GaugeHandle, int64, ...string)

func (*NoopMetricsRecorder) RecordInt64Histo

func (r *NoopMetricsRecorder) RecordInt64Histo(*estats.Int64HistoHandle, int64, ...string)

type TestMetricsRecorder

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

TestMetricsRecorder is a MetricsRecorder to be used in tests. It sends recording events on channels and provides helpers to check if certain events have taken place. It also persists metrics data keyed on the metrics descriptor.

func NewTestMetricsRecorder

func NewTestMetricsRecorder(t *testing.T) *TestMetricsRecorder

func (*TestMetricsRecorder) AssertDataForMetric

func (r *TestMetricsRecorder) AssertDataForMetric(metricName string, wantVal float64)

AssertDataForMetric asserts data is present for metric. The zero value in the check is equivalent to unset.

func (*TestMetricsRecorder) ClearMetrics

func (r *TestMetricsRecorder) ClearMetrics()

ClearMetrics clears the metrics data stores of the test metrics recorder by setting all the data to 0.

func (*TestMetricsRecorder) HandleConn

func (*TestMetricsRecorder) HandleRPC

func (*TestMetricsRecorder) PollForDataForMetric

func (r *TestMetricsRecorder) PollForDataForMetric(ctx context.Context, metricName string, wantVal float64)

PollForDataForMetric polls the metric data for the want. Fails if context provided expires before data for metric is found.

func (*TestMetricsRecorder) RecordFloat64Count

func (r *TestMetricsRecorder) RecordFloat64Count(handle *estats.Float64CountHandle, incr float64, labels ...string)

func (*TestMetricsRecorder) RecordFloat64Histo

func (r *TestMetricsRecorder) RecordFloat64Histo(handle *estats.Float64HistoHandle, incr float64, labels ...string)

func (*TestMetricsRecorder) RecordInt64Count

func (r *TestMetricsRecorder) RecordInt64Count(handle *estats.Int64CountHandle, incr int64, labels ...string)

func (*TestMetricsRecorder) RecordInt64Gauge

func (r *TestMetricsRecorder) RecordInt64Gauge(handle *estats.Int64GaugeHandle, incr int64, labels ...string)

func (*TestMetricsRecorder) RecordInt64Histo

func (r *TestMetricsRecorder) RecordInt64Histo(handle *estats.Int64HistoHandle, incr int64, labels ...string)

func (*TestMetricsRecorder) TagConn

func (*TestMetricsRecorder) TagRPC

func (*TestMetricsRecorder) WaitForFloat64Count

func (r *TestMetricsRecorder) WaitForFloat64Count(ctx context.Context, metricsDataWant MetricsData)

func (*TestMetricsRecorder) WaitForFloat64Histo

func (r *TestMetricsRecorder) WaitForFloat64Histo(ctx context.Context, metricsDataWant MetricsData)

func (*TestMetricsRecorder) WaitForInt64Count

func (r *TestMetricsRecorder) WaitForInt64Count(ctx context.Context, metricsDataWant MetricsData)

func (*TestMetricsRecorder) WaitForInt64Gauge

func (r *TestMetricsRecorder) WaitForInt64Gauge(ctx context.Context, metricsDataWant MetricsData)

func (*TestMetricsRecorder) WaitForInt64Histo

func (r *TestMetricsRecorder) WaitForInt64Histo(ctx context.Context, metricsDataWant MetricsData)

Jump to

Keyboard shortcuts

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