process-reporter
Advanced tools
Comparing version 1.0.0 to 1.1.0
62
index.js
@@ -10,2 +10,3 @@ 'use strict'; | ||
/*eslint max-statements: [1, 30]*/ | ||
function ProcessReporter(options) { | ||
@@ -19,11 +20,49 @@ if (!(this instanceof ProcessReporter)) { | ||
assert(typeof options === 'object', 'options required'); | ||
assert(typeof options.statsd === 'object', 'options.statsd required'); | ||
self.statsd = options.statsd; | ||
assert(typeof self.statsd === 'object', 'options.statsd required'); | ||
self.handleInterval = options.handleInterval || 1000; | ||
assert( | ||
typeof self.handleInterval === 'number', | ||
'expected options.handleInterval to be number' | ||
); | ||
self.requestInterval = options.requestInterval || 100; | ||
assert( | ||
typeof self.requestInterval === 'number', | ||
'expected options.requestInterval to be number' | ||
); | ||
self.memoryInterval = options.memoryInterval || 1000; | ||
assert( | ||
typeof self.memoryInterval === 'number', | ||
'expected options.memoryInterval to be number' | ||
); | ||
self.lagInterval = options.lagInterval || 500; | ||
assert( | ||
typeof self.lagInterval === 'number', | ||
'expected options.lagInterval to be number' | ||
); | ||
self.statsd = options.statsd; | ||
self.timers = options.timers || timers; | ||
assert( | ||
typeof self.timers === 'object' && | ||
typeof self.timers.setTimeout === 'function' && | ||
typeof self.timers.clearTimeout === 'function', | ||
'expected options.timers to be object with setTimeout and ' + | ||
'clearTimeout functions' | ||
); | ||
self.prefix = options.prefix || ''; | ||
assert( | ||
typeof self.prefix === 'string', | ||
'expected options.prefix to be string' | ||
); | ||
if (self.prefix[self.prefix.length - 1] !== '.' && self.prefix !== '') { | ||
self.prefix = self.prefix + '.'; | ||
} | ||
self.handleTimer = null; | ||
@@ -33,4 +72,2 @@ self.requestTimer = null; | ||
self.lagTimer = null; | ||
self.timers = options.timers || timers; | ||
} | ||
@@ -86,3 +123,3 @@ | ||
var num = process._getActiveHandles().length; | ||
self.statsd.timing('process-reporter.handles', num); | ||
self.statsd.timing(self.prefix + 'process-reporter.handles', num); | ||
}; | ||
@@ -94,3 +131,3 @@ | ||
var num = process._getActiveRequests().length; | ||
self.statsd.timing('process-reporter.requests', num); | ||
self.statsd.timing(self.prefix + 'process-reporter.requests', num); | ||
}; | ||
@@ -102,7 +139,7 @@ | ||
var usage = process.memoryUsage(); | ||
var prefix = 'process-reporter.memory-usage'; | ||
var memPrefix = self.prefix + 'process-reporter.memory-usage'; | ||
self.statsd.gauge(prefix + '.rss', usage.rss); | ||
self.statsd.gauge(prefix + '.heap-used', usage.heapUsed); | ||
self.statsd.gauge(prefix + '.heap-total', usage.heapTotal); | ||
self.statsd.gauge(memPrefix + '.rss', usage.rss); | ||
self.statsd.gauge(memPrefix + '.heap-used', usage.heapUsed); | ||
self.statsd.gauge(memPrefix + '.heap-total', usage.heapTotal); | ||
}; | ||
@@ -113,3 +150,6 @@ | ||
self.statsd.timing('process-reporter.lag-sampler', toobusy.lag()); | ||
self.statsd.timing( | ||
self.prefix + 'process-reporter.lag-sampler', | ||
toobusy.lag() | ||
); | ||
}; |
{ | ||
"name": "process-reporter", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "process reporter", | ||
@@ -26,3 +26,2 @@ "main": "index.js", | ||
"test": "npm run check-ls -s && npm run lint -s && npm run cover", | ||
"test-repeat": "NODE_DEBUG=autobahn node test/index.js | FORCE_COLOR=1 tap-spec; while [ $? -eq 0 ]; do NODE_DEBUG=autobahn node test/index.js | FORCE_COLOR=1 tap-spec; done;", | ||
"test-cover": "istanbul cover test.js", | ||
@@ -29,0 +28,0 @@ "view-cover": "opn ./coverage/index.html", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8531
6
159
1