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)
| 77 | // the case where a valueFunc is directly registered with Prometheus, the |
| 78 | // provided function must be concurrency-safe. |
| 79 | func 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 | |
| 90 | func (v *valueFunc) Desc() *Desc { |
| 91 | return v.desc |
no test coverage detected