pandora-metrics
Version:
## Overview
49 lines • 1.53 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const MetricType_1 = require("../MetricType");
const Reservoir_1 = require("../Reservoir");
const Meter_1 = require("./Meter");
const Histogram_1 = require("./Histogram");
/**
* A timer metric which aggregates timing durations and provides duration statistics, plus
* throughput statistics via {@link Meter}.
*/
class BaseTimer {
constructor(interval = 60, reservoir = Reservoir_1.ReservoirType.EXPONENTIALLY_DECAYING) {
this.type = MetricType_1.MetricType.TIMER;
this.meter = new Meter_1.BaseMeter(interval);
this.histogram = new Histogram_1.BaseHistogram(reservoir, interval, 10);
}
getCount() {
return this.histogram.getCount();
}
getFifteenMinuteRate() {
return this.meter.getFifteenMinuteRate();
}
getFiveMinuteRate() {
return this.meter.getFiveMinuteRate();
}
getMeanRate() {
return this.meter.getMeanRate();
}
getOneMinuteRate() {
return this.meter.getOneMinuteRate();
}
getSnapshot() {
return this.histogram.getSnapshot();
}
getInstantCountInterval() {
return this.meter.getInstantCountInterval();
}
getInstantCount(startTime) {
return this.meter.getInstantCount(startTime);
}
update(duration) {
if (duration >= 0) {
this.histogram.update(duration);
this.meter.mark();
}
}
}
exports.BaseTimer = BaseTimer;
//# sourceMappingURL=Timer.js.map
;