prometheus-gc-stats
Advanced tools
Comparing version 0.1.0 to 0.2.0
35
index.js
@@ -22,6 +22,9 @@ 'use strict'; | ||
var gcTypes = { | ||
0: 'unknown', | ||
1: 'minor', | ||
2: 'major', | ||
3: 'both' | ||
0: 'Unknown', | ||
1: 'Scavenge', | ||
2: 'MarkSweepCompact', | ||
3: 'ScavengeAndMarkSweepCompact', | ||
4: 'IncrementalMarking', | ||
8: 'WeakPhantom', | ||
15: 'All' | ||
}; | ||
@@ -32,2 +35,7 @@ | ||
exports.default = function () { | ||
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var _ref$seconds = _ref.seconds; | ||
var seconds = _ref$seconds === undefined ? false : _ref$seconds; | ||
if (typeof gc !== 'function') { | ||
@@ -37,6 +45,12 @@ return noop; | ||
var gcCount = new _counter2.default('nodejs_gc_count', 'Count of total garbage collections.', ['gctype']); | ||
var gcTimeCount = new _counter2.default('nodejs_gc_pause_nanos_total', 'Time spent in GC Pause in nanoseconds.', ['gctype']); | ||
var gcReclaimedCount = new _counter2.default('nodejs_gc_reclaimed_bytes_total', 'Total number of bytes reclaimed by GC.', ['gctype']); | ||
var gcCount = new _counter2.default('nodejs_gc_runs_total', 'Count of total garbage collections.', ['gctype']); | ||
var gcReclaimedCount = new _counter2.default('nodejs_gc_reclaimed_total_bytes', 'Total number of bytes reclaimed by GC.', ['gctype']); | ||
var gcTimeCount = void 0; | ||
if (seconds) { | ||
gcTimeCount = new _counter2.default('nodejs_gc_pause_total_seconds', 'Time spent in GC Pause in seconds.', ['gctype']); | ||
} else { | ||
gcTimeCount = new _counter2.default('nodejs_gc_pause_total_nanoseconds', 'Time spent in GC Pause in nanoseconds.', ['gctype']); | ||
} | ||
var started = false; | ||
@@ -50,4 +64,9 @@ | ||
gcCount.labels(gcTypes[stats.gctype]).inc(); | ||
gcTimeCount.labels(gcTypes[stats.gctype]).inc(stats.pause); | ||
if (seconds) { | ||
gcTimeCount.labels(gcTypes[stats.gctype]).inc(stats.pause / 1e9); | ||
} else { | ||
gcTimeCount.labels(gcTypes[stats.gctype]).inc(stats.pause); | ||
} | ||
if (stats.diff.usedHeapSize < 0) { | ||
@@ -54,0 +73,0 @@ gcReclaimedCount.labels(gcTypes[stats.gctype]).inc(stats.diff.usedHeapSize * -1); |
{ | ||
"name": "prometheus-gc-stats", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Report Garbage Collection stats using Prometheus", | ||
@@ -41,7 +41,7 @@ "main": "index.js", | ||
"babel-preset-es2015": "^6.14.0", | ||
"eslint": "^3.5.0", | ||
"eslint": "^3.6.0", | ||
"eslint-config-simenb-base": "^3.0.0", | ||
"in-publish": "^2.0.0", | ||
"prom-client": "^5.0.0" | ||
"prom-client": "^5.0.1" | ||
} | ||
} |
@@ -24,2 +24,11 @@ # prometheus-gc-stats | ||
## Metrics exposed | ||
This module exposes 3 metrics: | ||
1. `nodejs_gc_runs_total`: Counts the number of time GC is invoked | ||
2. `nodejs_gc_pause_total_nanoseconds`: Time spent in GC in nanoseconds | ||
1. There's an option that can be passed to the function, `{ seconds: true }` which make this be reported in seconds instead | ||
3. `nodejs_gc_reclaimed_total_bytes`: The number of bytes GC has freed | ||
## Credits | ||
@@ -26,0 +35,0 @@ |
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
6740
4
55
50