MCPcopy
hub / github.com/IBM/sarama / TestGetOrRegisterHistogram

Function TestGetOrRegisterHistogram

metrics_test.go:11–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestGetOrRegisterHistogram(t *testing.T) {
12 metricRegistry := metrics.NewRegistry()
13 histogram := getOrRegisterHistogram("name", metricRegistry)
14
15 if histogram == nil {
16 t.Error("Unexpected nil histogram")
17 }
18
19 // Fetch the metric
20 foundHistogram := metricRegistry.Get("name")
21
22 if foundHistogram != histogram {
23 t.Error("Unexpected different histogram", foundHistogram, histogram)
24 }
25
26 // Try to register the metric again
27 sameHistogram := getOrRegisterHistogram("name", metricRegistry)
28
29 if sameHistogram != histogram {
30 t.Error("Unexpected different histogram", sameHistogram, histogram)
31 }
32}
33
34func TestGetMetricNameForBroker(t *testing.T) {
35 metricName := getMetricNameForBroker("name", &Broker{id: 1})

Callers

nothing calls this directly

Calls 3

getOrRegisterHistogramFunction · 0.85
ErrorMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected