MCPcopy
hub / github.com/prometheus/client_golang / CollectAndCount

Function CollectAndCount

prometheus/testutil/testutil.go:128–138  ·  view source on GitHub ↗

CollectAndCount registers the provided Collector with a newly created pedantic Registry. It then calls GatherAndCount with that Registry and with the provided metricNames. In the unlikely case that the registration or the gathering fails, this function panics. (This is inconsistent with the other Co

(c prometheus.Collector, metricNames ...string)

Source from the content-addressed store, hash-verified

126// the function signature would be a breaking change and will therefore only
127// happen with the next major version bump.)
128func CollectAndCount(c prometheus.Collector, metricNames ...string) int {
129 reg := prometheus.NewPedanticRegistry()
130 if err := reg.Register(c); err != nil {
131 panic(fmt.Errorf("registering collector failed: %w", err))
132 }
133 result, err := GatherAndCount(reg, metricNames...)
134 if err != nil {
135 panic(err)
136 }
137 return result
138}
139
140// GatherAndCount gathers all metrics from the provided Gatherer and counts
141// them. It returns the number of metric children in all gathered metric

Callers 1

TestCollectAndCountFunction · 0.85

Calls 3

NewPedanticRegistryFunction · 0.92
GatherAndCountFunction · 0.85
RegisterMethod · 0.65

Tested by 1

TestCollectAndCountFunction · 0.68