feat(instrumentation): lots of refactoring to support tag based backend, #4696

This commit is contained in:
Torkel Ödegaard
2016-06-02 21:06:49 +02:00
parent 2a9b51d836
commit e2c794ff31
12 changed files with 219 additions and 207 deletions
+31 -16
View File
@@ -3,21 +3,33 @@ package metrics
//import "sync/atomic"
type Timer interface {
Metric
AddTiming(int64)
Clear()
Avg() int64
Min() int64
Max() int64
Total() int64
Count() int64
}
func NewTimer() Timer {
type StandardTimer struct {
*MetricMeta
total int64
count int64
avg int64
min int64
max int64
}
func NewTimer(meta *MetricMeta) Timer {
return &StandardTimer{
avg: 0,
min: 0,
max: 0,
total: 0,
count: 0,
MetricMeta: meta,
avg: 0,
min: 0,
max: 0,
total: 0,
count: 0,
}
}
@@ -56,14 +68,17 @@ func (this *StandardTimer) Max() int64 {
return this.max
}
func (this *StandardTimer) Total() int64 {
return this.total
func (this *StandardTimer) Count() int64 {
return this.count
}
type StandardTimer struct {
total int64
count int64
avg int64
min int64
max int64
func (this *StandardTimer) Snapshot() Metric {
return &StandardTimer{
MetricMeta: this.MetricMeta,
avg: this.avg,
min: this.min,
max: this.max,
total: this.total,
count: this.count,
}
}