forked from mirror/client_golang
Merge pull request #282 from prometheus/grobie/fix-vet-issues
Fix invalid Timer (gauge) example
This commit is contained in:
commit
aace68cde2
|
@ -13,7 +13,11 @@
|
||||||
|
|
||||||
package prometheus_test
|
package prometheus_test
|
||||||
|
|
||||||
import "github.com/prometheus/client_golang/prometheus"
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// If a function is called rarely (i.e. not more often than scrapes
|
// If a function is called rarely (i.e. not more often than scrapes
|
||||||
|
@ -27,7 +31,7 @@ var (
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExampleTimer_gauge() error {
|
func run() error {
|
||||||
// The Set method of the Gauge is used to observe the duration.
|
// The Set method of the Gauge is used to observe the duration.
|
||||||
timer := prometheus.NewTimer(prometheus.ObserverFunc(funcDuration.Set))
|
timer := prometheus.NewTimer(prometheus.ObserverFunc(funcDuration.Set))
|
||||||
defer timer.ObserveDuration()
|
defer timer.ObserveDuration()
|
||||||
|
@ -36,3 +40,9 @@ func ExampleTimer_gauge() error {
|
||||||
// makes sure the function is still timed properly.
|
// makes sure the function is still timed properly.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExampleTimer_gauge() {
|
||||||
|
if err := run(); err != nil {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue