13
13
14
14
package prometheus
15
15
16
- import (
17
- "time"
18
- )
16
+ import "time"
19
17
20
18
// Timer is a helper type to time functions. Use NewTimer to create new
21
19
// instances.
@@ -154,7 +152,7 @@ func (t *TimerHistogramVec) Wrap(labels map[string]string, fn func()) {
154
152
fn ()
155
153
}
156
154
157
- func (t * TimerHistogramVec ) WrapLV (values []string , fn func ()) {
155
+ func (t * TimerHistogramVec ) WrapLabelValues (values []string , fn func ()) {
158
156
defer t .ObserveLabelValues (values ... )()
159
157
fn ()
160
158
}
@@ -201,7 +199,7 @@ func (t *TimerCounter) Observe() func() {
201
199
202
200
return func () {
203
201
d := time .Since (start )
204
- t .Counter . Add (d .Seconds ())
202
+ t .Add (d .Seconds ())
205
203
}
206
204
}
207
205
@@ -227,15 +225,15 @@ func (t *TimerCounterVec) Observe(labels map[string]string) func() {
227
225
228
226
return func () {
229
227
d := time .Since (start )
230
- t .CounterVec . With (labels ).Add (d .Seconds ())
228
+ t .With (labels ).Add (d .Seconds ())
231
229
}
232
230
}
233
231
234
232
func (t * TimerCounterVec ) ObserveLabelValues (values ... string ) func () {
235
233
start := time .Now ()
236
234
return func () {
237
235
d := time .Since (start )
238
- t .CounterVec . WithLabelValues (values ... ).Add (d .Seconds ())
236
+ t .WithLabelValues (values ... ).Add (d .Seconds ())
239
237
}
240
238
}
241
239
@@ -292,13 +290,13 @@ func (t *TimerContinuous) Observe() func() {
292
290
case <- ch :
293
291
d := time .Since (start )
294
292
if diff := d .Seconds () - added ; diff > 0 {
295
- t .Counter . Add (diff )
293
+ t .Add (diff )
296
294
}
297
295
return
298
296
case <- ticker .C :
299
297
d := time .Since (start )
300
298
if diff := d .Seconds () - added ; diff > 0 {
301
- t .Counter . Add (diff )
299
+ t .Add (diff )
302
300
added += diff
303
301
}
304
302
}
@@ -340,13 +338,13 @@ func (t *TimerContinuousVec) Observe(labels map[string]string) func() {
340
338
case <- ch :
341
339
d := time .Since (start )
342
340
if diff := d .Seconds () - added ; diff > 0 {
343
- t .CounterVec . With (labels ).Add (diff )
341
+ t .With (labels ).Add (diff )
344
342
}
345
343
return
346
344
case <- ticker .C :
347
345
d := time .Since (start )
348
346
if diff := d .Seconds () - added ; diff > 0 {
349
- t .CounterVec . With (labels ).Add (diff )
347
+ t .With (labels ).Add (diff )
350
348
added += diff
351
349
}
352
350
}
@@ -371,13 +369,13 @@ func (t *TimerContinuousVec) ObserveLabelValues(values ...string) func() {
371
369
case <- ch :
372
370
d := time .Since (start )
373
371
if diff := d .Seconds () - added ; diff > 0 {
374
- t .CounterVec . WithLabelValues (values ... ).Add (diff )
372
+ t .WithLabelValues (values ... ).Add (diff )
375
373
}
376
374
return
377
375
case <- ticker .C :
378
376
d := time .Since (start )
379
377
if diff := d .Seconds () - added ; diff > 0 {
380
- t .CounterVec . WithLabelValues (values ... ).Add (diff )
378
+ t .WithLabelValues (values ... ).Add (diff )
381
379
added += diff
382
380
}
383
381
}
0 commit comments