1
0
Fork 0

Make sample size configurable

This commit is contained in:
Gregory Eremin 2015-10-27 03:03:21 +03:00
parent 6f56486566
commit e0eb526af5
1 changed files with 9 additions and 4 deletions

View File

@ -34,7 +34,8 @@ type Stats interface {
type base struct {
sync.Mutex
stats map[string]*baseStats
stats map[string]*baseStats
sampleSize int
}
type baseStats struct {
@ -44,8 +45,9 @@ type baseStats struct {
}
const (
Latency = "Latency"
TaskWait = "TaskWait"
DefaultSampleSize = 1000
Latency = "Latency"
TaskWait = "TaskWait"
)
func (b *base) Add(name string, dur time.Duration) {
@ -122,9 +124,12 @@ func (b *base) metrics(name string) *baseStats {
return s
}
if b.sampleSize == 0 {
b.sampleSize = DefaultSampleSize
}
b.stats[name] = &baseStats{
name: name,
time: metrics.NewHistogram(metrics.NewUniformSample(1000)),
time: metrics.NewHistogram(metrics.NewUniformSample(b.sampleSize)),
errors: metrics.NewCounter(),
}
}