Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
childClient() {
return new LogStatsD(
this._logger,
this._serviceName
);
}
}
const timingMixin = {
endTiming(names, startTime, samplingInterval) {
return this.timing(names, Date.now() - startTime, samplingInterval);
}
};
// Also add a small utility to send a delta given a startTime
Object.assign(StatsD.prototype, timingMixin);
Object.assign(LogStatsD.prototype, timingMixin);
// Minimal StatsD wrapper
function makeStatsD(options, logger) {
let statsd;
const srvName = options._prefix ? options._prefix : normalizeName(options.name);
const statsdOptions = {
host: options.host,
port: options.port,
prefix: `${srvName}.`,
suffix: '',
globalize: false,
cacheDns: false,
mock: false
};
var monitor = function (host, port, prefix, suffix, globalize, cacheDns, mock, global_tags) {
var appmetrics = require('appmetrics');
var monitor = appmetrics.monitor();
var StatsD = require('hot-shots');
var client = Object.create(StatsD.prototype);
StatsD.apply(client, arguments);
monitor.on('cpu', function handleCPU(cpu) {
client.gauge('cpu.process', cpu.process);
client.gauge('cpu.system', cpu.system);
});
monitor.on('memory', function handleMem(memory) {
client.gauge('memory.process.private', memory.private);
client.gauge('memory.process.physical', memory.physical);
client.gauge('memory.process.virtual', memory.virtual);
client.gauge('memory.system.used', memory.physical_used);
client.gauge('memory.system.total', memory.physical_total);
});
monitor.on('eventloop', function handleEL(eventloop) {