Fixed typos
This commit is contained in:
parent
a7e9babbc0
commit
8e8b992294
@ -54,7 +54,7 @@ func (self *reservoirSamplerFactory) String() string {
|
|||||||
func (self *reservoirSamplerFactory) NewSampler(param *StatsParameter) (sampling.Sampler, error) {
|
func (self *reservoirSamplerFactory) NewSampler(param *StatsParameter) (sampling.Sampler, error) {
|
||||||
s := sampling.NewReservoirSampler(param.NumSamples)
|
s := sampling.NewReservoirSampler(param.NumSamples)
|
||||||
if param.ResetPeriod.Seconds() > 1.0 {
|
if param.ResetPeriod.Seconds() > 1.0 {
|
||||||
s = sampling.NewPeriodcallyResetSampler(param.ResetPeriod, s)
|
s = sampling.NewPeriodicallyResetSampler(param.ResetPeriod, s)
|
||||||
}
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ func (self *esSamplerFactory) NewSampler(param *StatsParameter) (sampling.Sample
|
|||||||
return delta.Seconds()
|
return delta.Seconds()
|
||||||
})
|
})
|
||||||
if param.ResetPeriod.Seconds() > 1.0 {
|
if param.ResetPeriod.Seconds() > 1.0 {
|
||||||
s = sampling.NewPeriodcallyResetSampler(param.ResetPeriod, s)
|
s = sampling.NewPeriodicallyResetSampler(param.ResetPeriod, s)
|
||||||
}
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ func (self *chainSamplerFactory) String() string {
|
|||||||
func (self *chainSamplerFactory) NewSampler(param *StatsParameter) (sampling.Sampler, error) {
|
func (self *chainSamplerFactory) NewSampler(param *StatsParameter) (sampling.Sampler, error) {
|
||||||
s := sampling.NewChainSampler(param.NumSamples, param.WindowSize)
|
s := sampling.NewChainSampler(param.NumSamples, param.WindowSize)
|
||||||
if param.ResetPeriod.Seconds() > 1.0 {
|
if param.ResetPeriod.Seconds() > 1.0 {
|
||||||
s = sampling.NewPeriodcallyResetSampler(param.ResetPeriod, s)
|
s = sampling.NewPeriodicallyResetSampler(param.ResetPeriod, s)
|
||||||
}
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ func (self *percentilesContainerHandlerWrapper) StatsSummary() (*info.ContainerS
|
|||||||
samples = append(samples, stats)
|
samples = append(samples, stats)
|
||||||
})
|
})
|
||||||
self.containerPercentiles.Samples = samples
|
self.containerPercentiles.Samples = samples
|
||||||
// XXX(dengnan): propabily add to StatsParameter?
|
// XXX(dengnan): probably add to StatsParameter?
|
||||||
self.containerPercentiles.FillPercentiles(
|
self.containerPercentiles.FillPercentiles(
|
||||||
[]int{50, 80, 90, 95, 99},
|
[]int{50, 80, 90, 95, 99},
|
||||||
[]int{50, 80, 90, 95, 99},
|
[]int{50, 80, 90, 95, 99},
|
||||||
|
@ -150,7 +150,7 @@ func TestSampleCpuUsage(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// request stats/obervation N+1 times, so that there will be N samples
|
// request stats/observation N+1 times, so that there will be N samples
|
||||||
for i := 0; i < N+1; i++ {
|
for i := 0; i < N+1; i++ {
|
||||||
_, err = handler.GetStats()
|
_, err = handler.GetStats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -135,7 +135,7 @@ type MemoryStats struct {
|
|||||||
Usage uint64 `json:"usage,omitempty"`
|
Usage uint64 `json:"usage,omitempty"`
|
||||||
|
|
||||||
// The amount of working set memory, this includes recently accessed memory,
|
// The amount of working set memory, this includes recently accessed memory,
|
||||||
// dirty memory, and kernel memmory. Working set is <= "usage".
|
// dirty memory, and kernel memory. Working set is <= "usage".
|
||||||
// Units: Bytes.
|
// Units: Bytes.
|
||||||
WorkingSet uint64 `json:"working_set,omitempty"`
|
WorkingSet uint64 `json:"working_set,omitempty"`
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ func NewSample(prev, current *ContainerStats) (*ContainerStatsSample, error) {
|
|||||||
return nil, fmt.Errorf("current CPU usage is less than prev CPU usage (cumulative).")
|
return nil, fmt.Errorf("current CPU usage is less than prev CPU usage (cumulative).")
|
||||||
}
|
}
|
||||||
sample := new(ContainerStatsSample)
|
sample := new(ContainerStatsSample)
|
||||||
// Caculate the diff to get the CPU usage within the time interval.
|
// Calculate the diff to get the CPU usage within the time interval.
|
||||||
sample.Cpu.Usage = current.Cpu.Usage.Total - prev.Cpu.Usage.Total
|
sample.Cpu.Usage = current.Cpu.Usage.Total - prev.Cpu.Usage.Total
|
||||||
// Memory usage is current memory usage
|
// Memory usage is current memory usage
|
||||||
sample.Memory.Usage = current.Memory.Usage
|
sample.Memory.Usage = current.Memory.Usage
|
||||||
|
@ -44,7 +44,7 @@ func (self *autoResetSampler) Update(d interface{}) {
|
|||||||
self.sampler.Update(d)
|
self.sampler.Update(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPeriodcallyResetSampler(period time.Duration, sampler Sampler) Sampler {
|
func NewPeriodicallyResetSampler(period time.Duration, sampler Sampler) Sampler {
|
||||||
lastRest := time.Now()
|
lastRest := time.Now()
|
||||||
shouldReset := func(d interface{}) bool {
|
shouldReset := func(d interface{}) bool {
|
||||||
if time.Now().Sub(lastRest) > period {
|
if time.Now().Sub(lastRest) > period {
|
||||||
|
@ -21,7 +21,7 @@ func randInt64Except(start, end int64, except map[int64]empty) int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Basic idea:
|
// Basic idea:
|
||||||
// Every obervation will have a sequence number as its id.
|
// Every observation will have a sequence number as its id.
|
||||||
// Suppose we want to sample k observations within latest n observations
|
// Suppose we want to sample k observations within latest n observations
|
||||||
// At first, we generated k random numbers in [0,n). These random numbers
|
// At first, we generated k random numbers in [0,n). These random numbers
|
||||||
// will be used as ids of observations that will be sampled.
|
// will be used as ids of observations that will be sampled.
|
||||||
|
@ -51,7 +51,7 @@ func (self *reservoirSampler) Update(d interface{}) {
|
|||||||
self.samples = append(self.samples, d)
|
self.samples = append(self.samples, d)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Randomly generates a number between [0, numInances).
|
// Randomly generates a number between [0, numInstances).
|
||||||
// Use this random number, j, as an index. If j is larger than the
|
// Use this random number, j, as an index. If j is larger than the
|
||||||
// reservoir size, we will ignore the current new data.
|
// reservoir size, we will ignore the current new data.
|
||||||
// Otherwise replace the jth element in reservoir with the new data.
|
// Otherwise replace the jth element in reservoir with the new data.
|
||||||
|
@ -36,7 +36,7 @@ type Sampler interface {
|
|||||||
|
|
||||||
// Filter() should update in place. Removing elements may or may not
|
// Filter() should update in place. Removing elements may or may not
|
||||||
// affect the statistical behavior of the sampler, i.e. the probability
|
// affect the statistical behavior of the sampler, i.e. the probability
|
||||||
// that an obervation will be sampled after removing some elements is
|
// that an observation will be sampled after removing some elements is
|
||||||
// implementation defined.
|
// implementation defined.
|
||||||
Filter(filter func(interface{}) bool)
|
Filter(filter func(interface{}) bool)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user