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

Function newValueFunc

prometheus/value.go:79–88  ·  view source on GitHub ↗

newValueFunc returns a newly allocated valueFunc with the given Desc and ValueType. The value reported is determined by calling the given function from within the Write method. Take into account that metric collection may happen concurrently. If that results in concurrent calls to Write, like in the

(desc *Desc, valueType ValueType, function func() float64)

Source from the content-addressed store, hash-verified

77// the case where a valueFunc is directly registered with Prometheus, the
78// provided function must be concurrency-safe.
79func newValueFunc(desc *Desc, valueType ValueType, function func() float64) *valueFunc {
80 result := &valueFunc{
81 desc: desc,
82 valType: valueType,
83 function: function,
84 labelPairs: MakeLabelPairs(desc, nil),
85 }
86 result.init(result)
87 return result
88}
89
90func (v *valueFunc) Desc() *Desc {
91 return v.desc

Callers 3

NewUntypedFuncFunction · 0.85
NewCounterFuncFunction · 0.85
NewGaugeFuncFunction · 0.85

Calls 2

MakeLabelPairsFunction · 0.85
initMethod · 0.80

Tested by

no test coverage detected