forked from mirror/client_golang
Change timer naming from Start/Stop to New/ObserveDuration
This commit is contained in:
parent
e63845e3ce
commit
120be69578
|
@ -32,7 +32,7 @@ type Timer struct {
|
||||||
observer Observer
|
observer Observer
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartTimer() *Timer {
|
func NewTimer() *Timer {
|
||||||
return &Timer{begin: time.Now()}
|
return &Timer{begin: time.Now()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func (t *Timer) WithGauge(g Gauge) *Timer {
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Timer) Stop() {
|
func (t *Timer) ObserveDuration() {
|
||||||
if t.observer != nil {
|
if t.observer != nil {
|
||||||
t.observer.Observe(time.Since(t.begin).Seconds())
|
t.observer.Observe(time.Since(t.begin).Seconds())
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ func TestTimerObserve(t *testing.T) {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
timer := StartTimer().With(his)
|
timer := NewTimer().With(his)
|
||||||
timer.Stop()
|
timer.ObserveDuration()
|
||||||
m := &dto.Metric{}
|
m := &dto.Metric{}
|
||||||
his.Write(m)
|
his.Write(m)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue