Movatterモバイル変換


[0]ホーム

URL:


stats

package
v1.77.0Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License:Apache-2.0Imports:7Imported by:0

Details

Repository

github.com/grpc/grpc-go

Links

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

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)RecordInt64UpDownCountadded 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

HandleConn is TestMetricsRecorder's implementation of HandleConn.

func (*TestMetricsRecorder)HandleRPC

HandleRPC is TestMetricsRecorder's implementation of HandleRPC.

func (*TestMetricsRecorder)Metricadded 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)RecordInt64UpDownCountadded 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

TagConn is TestMetricsRecorder's implementation of TagConn.

func (*TestMetricsRecorder)TagRPC

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)WaitForInt64CountIncradded 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.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp