stats
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
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)
- func (r *NoopMetricsRecorder) RecordInt64UpDownCount(*estats.Int64UpDownCountHandle, int64, ...string)
- type TestMetricsRecorder
- func (r *TestMetricsRecorder) ClearMetrics()
- func (r *TestMetricsRecorder) HandleConn(context.Context, stats.ConnStats)
- func (r *TestMetricsRecorder) HandleRPC(context.Context, stats.RPCStats)
- func (r *TestMetricsRecorder) Metric(name string) (float64, bool)
- 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) RecordInt64UpDownCount(handle *estats.Int64UpDownCountHandle, 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) error
- func (r *TestMetricsRecorder) WaitForFloat64Histo(ctx context.Context, metricsDataWant MetricsData) error
- func (r *TestMetricsRecorder) WaitForInt64Count(ctx context.Context, metricsDataWant MetricsData) error
- func (r *TestMetricsRecorder) WaitForInt64CountIncr(ctx context.Context, incrWant int64) error
- func (r *TestMetricsRecorder) WaitForInt64Gauge(ctx context.Context, metricsDataWant MetricsData) error
- func (r *TestMetricsRecorder) WaitForInt64Histo(ctx context.Context, metricsDataWant MetricsData) error
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeMetricsData¶
type MetricsData struct {Handle *estats.MetricDescriptor// Only set based on the type of metric. So only one of IntIncr or FloatIncr// is set.IntIncrint64FloatIncrfloat64LabelKeys []stringLabelVals []string}MetricsData represents data associated with a metric.
typeNoopMetricsRecorder¶
type NoopMetricsRecorder struct{}NoopMetricsRecorder is a noop MetricsRecorder to be used in tests to preventnil panics.
func (*NoopMetricsRecorder)RecordFloat64Count¶
func (r *NoopMetricsRecorder) RecordFloat64Count(*estats.Float64CountHandle,float64, ...string)
RecordFloat64Count is a noop implementation of RecordFloat64Count.
func (*NoopMetricsRecorder)RecordFloat64Histo¶
func (r *NoopMetricsRecorder) RecordFloat64Histo(*estats.Float64HistoHandle,float64, ...string)
RecordFloat64Histo is a noop implementation of RecordFloat64Histo.
func (*NoopMetricsRecorder)RecordInt64Count¶
func (r *NoopMetricsRecorder) RecordInt64Count(*estats.Int64CountHandle,int64, ...string)
RecordInt64Count is a noop implementation of RecordInt64Count.
func (*NoopMetricsRecorder)RecordInt64Gauge¶
func (r *NoopMetricsRecorder) RecordInt64Gauge(*estats.Int64GaugeHandle,int64, ...string)
RecordInt64Gauge is a noop implementation of RecordInt64Gauge.
func (*NoopMetricsRecorder)RecordInt64Histo¶
func (r *NoopMetricsRecorder) RecordInt64Histo(*estats.Int64HistoHandle,int64, ...string)
RecordInt64Histo is a noop implementation of RecordInt64Histo.
func (*NoopMetricsRecorder)RecordInt64UpDownCount¶added inv1.77.0
func (r *NoopMetricsRecorder) RecordInt64UpDownCount(*estats.Int64UpDownCountHandle,int64, ...string)
RecordInt64UpDownCount is a noop implementation of RecordInt64UpDownCount.
typeTestMetricsRecorder¶
type TestMetricsRecorder struct {// contains filtered or unexported fields}TestMetricsRecorder is a MetricsRecorder to be used in tests. It sendsrecording events on channels and provides helpers to check if certain eventshave taken place. It also persists metrics data keyed on the metricsdescriptor.
funcNewTestMetricsRecorder¶
func NewTestMetricsRecorder() *TestMetricsRecorder
NewTestMetricsRecorder returns a new TestMetricsRecorder.
func (*TestMetricsRecorder)ClearMetrics¶
func (r *TestMetricsRecorder) ClearMetrics()
ClearMetrics clears the metrics data store of the test metrics recorder.
func (*TestMetricsRecorder)HandleConn¶
func (r *TestMetricsRecorder) HandleConn(context.Context,stats.ConnStats)
HandleConn is TestMetricsRecorder's implementation of HandleConn.
func (*TestMetricsRecorder)HandleRPC¶
func (r *TestMetricsRecorder) HandleRPC(context.Context,stats.RPCStats)
HandleRPC is TestMetricsRecorder's implementation of HandleRPC.
func (*TestMetricsRecorder)Metric¶added inv1.68.0
func (r *TestMetricsRecorder) Metric(namestring) (float64,bool)
Metric returns the most recent data for a metric, and whether this recorderhas received data for a metric.
func (*TestMetricsRecorder)RecordFloat64Count¶
func (r *TestMetricsRecorder) RecordFloat64Count(handle *estats.Float64CountHandle, incrfloat64, labels ...string)
RecordFloat64Count sends the metrics data to the floatCountCh channel andupdates the internal data map with the recorded value.
func (*TestMetricsRecorder)RecordFloat64Histo¶
func (r *TestMetricsRecorder) RecordFloat64Histo(handle *estats.Float64HistoHandle, incrfloat64, labels ...string)
RecordFloat64Histo sends the metrics data to the floatHistoCh channel andupdates the internal data map with the recorded value.
func (*TestMetricsRecorder)RecordInt64Count¶
func (r *TestMetricsRecorder) RecordInt64Count(handle *estats.Int64CountHandle, incrint64, labels ...string)
RecordInt64Count sends the metrics data to the intCountCh channel and updatesthe internal data map with the recorded value.
func (*TestMetricsRecorder)RecordInt64Gauge¶
func (r *TestMetricsRecorder) RecordInt64Gauge(handle *estats.Int64GaugeHandle, incrint64, labels ...string)
RecordInt64Gauge sends the metrics data to the intGaugeCh channel and updatesthe internal data map with the recorded value.
func (*TestMetricsRecorder)RecordInt64Histo¶
func (r *TestMetricsRecorder) RecordInt64Histo(handle *estats.Int64HistoHandle, incrint64, labels ...string)
RecordInt64Histo sends the metrics data to the intHistoCh channel and updatesthe internal data map with the recorded value.
func (*TestMetricsRecorder)RecordInt64UpDownCount¶added inv1.77.0
func (r *TestMetricsRecorder) RecordInt64UpDownCount(handle *estats.Int64UpDownCountHandle, incrint64, labels ...string)
RecordInt64UpDownCount sends the metrics data to the intUpDownCountCh channel and updatesthe internal data map with the recorded value.
func (*TestMetricsRecorder)TagConn¶
func (r *TestMetricsRecorder) TagConn(ctxcontext.Context, _ *stats.ConnTagInfo)context.Context
TagConn is TestMetricsRecorder's implementation of TagConn.
func (*TestMetricsRecorder)TagRPC¶
func (r *TestMetricsRecorder) TagRPC(ctxcontext.Context, _ *stats.RPCTagInfo)context.Context
TagRPC is TestMetricsRecorder's implementation of TagRPC.
func (*TestMetricsRecorder)WaitForFloat64Count¶
func (r *TestMetricsRecorder) WaitForFloat64Count(ctxcontext.Context, metricsDataWantMetricsData)error
WaitForFloat64Count waits for a float count metric to be recorded andverifies that the recorded metrics data matches the expected metricsDataWant.Returns an error if failed to wait or received wrong data.
func (*TestMetricsRecorder)WaitForFloat64Histo¶
func (r *TestMetricsRecorder) WaitForFloat64Histo(ctxcontext.Context, metricsDataWantMetricsData)error
WaitForFloat64Histo waits for a float histo metric to be recorded andverifies that the recorded metrics data matches the expected metricsDataWant.Returns an error if failed to wait or received wrong data.
func (*TestMetricsRecorder)WaitForInt64Count¶
func (r *TestMetricsRecorder) WaitForInt64Count(ctxcontext.Context, metricsDataWantMetricsData)error
WaitForInt64Count waits for an int64 count metric to be recorded and verifiesthat the recorded metrics data matches the expected metricsDataWant. Returnsan error if failed to wait or received wrong data.
func (*TestMetricsRecorder)WaitForInt64CountIncr¶added inv1.69.0
func (r *TestMetricsRecorder) WaitForInt64CountIncr(ctxcontext.Context, incrWantint64)error
WaitForInt64CountIncr waits for an int64 count metric to be recorded andverifies that the recorded metrics data incr matches the expected incr.Returns an error if failed to wait or received wrong data.
func (*TestMetricsRecorder)WaitForInt64Gauge¶
func (r *TestMetricsRecorder) WaitForInt64Gauge(ctxcontext.Context, metricsDataWantMetricsData)error
WaitForInt64Gauge waits for a int gauge metric to be recorded and verifiesthat the recorded metrics data matches the expected metricsDataWant.
func (*TestMetricsRecorder)WaitForInt64Histo¶
func (r *TestMetricsRecorder) WaitForInt64Histo(ctxcontext.Context, metricsDataWantMetricsData)error
WaitForInt64Histo waits for an int histo metric to be recorded and verifiesthat the recorded metrics data matches the expected metricsDataWant. Returnsan error if failed to wait or received wrong data.