Change timer naming from Start/Stop to New/ObserveDuration

This commit is contained in:
beorn7 2016-11-12 16:13:58 +01:00
parent e63845e3ce
commit 120be69578
2 changed files with 4 additions and 4 deletions

View File

@ -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())
}

View File

@ -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)