Skip to content

Commit

Permalink
Merge pull request prometheus#697 from prometheus/beorn7/doc
Browse files Browse the repository at this point in the history
Improve doc comment for NewGaugeFunc
  • Loading branch information
beorn7 authored Dec 10, 2019
2 parents 0da4c3a + de74638 commit 99d85f4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions prometheus/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,12 @@ type GaugeFunc interface {
// 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. If that results in concurrent calls to Write, like in the case
// where a GaugeFunc is directly registered with Prometheus, the provided
// function must be concurrency-safe.
// concurrently. Therefore, it must be safe to call the provided function
// concurrently.
//
// 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 {
return newValueFunc(NewDesc(
BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
Expand Down

0 comments on commit 99d85f4

Please sign in to comment.