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

Function NewGaugeFunc

prometheus/gauge.go:304–311  ·  view source on GitHub ↗

NewGaugeFunc creates a new GaugeFunc based on the provided GaugeOpts. The value reported is determined by calling the given function from within the Write method. Take into account that metric collection may happen concurrently. Therefore, it must be safe to call the provided function concurrently.

(opts GaugeOpts, function func() float64)

Source from the content-addressed store, hash-verified

302// value of 1. Example:
303// https://github.com/prometheus/common/blob/8558a5b7db3c84fa38b4766966059a7bd5bfa2ee/version/info.go#L36-L56
304func NewGaugeFunc(opts GaugeOpts, function func() float64) GaugeFunc {
305 return newValueFunc(NewDesc(
306 BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
307 opts.Help,
308 nil,
309 opts.ConstLabels,
310 ), GaugeValue, function)
311}

Callers 5

ExampleGaugeFunc_simpleFunction · 0.92
NewCollectorFunction · 0.92
NewGaugeFuncMethod · 0.92
TestGaugeFuncFunction · 0.70

Calls 3

newValueFuncFunction · 0.85
NewDescFunction · 0.85
BuildFQNameFunction · 0.85

Tested by 3

ExampleGaugeFunc_simpleFunction · 0.74
TestGaugeFuncFunction · 0.56