Skip to content

Commit 1777cf3

Browse files
committed
Lint
1 parent 69f0d6c commit 1777cf3

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

prometheus/timer.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
package prometheus
1515

16-
import (
17-
"time"
18-
)
16+
import "time"
1917

2018
// Timer is a helper type to time functions. Use NewTimer to create new
2119
// instances.
@@ -154,7 +152,7 @@ func (t *TimerHistogramVec) Wrap(labels map[string]string, fn func()) {
154152
fn()
155153
}
156154

157-
func (t *TimerHistogramVec) WrapLV(values []string, fn func()) {
155+
func (t *TimerHistogramVec) WrapLabelValues(values []string, fn func()) {
158156
defer t.ObserveLabelValues(values...)()
159157
fn()
160158
}
@@ -201,7 +199,7 @@ func (t *TimerCounter) Observe() func() {
201199

202200
return func() {
203201
d := time.Since(start)
204-
t.Counter.Add(d.Seconds())
202+
t.Add(d.Seconds())
205203
}
206204
}
207205

@@ -227,15 +225,15 @@ func (t *TimerCounterVec) Observe(labels map[string]string) func() {
227225

228226
return func() {
229227
d := time.Since(start)
230-
t.CounterVec.With(labels).Add(d.Seconds())
228+
t.With(labels).Add(d.Seconds())
231229
}
232230
}
233231

234232
func (t *TimerCounterVec) ObserveLabelValues(values ...string) func() {
235233
start := time.Now()
236234
return func() {
237235
d := time.Since(start)
238-
t.CounterVec.WithLabelValues(values...).Add(d.Seconds())
236+
t.WithLabelValues(values...).Add(d.Seconds())
239237
}
240238
}
241239

@@ -292,13 +290,13 @@ func (t *TimerContinuous) Observe() func() {
292290
case <-ch:
293291
d := time.Since(start)
294292
if diff := d.Seconds() - added; diff > 0 {
295-
t.Counter.Add(diff)
293+
t.Add(diff)
296294
}
297295
return
298296
case <-ticker.C:
299297
d := time.Since(start)
300298
if diff := d.Seconds() - added; diff > 0 {
301-
t.Counter.Add(diff)
299+
t.Add(diff)
302300
added += diff
303301
}
304302
}
@@ -340,13 +338,13 @@ func (t *TimerContinuousVec) Observe(labels map[string]string) func() {
340338
case <-ch:
341339
d := time.Since(start)
342340
if diff := d.Seconds() - added; diff > 0 {
343-
t.CounterVec.With(labels).Add(diff)
341+
t.With(labels).Add(diff)
344342
}
345343
return
346344
case <-ticker.C:
347345
d := time.Since(start)
348346
if diff := d.Seconds() - added; diff > 0 {
349-
t.CounterVec.With(labels).Add(diff)
347+
t.With(labels).Add(diff)
350348
added += diff
351349
}
352350
}
@@ -371,13 +369,13 @@ func (t *TimerContinuousVec) ObserveLabelValues(values ...string) func() {
371369
case <-ch:
372370
d := time.Since(start)
373371
if diff := d.Seconds() - added; diff > 0 {
374-
t.CounterVec.WithLabelValues(values...).Add(diff)
372+
t.WithLabelValues(values...).Add(diff)
375373
}
376374
return
377375
case <-ticker.C:
378376
d := time.Since(start)
379377
if diff := d.Seconds() - added; diff > 0 {
380-
t.CounterVec.WithLabelValues(values...).Add(diff)
378+
t.WithLabelValues(values...).Add(diff)
381379
added += diff
382380
}
383381
}

0 commit comments

Comments
 (0)