UNPKG

grafana-cloud-graphite

Version:
50 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GraphiteGauge = void 0; class GraphiteGauge { constructor(name, interval, tags) { this.name = name; this.interval = interval; this.tags = tags; this.count = 0; } get() { return [ { name: this.name, interval: this.interval, value: this.count, time: Date.now(), tags: this.tags, }, ]; } clear() { const data = this.get(); this.reset(); return data; } set(value) { this.count = value || 0; } inc(value) { if (value === 0) { return; } this.count = value ? this.count + value : this.count + 1; } dec(value) { if (value === 0) { return; } if ((value ? this.count - value : this.count - 1) < 0) { return; } this.count = value ? this.count - value : this.count - 1; } reset() { this.count = 0; } } exports.GraphiteGauge = GraphiteGauge; //# sourceMappingURL=gauge.js.map