|
|
|
@ -131,10 +131,18 @@ func extrapolatedRate(vals []parser.Value, args parser.Expressions, enh *EvalNod
|
|
|
|
|
sampledInterval := float64(lastT-firstT) / 1000 |
|
|
|
|
averageDurationBetweenSamples := sampledInterval / float64(numSamplesMinusOne) |
|
|
|
|
|
|
|
|
|
// If the first/last samples are close to the boundaries of the range,
|
|
|
|
|
// extrapolate the result. This is as we expect that another sample
|
|
|
|
|
// will exist given the spacing between samples we've seen thus far,
|
|
|
|
|
// with an allowance for noise.
|
|
|
|
|
// If samples are close enough to the (lower or upper) boundary of the
|
|
|
|
|
// range, we extrapolate the rate all the way to the boundary in
|
|
|
|
|
// question. "Close enough" is defined as "up to 10% more than the
|
|
|
|
|
// average duration between samples within the range", see
|
|
|
|
|
// extrapolationThreshold below. Essentially, we are assuming a more or
|
|
|
|
|
// less regular spacing between samples, and if we don't see a sample
|
|
|
|
|
// where we would expect one, we assume the series does not cover the
|
|
|
|
|
// whole range, but starts and/or ends within the range. We still
|
|
|
|
|
// extrapolate the rate in this case, but not all the way to the
|
|
|
|
|
// boundary, but only by half of the average duration between samples
|
|
|
|
|
// (which is our guess for where the series actually starts or ends).
|
|
|
|
|
|
|
|
|
|
extrapolationThreshold := averageDurationBetweenSamples * 1.1 |
|
|
|
|
extrapolateToInterval := sampledInterval |
|
|
|
|
|
|
|
|
|