Make sample size configurable
This commit is contained in:
parent
6f56486566
commit
e0eb526af5
@ -34,7 +34,8 @@ type Stats interface {
|
|||||||
|
|
||||||
type base struct {
|
type base struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
stats map[string]*baseStats
|
stats map[string]*baseStats
|
||||||
|
sampleSize int
|
||||||
}
|
}
|
||||||
|
|
||||||
type baseStats struct {
|
type baseStats struct {
|
||||||
@ -44,8 +45,9 @@ type baseStats struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Latency = "Latency"
|
DefaultSampleSize = 1000
|
||||||
TaskWait = "TaskWait"
|
Latency = "Latency"
|
||||||
|
TaskWait = "TaskWait"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (b *base) Add(name string, dur time.Duration) {
|
func (b *base) Add(name string, dur time.Duration) {
|
||||||
@ -122,9 +124,12 @@ func (b *base) metrics(name string) *baseStats {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if b.sampleSize == 0 {
|
||||||
|
b.sampleSize = DefaultSampleSize
|
||||||
|
}
|
||||||
b.stats[name] = &baseStats{
|
b.stats[name] = &baseStats{
|
||||||
name: name,
|
name: name,
|
||||||
time: metrics.NewHistogram(metrics.NewUniformSample(1000)),
|
time: metrics.NewHistogram(metrics.NewUniformSample(b.sampleSize)),
|
||||||
errors: metrics.NewCounter(),
|
errors: metrics.NewCounter(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user