Collect returns the current state of all metrics of the collector.
(ch chan<- Metric)
| 242 | |
| 243 | // Collect returns the current state of all metrics of the collector. |
| 244 | func (c *baseGoCollector) Collect(ch chan<- Metric) { |
| 245 | ch <- MustNewConstMetric(c.goroutinesDesc, GaugeValue, float64(runtime.NumGoroutine())) |
| 246 | |
| 247 | n := getRuntimeNumThreads() |
| 248 | ch <- MustNewConstMetric(c.threadsDesc, GaugeValue, n) |
| 249 | |
| 250 | var stats debug.GCStats |
| 251 | stats.PauseQuantiles = make([]time.Duration, 5) |
| 252 | debug.ReadGCStats(&stats) |
| 253 | |
| 254 | quantiles := make(map[float64]float64) |
| 255 | for idx, pq := range stats.PauseQuantiles[1:] { |
| 256 | quantiles[float64(idx+1)/float64(len(stats.PauseQuantiles)-1)] = pq.Seconds() |
| 257 | } |
| 258 | quantiles[0.0] = stats.PauseQuantiles[0].Seconds() |
| 259 | ch <- MustNewConstSummary(c.gcDesc, uint64(stats.NumGC), stats.PauseTotal.Seconds(), quantiles) |
| 260 | ch <- MustNewConstMetric(c.gcLastTimeDesc, GaugeValue, float64(stats.LastGC.UnixNano())/1e9) |
| 261 | ch <- MustNewConstMetric(c.goInfoDesc, GaugeValue, 1) |
| 262 | } |
| 263 | |
| 264 | func memstatNamespace(s string) string { |
| 265 | return "go_memstats_" + s |
nothing calls this directly
no test coverage detected