Fix duplicated tags in InfluxDB
This commit is contained in:
parent
749d833f65
commit
ebd77f314d
20 changed files with 530 additions and 209 deletions
10
vendor/github.com/go-kit/kit/metrics/timer.go
generated
vendored
10
vendor/github.com/go-kit/kit/metrics/timer.go
generated
vendored
|
@ -7,6 +7,7 @@ import "time"
|
|||
type Timer struct {
|
||||
h Histogram
|
||||
t time.Time
|
||||
u time.Duration
|
||||
}
|
||||
|
||||
// NewTimer wraps the given histogram and records the current time.
|
||||
|
@ -14,15 +15,22 @@ func NewTimer(h Histogram) *Timer {
|
|||
return &Timer{
|
||||
h: h,
|
||||
t: time.Now(),
|
||||
u: time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
// ObserveDuration captures the number of seconds since the timer was
|
||||
// constructed, and forwards that observation to the histogram.
|
||||
func (t *Timer) ObserveDuration() {
|
||||
d := time.Since(t.t).Seconds()
|
||||
d := float64(time.Since(t.t).Nanoseconds()) / float64(t.u)
|
||||
if d < 0 {
|
||||
d = 0
|
||||
}
|
||||
t.h.Observe(d)
|
||||
}
|
||||
|
||||
// Unit sets the unit of the float64 emitted by the timer.
|
||||
// By default, the timer emits seconds.
|
||||
func (t *Timer) Unit(u time.Duration) {
|
||||
t.u = u
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue