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)