Documentation ¶
Overview ¶
Package stats implements a TestMetricsRecorder utility.
Index ¶
- type MetricsData
- type NoopMetricsRecorder
- func (r *NoopMetricsRecorder) RecordFloat64Count(*estats.Float64CountHandle, float64, ...string)
- func (r *NoopMetricsRecorder) RecordFloat64Histo(*estats.Float64HistoHandle, float64, ...string)
- func (r *NoopMetricsRecorder) RecordInt64Count(*estats.Int64CountHandle, int64, ...string)
- func (r *NoopMetricsRecorder) RecordInt64Gauge(*estats.Int64GaugeHandle, int64, ...string)
- func (r *NoopMetricsRecorder) RecordInt64Histo(*estats.Int64HistoHandle, int64, ...string)
- type TestMetricsRecorder
- func (r *TestMetricsRecorder) AssertDataForMetric(metricName string, wantVal float64)
- func (r *TestMetricsRecorder) ClearMetrics()
- func (r *TestMetricsRecorder) HandleConn(context.Context, stats.ConnStats)
- func (r *TestMetricsRecorder) HandleRPC(context.Context, stats.RPCStats)
- func (r *TestMetricsRecorder) PollForDataForMetric(ctx context.Context, metricName string, wantVal float64)
- func (r *TestMetricsRecorder) RecordFloat64Count(handle *estats.Float64CountHandle, incr float64, labels ...string)
- func (r *TestMetricsRecorder) RecordFloat64Histo(handle *estats.Float64HistoHandle, incr float64, labels ...string)
- func (r *TestMetricsRecorder) RecordInt64Count(handle *estats.Int64CountHandle, incr int64, labels ...string)
- func (r *TestMetricsRecorder) RecordInt64Gauge(handle *estats.Int64GaugeHandle, incr int64, labels ...string)
- func (r *TestMetricsRecorder) RecordInt64Histo(handle *estats.Int64HistoHandle, incr int64, labels ...string)
- func (r *TestMetricsRecorder) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context
- func (r *TestMetricsRecorder) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context
- func (r *TestMetricsRecorder) WaitForFloat64Count(ctx context.Context, metricsDataWant MetricsData)
- func (r *TestMetricsRecorder) WaitForFloat64Histo(ctx context.Context, metricsDataWant MetricsData)
- func (r *TestMetricsRecorder) WaitForInt64Count(ctx context.Context, metricsDataWant MetricsData)
- func (r *TestMetricsRecorder) WaitForInt64Gauge(ctx context.Context, metricsDataWant MetricsData)
- func (r *TestMetricsRecorder) WaitForInt64Histo(ctx context.Context, metricsDataWant MetricsData)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricsData ¶
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 (r *TestMetricsRecorder) HandleConn(context.Context, stats.ConnStats)
func (*TestMetricsRecorder) HandleRPC ¶
func (r *TestMetricsRecorder) HandleRPC(context.Context, stats.RPCStats)
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 (r *TestMetricsRecorder) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context
func (*TestMetricsRecorder) TagRPC ¶
func (r *TestMetricsRecorder) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context
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)