示例#1
0
func (self *chainSamplerFactory) NewSampler(param *StatsParameter) (sampling.Sampler, error) {
	s := sampling.NewChainSampler(param.NumSamples, param.WindowSize)
	if param.ResetPeriod.Seconds() > 1.0 {
		s = sampling.NewPeriodcallyResetSampler(param.ResetPeriod, s)
	}
	return s, nil
}
示例#2
0
func (self *reservoirSamplerFactory) NewSampler(param *StatsParameter) (sampling.Sampler, error) {
	s := sampling.NewReservoirSampler(param.NumSamples)
	if param.ResetPeriod.Seconds() > 1.0 {
		s = sampling.NewPeriodcallyResetSampler(param.ResetPeriod, s)
	}
	return s, nil
}
示例#3
0
func (self *esSamplerFactory) NewSampler(param *StatsParameter) (sampling.Sampler, error) {
	s := sampling.NewESSampler(param.NumSamples, func(d interface{}) float64 {
		stats := d.(*info.ContainerStats)
		delta := self.startTime.Sub(stats.Timestamp)
		return delta.Seconds()
	})
	if param.ResetPeriod.Seconds() > 1.0 {
		s = sampling.NewPeriodcallyResetSampler(param.ResetPeriod, s)
	}
	return s, nil
}