aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/prometheus/client_golang/prometheus/timer.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/prometheus/client_golang/prometheus/timer.go')
-rw-r--r--vendor/github.com/prometheus/client_golang/prometheus/timer.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/timer.go b/vendor/github.com/prometheus/client_golang/prometheus/timer.go
index b8fc5f1..8d5f105 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/timer.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/timer.go
@@ -39,13 +39,16 @@ func NewTimer(o Observer) *Timer {
39 39
40// ObserveDuration records the duration passed since the Timer was created with 40// ObserveDuration records the duration passed since the Timer was created with
41// NewTimer. It calls the Observe method of the Observer provided during 41// NewTimer. It calls the Observe method of the Observer provided during
42// construction with the duration in seconds as an argument. ObserveDuration is 42// construction with the duration in seconds as an argument. The observed
43// usually called with a defer statement. 43// duration is also returned. ObserveDuration is usually called with a defer
44// statement.
44// 45//
45// Note that this method is only guaranteed to never observe negative durations 46// Note that this method is only guaranteed to never observe negative durations
46// if used with Go1.9+. 47// if used with Go1.9+.
47func (t *Timer) ObserveDuration() { 48func (t *Timer) ObserveDuration() time.Duration {
49 d := time.Since(t.begin)
48 if t.observer != nil { 50 if t.observer != nil {
49 t.observer.Observe(time.Since(t.begin).Seconds()) 51 t.observer.Observe(d.Seconds())
50 } 52 }
53 return d
51} 54}