Histogram doesn't update min/max correctly when initial updates are 0 or negative
otterley opened this issue · comments
Michael S. Fischer commented
Test case:
var Histogram = require('../metrics/histogram');
var broken = function(callback) {
console.log("\nBroken histogram demo");
var brokenHist = Histogram.createUniformHistogram(1000);
console.log("Adding 0 to histogram");
brokenHist.update(0);
console.log("Current min: " + brokenHist.min + ", max: " + brokenHist.max);
console.log("Adding -1 to histogram");
brokenHist.update(-1);
console.log("Current min: " + brokenHist.min + ", max: " + brokenHist.max);
console.log("Adding 1 to histogram");
brokenHist.update(1);
console.log("Current min: " + brokenHist.min + ", max: " + brokenHist.max);
if (typeof callback == 'function') {
callback();
}
};
Broken histogram demo
Adding 0 to histogram
Current min: 0, max: null
Adding -1 to histogram
Current min: -1, max: null
Adding 1 to histogram
Current min: -1, max: 1
Fix forthcoming in pull request.