diff --git a/prometheus/example_timer_gauge_test.go b/prometheus/example_timer_gauge_test.go index dd91066..7184a0d 100644 --- a/prometheus/example_timer_gauge_test.go +++ b/prometheus/example_timer_gauge_test.go @@ -13,7 +13,11 @@ package prometheus_test -import "github.com/prometheus/client_golang/prometheus" +import ( + "os" + + "github.com/prometheus/client_golang/prometheus" +) var ( // 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. timer := prometheus.NewTimer(prometheus.ObserverFunc(funcDuration.Set)) defer timer.ObserveDuration() @@ -36,3 +40,9 @@ func ExampleTimer_gauge() error { // makes sure the function is still timed properly. return nil } + +func ExampleTimer_gauge() { + if err := run(); err != nil { + os.Exit(1) + } +}