Skip to content

Commit de74638

Browse files
committed
Improve doc comment for NewGaugeFunc
- Simplify confusing wording about concurrency safety. - Add link to example for info metric. Signed-off-by: beorn7 <[email protected]>
1 parent 0da4c3a commit de74638

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

prometheus/gauge.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,12 @@ type GaugeFunc interface {
273273
// NewGaugeFunc creates a new GaugeFunc based on the provided GaugeOpts. The
274274
// value reported is determined by calling the given function from within the
275275
// Write method. Take into account that metric collection may happen
276-
// concurrently. If that results in concurrent calls to Write, like in the case
277-
// where a GaugeFunc is directly registered with Prometheus, the provided
278-
// function must be concurrency-safe.
276+
// concurrently. Therefore, it must be safe to call the provided function
277+
// concurrently.
278+
//
279+
// NewGaugeFunc is a good way to create an “info” style metric with a constant
280+
// value of 1. Example:
281+
// https://github.com/prometheus/common/blob/8558a5b7db3c84fa38b4766966059a7bd5bfa2ee/version/info.go#L36-L56
279282
func NewGaugeFunc(opts GaugeOpts, function func() float64) GaugeFunc {
280283
return newValueFunc(NewDesc(
281284
BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),

0 commit comments

Comments
 (0)