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

Function NewGoCollector

prometheus/go_collector_go116.go:42–66  ·  view source on GitHub ↗

NewGoCollector is the obsolete version of collectors.NewGoCollector. See there for documentation. Deprecated: Use collectors.NewGoCollector instead.

()

Source from the content-addressed store, hash-verified

40//
41// Deprecated: Use collectors.NewGoCollector instead.
42func NewGoCollector() Collector {
43 msMetrics := goRuntimeMemStats()
44 msMetrics = append(msMetrics, struct {
45 desc *Desc
46 eval func(*runtime.MemStats) float64
47 valType ValueType
48 }{
49 // This metric is omitted in Go1.17+, see https://github.com/prometheus/client_golang/issues/842#issuecomment-861812034
50 desc: NewDesc(
51 memstatNamespace("gc_cpu_fraction"),
52 "The fraction of this program's available CPU time used by the GC since the program started.",
53 nil, nil,
54 ),
55 eval: func(ms *runtime.MemStats) float64 { return ms.GCCPUFraction },
56 valType: GaugeValue,
57 })
58 return &goCollector{
59 base: newBaseGoCollector(),
60 msLast: &runtime.MemStats{},
61 msRead: runtime.ReadMemStats,
62 msMaxWait: time.Second,
63 msMaxAge: 5 * time.Minute,
64 msMetrics: msMetrics,
65 }
66}
67
68// Describe returns all descriptions of the collector.
69func (c *goCollector) Describe(ch chan<- *Desc) {

Callers 7

TestGoCollectorGCFunction · 0.70
BenchmarkGoCollectorFunction · 0.70
collectGoMetricsFunction · 0.70
TestGoCollectorMemStatsFunction · 0.70
initFunction · 0.70

Calls 4

goRuntimeMemStatsFunction · 0.85
NewDescFunction · 0.85
memstatNamespaceFunction · 0.85
newBaseGoCollectorFunction · 0.85

Tested by 6

TestGoCollectorGCFunction · 0.56
BenchmarkGoCollectorFunction · 0.56
collectGoMetricsFunction · 0.56
TestGoCollectorMemStatsFunction · 0.56