Skip to content

Summary DataPoint SlidingWindow only uses 'current' slice, resulting in periodic NaN values #894

@yrn1

Description

@yrn1

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions