long start = request.getStartTime();
long end = request.getEndTime();
// if we're interpolating, expand the time window a little to allow interpolation at the start and end.
// Before returning the results, we'll make sure to only return what the client requested.
Interpolator interpolator = request.getInterpolator();
if (interpolator != null) {
// try and expand the window by the max allowed gap for interpolation, but cap it so we dont have
// super big windows. The worry being that somebody sets the max allowed gap to Long.MAX_VALUE
// to tell us to always interpolate.
long expandCap = Math.max(Interpolators.DEFAULT_MAX_ALLOWED_GAP, (end - start) / 4);
start -= Math.min(interpolator.getMaxAllowedGap(), expandCap);
end += Math.min(interpolator.getMaxAllowedGap(), expandCap);
// no use going past the current time
end = Math.min(end, TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS));
}
return new MetricsScanQueryBuilder()