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)
| 126 | // the function signature would be a breaking change and will therefore only |
| 127 | // happen with the next major version bump.) |
| 128 | func 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 |