Temper stream allocator more (#1920)
* Temper stream allocator more * gofmt * AllowPause default
This commit is contained in:
@@ -90,7 +90,9 @@ func NewChannelObserver(params ChannelObserverParams, logger logger.Logger) *Cha
|
||||
Name: params.Name + "-estimate",
|
||||
Logger: logger,
|
||||
RequiredSamples: params.Config.EstimateRequiredSamples,
|
||||
RequiredSamplesMin: params.Config.EstimateRequiredSamplesMin,
|
||||
DownwardTrendThreshold: params.Config.EstimateDownwardTrendThreshold,
|
||||
DownwardTrendMaxWait: params.Config.EstimateDownwardTrendMaxWait,
|
||||
CollapseThreshold: params.Config.EstimateCollapseThreshold,
|
||||
ValidityWindow: params.Config.EstimateValidityWindow,
|
||||
}),
|
||||
|
||||
@@ -57,7 +57,9 @@ type TrendDetectorParams struct {
|
||||
Name string
|
||||
Logger logger.Logger
|
||||
RequiredSamples int
|
||||
RequiredSamplesMin int
|
||||
DownwardTrendThreshold float64
|
||||
DownwardTrendMaxWait time.Duration
|
||||
CollapseThreshold time.Duration
|
||||
ValidityWindow time.Duration
|
||||
}
|
||||
@@ -203,7 +205,7 @@ func (t *TrendDetector) prune() {
|
||||
}
|
||||
|
||||
func (t *TrendDetector) updateDirection() {
|
||||
if len(t.samples) < t.params.RequiredSamples {
|
||||
if len(t.samples) < t.params.RequiredSamplesMin {
|
||||
t.direction = TrendDirectionNeutral
|
||||
return
|
||||
}
|
||||
@@ -213,9 +215,9 @@ func (t *TrendDetector) updateDirection() {
|
||||
|
||||
t.direction = TrendDirectionNeutral
|
||||
switch {
|
||||
case kt > 0:
|
||||
case kt > 0 && len(t.samples) >= t.params.RequiredSamples:
|
||||
t.direction = TrendDirectionUpward
|
||||
case kt < t.params.DownwardTrendThreshold:
|
||||
case kt < t.params.DownwardTrendThreshold && (len(t.samples) >= t.params.RequiredSamples || t.samples[len(t.samples)-1].at.Sub(t.samples[0].at) > t.params.DownwardTrendMaxWait):
|
||||
t.direction = TrendDirectionDownward
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user