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

Method TestUpDownCounts

experimental/stats/metricregistry_test.go:172–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170}
171
172func (s) TestUpDownCounts(t *testing.T) {
173 cleanup := snapshotMetricsRegistryForTesting()
174 defer cleanup()
175
176 intUpDownCountHandle1 := RegisterInt64UpDownCount(MetricDescriptor{
177 Name: "simple up down counter",
178 Description: "current number of emissions from tests",
179 Unit: "int",
180 Labels: []string{"int up down counter label"},
181 OptionalLabels: []string{"int up down counter optional label"},
182 Default: false,
183 })
184
185 fmr := newFakeMetricsRecorder(t)
186 intUpDownCountHandle1.Record(fmr, 2, []string{"up down value", "some optional label value"}...)
187 intUpDownCountHandle1.Record(fmr, -1, []string{"up down value", "some optional label value"}...)
188
189 if got := fmr.intValues[intUpDownCountHandle1.Descriptor()]; got != 1 {
190 t.Fatalf("fmr.intValues[intUpDownCountHandle1.MetricDescriptor] got %v, want: %v", got, 1)
191 }
192}
193
194// TestNumerousIntCounts tests numerous int count metrics registered onto the
195// metric registry. A component (simulated by test) should be able to record on

Callers

nothing calls this directly

Calls 6

RegisterInt64UpDownCountFunction · 0.85
newFakeMetricsRecorderFunction · 0.85
DescriptorMethod · 0.65
FatalfMethod · 0.65
RecordMethod · 0.45

Tested by

no test coverage detected