/** * Initialize reporter * @param {MetricRegistry} registry * @memberof ConsoleReporter */ init(registry) { super.init(registry); if (this.opts.interval > 0) { this.timer = setInterval(() => this.print(), this.opts.interval * 1000); this.timer.unref(); } }
/** * Recreate the INFO key update timer. */ recreateInfoUpdateTimer() { if (this.infoUpdateTimer) clearTimeout(this.infoUpdateTimer); this.infoUpdateTimer = setTimeout(() => { // Reset the INFO packet expiry. this.client.expire(this.INFO_KEY, 60 * 60); // 60 mins this.recreateInfoUpdateTimer(); }, 20 * 60 * 1000 ); // 20 mins this.infoUpdateTimer.unref(); }
/** * Start Gossip timers */ startTimers() { this.gossipTimer = setInterval(() => { this.getLocalNodeInfo().updateLocalInfo(this.broker.getCpuUsage) .then(() => this.sendGossipRequest()); }, Math.max(this.opts.gossipPeriod, 1) * 1000); this.gossipTimer.unref(); }
constructor(metric, item, min) { this.metric = metric; this.item = item; this.min = min; //this.alpha = getAlpha(min); this.rate = 0; this.lastValue = 0; this.lastTickTime = Date.now(); this.value = null; this.timer = setInterval(() => this.tick(), INTERVAL * 1000).unref(); }
/** * Rotate the ring buckets. * * @memberof TimeWindowQuantiles */ rotate() { this.currentBucket = (this.currentBucket + 1) % this.ageBuckets; this.ringBuckets[this.currentBucket].clear(); this.setDirty(); setTimeout(() => this.rotate(), (this.maxAgeSeconds / this.ageBuckets) * 1000).unref(); }
// Master discovery() { return this.broker.transit.sendPing().then(() => { const timer = setTimeout(() => this.pingHosts(), 1000 * this.opts.pingInterval); timer.unref(); }); }
/** * Initialize reporter. * * @param {MetricRegistry} registry * @memberof DatadogReporter */ init(registry) { super.init(registry); fetch.Promise = this.broker.Promise; if (this.opts.interval > 0) { this.timer = setInterval(() => this.flush(), this.opts.interval * 1000); this.timer.unref(); } this.defaultLabels = isFunction(this.opts.defaultLabels) ? this.opts.defaultLabels.call(this, registry) : this.opts.defaultLabels; }
/** * Start auto discovering * * @memberof UdpServer */ startDiscovering() { if (!this.discoverTimer) { this.discoverTimer = setInterval(() => { this.discover(); if (this.opts.udpMaxDiscovery && this.counter >= this.opts.udpMaxDiscovery) this.stopDiscovering(); }, (this.opts.udpPeriod || 30) * 1000); this.discoverTimer.unref(); this.logger.info("UDP discovery started."); } }
/** * Start heartbeat timers */ startHeartbeatTimers() { this.stopHeartbeatTimers(); if (this.opts.heartbeatInterval > 0) { // HB timer const time = this.opts.heartbeatInterval * 1000 + (Math.round(Math.random() * 1000) - 500); // random +/- 500ms this.heartbeatTimer = setInterval(() => this.beat(), time); this.heartbeatTimer.unref(); // Check expired heartbeats of remote nodes timer this.checkNodesTimer = setInterval(() => this.checkRemoteNodes(), this.opts.heartbeatTimeout * 1000); this.checkNodesTimer.unref(); // Clean offline nodes timer this.offlineTimer = setInterval(() => this.checkOfflineNodes(), 60 * 1000); // 1 min this.offlineTimer.unref(); } }
/** * Initialize logger. * * @param {LoggerFactory} loggerFactory */ init(loggerFactory) { super.init(loggerFactory); this.logFolder = path.resolve(this.render(this.opts.folder, { nodeID: this.broker.nodeID, namespace: this.broker.namespace, })); makeDirs(this.logFolder); if (this.opts.interval > 0) { this.timer = setInterval(() => this.flush(), this.opts.interval); this.timer.unref(); } }
/** * Initialize logger. * * @param {LoggerFactory} loggerFactory */ init(loggerFactory) { super.init(loggerFactory); this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : o => util.inspect(o, { showHidden: false, depth: 2, colors: false, breakLength: Number.POSITIVE_INFINITY }); if (this.opts.interval > 0) { this.timer = setInterval(() => this.flush(), this.opts.interval); this.timer.unref(); } }
/** * Initialize Trace Exporter. * * @param {Tracer} tracer * @memberof EventTraceExporter */ init(tracer) { super.init(tracer); if (this.opts.interval > 0) { this.timer = setInterval(() => this.flush(), this.opts.interval * 1000); this.timer.unref(); } this.defaultTags = isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, tracer) : this.opts.defaultTags; }
/** * Initialize Trace Exporter. * * @param {Tracer} tracer * @memberof DatadogTraceExporter */ init(tracer) { super.init(tracer); fetch.Promise = this.broker.Promise; if (this.opts.interval > 0) { this.timer = setInterval(() => this.flush(), this.opts.interval * 1000); this.timer.unref(); } this.defaultTags = isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, tracer) : this.opts.defaultTags; if (this.defaultTags) { this.defaultTags = this.flattenTags(this.defaultTags, true); } }
/** * Initialize reporter. * * @param {MetricRegistry} registry * @memberof CSVReporter */ init(registry) { super.init(registry); if (this.opts.interval > 0) { this.timer = setInterval(() => this.flush(), this.opts.interval * 1000); this.timer.unref(); } this.folder = path.resolve(this.opts.folder); makeDirs(this.folder); }
/** * Initialize reporter. * * @param {MetricRegistry} registry * @memberof EventReporter */ init(registry) { super.init(registry); if (this.opts.interval > 0) { this.timer = setInterval(() => this.sendEvent(), this.opts.interval * 1000); this.timer.unref(); } }