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
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue