pandora-metrics
Version:
## Overview
50 lines • 2.24 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const Reservoir_1 = require("../Reservoir");
const MetricType_1 = require("../MetricType");
const BucketCounter_1 = require("./BucketCounter");
const UniformReservoir_1 = require("../reservoir/UniformReservoir");
const ExponentiallyDecayingReservoir_1 = require("../reservoir/ExponentiallyDecayingReservoir");
const BucketReservoir_1 = require("../reservoir/BucketReservoir");
class BaseHistogram {
constructor(type = Reservoir_1.ReservoirType.EXPONENTIALLY_DECAYING, interval = 10, numberOfBucket = 10) {
this.type = MetricType_1.MetricType.HISTOGRAM;
this.count = new BucketCounter_1.BucketCounter(interval, numberOfBucket);
if (typeof type === 'object') {
this.reservoir = type; // || new EDS(1028, 0.015);
}
else {
switch (type) {
case Reservoir_1.ReservoirType.EXPONENTIALLY_DECAYING:
this.reservoir = new ExponentiallyDecayingReservoir_1.ExponentiallyDecayingReservoir();
break;
// case ReservoirType.SLIDING_TIME_WINDOW:
// this.reservoir = new SlidingTimeWindowReservoir(interval);
// break;
// case ReservoirType.SLIDING_WINDOW:
// this.reservoir = new SlidingWindowReservoir(1024);
// break;
case Reservoir_1.ReservoirType.UNIFORM:
this.reservoir = new UniformReservoir_1.UniformReservoir(1024);
break;
case Reservoir_1.ReservoirType.BUCKET:
this.reservoir = new BucketReservoir_1.BucketReservoir(interval, numberOfBucket, this.count);
break;
default:
this.reservoir = new ExponentiallyDecayingReservoir_1.ExponentiallyDecayingReservoir();
}
}
}
update(value) {
this.count.update();
this.reservoir.update(value);
}
getCount() {
return this.count.getCount();
}
getSnapshot() {
return this.reservoir.getSnapshot();
}
}
exports.BaseHistogram = BaseHistogram;
//# sourceMappingURL=Histogram.js.map
;