Last active
November 8, 2022 20:11
-
-
Save BetterProgramming/568c388f0ce082e85d13cdaf3c44e7b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c *baseGoCollector) Collect(ch chan<- Metric) { | |
ch <- MustNewConstMetric(c.goroutinesDesc, GaugeValue, float64(runtime.NumGoroutine())) | |
n := getRuntimeNumThreads() | |
ch <- MustNewConstMetric(c.threadsDesc, GaugeValue, n) | |
var stats debug.GCStats | |
stats.PauseQuantiles = make([]time.Duration, 5) | |
debug.ReadGCStats(&stats) | |
quantiles := make(map[float64]float64) | |
for idx, pq := range stats.PauseQuantiles[1:] { | |
quantiles[float64(idx+1)/float64(len(stats.PauseQuantiles)-1)] = pq.Seconds() | |
} | |
quantiles[0.0] = stats.PauseQuantiles[0].Seconds() | |
ch <- MustNewConstSummary(c.gcDesc, uint64(stats.NumGC), stats.PauseTotal.Seconds(), quantiles) | |
ch <- MustNewConstMetric(c.gcLastTimeDesc, GaugeValue, float64(stats.LastGC.UnixNano())/1e9) | |
ch <- MustNewConstMetric(c.goInfoDesc, GaugeValue, 1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment