Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const handleObjectTags = method => {
const original = metrics[method];
metrics[method] = (key, val, tags, timestamp) => {
return original.call(
metrics,
key,
val,
Array.isArray(tags) ? tags : stringify(tags),
timestamp
);
};
};
handleObjectTags('histogram');
handleObjectTags('gauge');
handleObjectTags('increment');
metrics.timing = (...args) => metrics.histogram.call(metrics, ...args);
statsd = metrics;
}
function collectMemoryStats() {
var memory = process.memoryUsage();
statsd.gauge('memory.rss', memory.rss);
statsd.gauge('memory.heapTotal', memory.heapTotal);
statsd.gauge('memory.heapUsed', memory.heapUsed);
}
// Report memory usage every second
setInterval(collectMemoryStats, 1000);