From 120be69578d9aa4a369500f23400ad67f39296e5 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Sat, 12 Nov 2016 16:13:58 +0100 Subject: [PATCH] Change timer naming from Start/Stop to New/ObserveDuration --- prometheus/timer.go | 4 ++-- prometheus/timer_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/prometheus/timer.go b/prometheus/timer.go index d6e0d11..0767281 100644 --- a/prometheus/timer.go +++ b/prometheus/timer.go @@ -32,7 +32,7 @@ type Timer struct { observer Observer } -func StartTimer() *Timer { +func NewTimer() *Timer { return &Timer{begin: time.Now()} } @@ -46,7 +46,7 @@ func (t *Timer) WithGauge(g Gauge) *Timer { return t } -func (t *Timer) Stop() { +func (t *Timer) ObserveDuration() { if t.observer != nil { t.observer.Observe(time.Since(t.begin).Seconds()) } diff --git a/prometheus/timer_test.go b/prometheus/timer_test.go index 747a7ba..3c117ef 100644 --- a/prometheus/timer_test.go +++ b/prometheus/timer_test.go @@ -26,8 +26,8 @@ func TestTimerObserve(t *testing.T) { }, ) - timer := StartTimer().With(his) - timer.Stop() + timer := NewTimer().With(his) + timer.ObserveDuration() m := &dto.Metric{} his.Write(m)