32 lines
702 B
Go
32 lines
702 B
Go
package prometheus
|
|
|
|
import (
|
|
"runtime"
|
|
)
|
|
|
|
type goCollector struct {
|
|
goroutines Gauge
|
|
}
|
|
|
|
// NewGoCollector returns a collector which exports metrics about the current
|
|
// go process.
|
|
func NewGoCollector() *goCollector {
|
|
return &goCollector{
|
|
goroutines: NewGauge(GaugeOpts{
|
|
Name: "process_goroutines",
|
|
Help: "Number of goroutines that currently exist.",
|
|
}),
|
|
}
|
|
}
|
|
|
|
// Describe returns all descriptions of the collector.
|
|
func (c *goCollector) Describe(ch chan<- *Desc) {
|
|
ch <- c.goroutines.Desc()
|
|
}
|
|
|
|
// Collect returns the current state of all metrics of the collector.
|
|
func (c *goCollector) Collect(ch chan<- Metric) {
|
|
c.goroutines.Set(float64(runtime.NumGoroutine()))
|
|
ch <- c.goroutines
|
|
}
|