/**
* Exposed for testing.
* @param clock the {@link Clock} to use for the {@link CachedGauge}.
* @param reservoir the {@link Reservoir} to use for the histogram.
* @param timeoutMs the timeout for the value stored in the cache in milliseconds. After this time has passed, a new
* value of the histogram at {@code quantile} will be calculated.
* @param quantile the quantile of the histogram to cache.
*/
CachedHistogram(Clock clock, Reservoir reservoir, long timeoutMs, double quantile) {
super(reservoir);
cache = new CachedGauge<Double>(clock, timeoutMs, TimeUnit.MILLISECONDS) {
@Override
protected Double loadValue() {
return getSnapshot().getValue(quantile);
}
};
}