In io.prometheus.metrics.core.metrics.SlidingWindow, a ringBuffer of T is maintained. In case of Summary, T is CKMSQuantiles. But this ringBuffer is never actually fully used: only the 'current' element of the buffer is ever used (all other methods are private):
public synchronized T current() {
return rotate();
}
public synchronized void observe(double value) {
observeFunction.accept(rotate(), value);
}
E.g. in Summary.DataPoint#makeQuantiles(), only quantileValues.current() is used:
for (int i = 0; i < getQuantiles().size(); i++) {
CKMSQuantiles.Quantile quantile = getQuantiles().get(i);
quantiles[i] = new Quantile(quantile.quantile, quantileValues.current().get(quantile.quantile));
}
When this current slice happens to be just rotated, then DataPoint.makeQuantiles() will result in a NaN value.
Isn't the purpose of having a SlidingWindow to the full window when calculating a value, instead of only using the current slice?