process-reporter
Advanced tools
Comparing version 1.1.3 to 2.0.0
48
index.js
@@ -6,2 +6,3 @@ 'use strict'; | ||
var assert = require('assert'); | ||
var _gcstats; | ||
var _toobusy; | ||
@@ -71,2 +72,8 @@ | ||
self.lagTimer = null; | ||
self.gcStats = null; | ||
self._onStatsListener = onStats; | ||
function onStats(gcInfo) { | ||
self._reportGCStats(gcInfo); | ||
} | ||
} | ||
@@ -81,2 +88,6 @@ | ||
if (!_gcstats) { | ||
_gcstats = require('gc-stats'); | ||
} | ||
self.handleTimer = self.timers.setTimeout(onHandle, self.handleInterval); | ||
@@ -88,2 +99,5 @@ self.requestTimer = | ||
self.gcStats = new _gcstats(); | ||
self.gcStats.on('stats', self._onStatsListener); | ||
function onHandle() { | ||
@@ -122,2 +136,3 @@ self._reportHandle(); | ||
_toobusy.shutdown(); | ||
self.gcStats.removeListener('stats', self._onStatsListener); | ||
}; | ||
@@ -170,1 +185,34 @@ | ||
}; | ||
ProcessReporter.prototype._reportGCStats = function _reportGCStats(gcInfo) { | ||
var self = this; | ||
var prefix = self.prefix + 'process-reporter.gc.' + formatGCType(gcInfo); | ||
self.statsd.timing(prefix + '.pause-ms', gcInfo.pauseMS); | ||
self.statsd.gauge(prefix + '.heap-used', gcInfo.diff.usedHeapSize); | ||
self.statsd.gauge(prefix + '.heap-total', gcInfo.diff.totalHeapSize); | ||
}; | ||
function formatGCType(gcInfo) { | ||
var type; | ||
switch (gcInfo.gctype) { | ||
case 1: | ||
type = 'minor'; | ||
break; | ||
case 2: | ||
type = 'major'; | ||
break; | ||
case 3: | ||
type = 'both'; | ||
break; | ||
default: | ||
type = 'unknown'; | ||
break; | ||
} | ||
return type; | ||
} |
{ | ||
"name": "process-reporter", | ||
"version": "1.1.3", | ||
"version": "2.0.0", | ||
"description": "process reporter", | ||
@@ -9,2 +9,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"gc-stats": "0.0.6", | ||
"process": "^0.11.1", | ||
@@ -11,0 +12,0 @@ "toobusy": "^0.2.4" |
@@ -23,3 +23,6 @@ # process-reporter | ||
* **yourapp.process-reporter.lag-sampler** event loop lag | ||
* **yourapp.process-reporter.gc.{gc-type}.pause-ms** length of GC pauses | ||
* **yourapp.process-reporter.gc.{gc-type}.heap-used** +/- amount of bytes GCd | ||
* **yourapp.process-reporter.gc.{gc-type}.heap-total** +/- changes in heap total | ||
To destroy the reporter just call `processReporter.destroy();` |
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
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
11456
250
28
0
3
+ Addedgc-stats@0.0.6
+ Addedgc-stats@0.0.6(transitive)
+ Addednan@2.22.0(transitive)