Merge pull request #697 from prometheus/beorn7/doc

Improve doc comment for NewGaugeFunc
This commit is contained in:
Björn Rabenstein 2019-12-10 11:42:33 +01:00 committed by GitHub
commit 99d85f4901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

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