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

Function ExampleGaugeFunc_simple

prometheus/examples_test.go:76–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74}
75
76func ExampleGaugeFunc_simple() {
77 if err := prometheus.Register(prometheus.NewGaugeFunc(
78 prometheus.GaugeOpts{
79 Subsystem: "runtime",
80 Name: "goroutines_count",
81 Help: "Number of goroutines that currently exist.",
82 },
83 func() float64 { return float64(runtime.NumGoroutine()) },
84 )); err == nil {
85 fmt.Println("GaugeFunc 'goroutines_count' registered.")
86 }
87 // Note that the count of goroutines is a gauge (and not a counter) as
88 // it can go up and down.
89
90 // Output:
91 // GaugeFunc 'goroutines_count' registered.
92}
93
94func ExampleGaugeFunc_constLabels() {
95 // primaryDB and secondaryDB represent two example *sql.DB connections we want to instrument.

Callers

nothing calls this directly

Calls 3

RegisterFunction · 0.92
NewGaugeFuncFunction · 0.92
PrintlnMethod · 0.65

Tested by

no test coverage detected