MCPcopy
hub / github.com/grpc/grpc-go / TestMetricRegistry

Method TestMetricRegistry

experimental/stats/metricregistry_test.go:68–170  ·  view source on GitHub ↗

TestInstrumentRegistry tests the metric registry. It registers testing only metrics using the metric registry, and creates a fake metrics recorder which uses these metrics. Using the handles returned from the metric registry, this test records stats using the fake metrics recorder. Then, the test ve

(t *testing.T)

Source from the content-addressed store, hash-verified

66// this tests the interactions between the metrics recorder and the metrics
67// registry.
68func (s) TestMetricRegistry(t *testing.T) {
69 cleanup := snapshotMetricsRegistryForTesting()
70 defer cleanup()
71
72 intCountHandle1 := RegisterInt64Count(MetricDescriptor{
73 Name: "simple counter",
74 Description: "sum of all emissions from tests",
75 Unit: "int",
76 Labels: []string{"int counter label"},
77 OptionalLabels: []string{"int counter optional label"},
78 Default: false,
79 })
80 floatCountHandle1 := RegisterFloat64Count(MetricDescriptor{
81 Name: "float counter",
82 Description: "sum of all emissions from tests",
83 Unit: "float",
84 Labels: []string{"float counter label"},
85 OptionalLabels: []string{"float counter optional label"},
86 Default: false,
87 })
88 intHistoHandle1 := RegisterInt64Histo(MetricDescriptor{
89 Name: "int histo",
90 Description: "sum of all emissions from tests",
91 Unit: "int",
92 Labels: []string{"int histo label"},
93 OptionalLabels: []string{"int histo optional label"},
94 Default: false,
95 })
96 floatHistoHandle1 := RegisterFloat64Histo(MetricDescriptor{
97 Name: "float histo",
98 Description: "sum of all emissions from tests",
99 Unit: "float",
100 Labels: []string{"float histo label"},
101 OptionalLabels: []string{"float histo optional label"},
102 Default: false,
103 })
104 intGaugeHandle1 := RegisterInt64Gauge(MetricDescriptor{
105 Name: "simple gauge",
106 Description: "the most recent int emitted by test",
107 Unit: "int",
108 Labels: []string{"int gauge label"},
109 OptionalLabels: []string{"int gauge optional label"},
110 Default: false,
111 })
112 intUpDownCountHandle1 := RegisterInt64UpDownCount(MetricDescriptor{
113 Name: "simple up down counter",
114 Description: "current number of emissions from tests",
115 Unit: "int",
116 Labels: []string{"int up down counter label"},
117 OptionalLabels: []string{"int up down counter optional label"},
118 Default: false,
119 })
120 intAsyncGaugeHandle1 := RegisterInt64AsyncGauge(MetricDescriptor{
121 Name: "simple async gauge",
122 Description: "the most recent int emitted by test",
123 Unit: "int",
124 Labels: []string{"int async gauge label"},
125 OptionalLabels: []string{"int async gauge optional label"},

Callers

nothing calls this directly

Calls 12

RegisterInt64CountFunction · 0.85
RegisterFloat64CountFunction · 0.85
RegisterInt64HistoFunction · 0.85
RegisterFloat64HistoFunction · 0.85
RegisterInt64GaugeFunction · 0.85
RegisterInt64UpDownCountFunction · 0.85
RegisterInt64AsyncGaugeFunction · 0.85
newFakeMetricsRecorderFunction · 0.85
DescriptorMethod · 0.65
FatalfMethod · 0.65
RecordMethod · 0.45

Tested by

no test coverage detected