Socket
Socket
Sign inDemoInstall

prometheus-gc-stats

Package Overview
Dependencies
19
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.5.0

127

index.js

@@ -1,103 +0,58 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
// Credits go to @tcolgate
var _counter = require("prom-client/lib/counter");
const Counter = require('prom-client').Counter;
const optional = require('optional');
var _counter2 = _interopRequireDefault(_counter);
const gc = optional('gc-stats');
var _package = require("prom-client/package.json");
var _optional = require("optional");
var _optional2 = _interopRequireDefault(_optional);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
var promMajor = Number(_package.version.split(".")[0]); // Credits go to @tcolgate
var promSupportsRegistries = promMajor >= 9;
var gc = (0, _optional2.default)("gc-stats");
var gcTypes = {
0: "Unknown",
1: "Scavenge",
2: "MarkSweepCompact",
3: "ScavengeAndMarkSweepCompact",
4: "IncrementalMarking",
8: "WeakPhantom",
15: "All"
const gcTypes = {
0: 'Unknown',
1: 'Scavenge',
2: 'MarkSweepCompact',
3: 'ScavengeAndMarkSweepCompact',
4: 'IncrementalMarking',
8: 'WeakPhantom',
15: 'All',
};
var noop = function noop() {};
const noop = () => {};
exports.default = function(registry) {
if (typeof gc !== "function") {
module.exports = registry => {
if (typeof gc !== 'function') {
return noop;
}
var gcCount = void 0;
var gcTimeCount = void 0;
var gcReclaimedCount = void 0;
const registers = registry ? [registry] : undefined;
if (registry) {
if (!promSupportsRegistries) {
throw new Error(
"You've provided a registry, but your version of prom-client is too old. Please use prom-client@9 or higher"
);
}
const labelNames = ['gctype'];
var registers = [registry];
var labelNames = ["gctype"];
const gcCount = new Counter({
name: 'nodejs_gc_runs_total',
help: 'Count of total garbage collections.',
labelNames,
registers,
});
const gcTimeCount = new Counter({
name: 'nodejs_gc_pause_seconds_total',
help: 'Time spent in GC Pause in seconds.',
labelNames,
registers,
});
const gcReclaimedCount = new Counter({
name: 'nodejs_gc_reclaimed_bytes_total',
help: 'Total number of bytes reclaimed by GC.',
labelNames,
registers,
});
gcCount = new _counter2.default({
name: "nodejs_gc_runs_total",
help: "Count of total garbage collections.",
labelNames: labelNames,
registers: registers
});
gcTimeCount = new _counter2.default({
name: "nodejs_gc_pause_seconds_total",
help: "Time spent in GC Pause in seconds.",
labelNames: labelNames,
registers: registers
});
gcReclaimedCount = new _counter2.default({
name: "nodejs_gc_reclaimed_bytes_total",
help: "Total number of bytes reclaimed by GC.",
labelNames: labelNames,
registers: registers
});
} else {
gcCount = new _counter2.default(
"nodejs_gc_runs_total",
"Count of total garbage collections.",
["gctype"],
registry && [registry]
);
gcTimeCount = new _counter2.default(
"nodejs_gc_pause_seconds_total",
"Time spent in GC Pause in seconds.",
["gctype"]
);
gcReclaimedCount = new _counter2.default(
"nodejs_gc_reclaimed_bytes_total",
"Total number of bytes reclaimed by GC.",
["gctype"]
);
}
let started = false;
var started = false;
return function() {
return () => {
if (started !== true) {
started = true;
gc().on("stats", function(stats) {
var gcType = gcTypes[stats.gctype];
gc().on('stats', stats => {
const gcType = gcTypes[stats.gctype];

@@ -114,3 +69,1 @@ gcCount.labels(gcType).inc();

};
module.exports = exports["default"];
{
"name": "prometheus-gc-stats",
"version": "0.4.0",
"version": "0.5.0",
"description": "Report Garbage Collection stats using Prometheus",

@@ -13,6 +13,6 @@ "main": "index.js",

"lint": "eslint .",
"prepublish": "not-in-install && npm run compile || in-install",
"prepublishOnly": "npm run compile",
"postpublish": "git push --follow-tags",
"pretest": "npm run lint",
"test": "echo \"Error: no test specified\""
"test": "jest"
},

@@ -27,2 +27,5 @@ "keywords": [

],
"engines": {
"node": ">=4"
},
"author": "Simen Bekkhus <sbekkhus91@gmail.com>",

@@ -38,14 +41,13 @@ "license": "MIT",

"peerDependencies": {
"prom-client": ">= 3.2 < 10"
"prom-client": ">= 10 < 11"
},
"devDependencies": {
"babel-cli": "^6.16.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.16.0",
"eslint": "^3.9.1",
"eslint-config-simenb-base": "^12.0.0",
"in-publish": "^2.0.0",
"eslint-config-simenb-jest": "^2.0.0",
"eslint-config-simenb-node": "^0.4.9",
"jest": "^20.0.4",
"prettier": "^1.4.4",
"prom-client": "^9.0.0"
"prom-client": "^10.0.0"
}
}

@@ -5,3 +5,3 @@ # prometheus-gc-stats

[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Build Status][circle-ci-image]][circle-ci-url]

@@ -16,3 +16,3 @@ [![Dependency Status][david-image]][david-url]

This module has a peer dependency on [`prom-client`](https://github.com/siimon/prom-client). Currently, version 3-10 are supported.
This module has a peer dependency on [`prom-client`](https://github.com/siimon/prom-client). Currently, 10 is supported.

@@ -43,4 +43,4 @@ This module follows the same API as the core default metrics. To start collection GC stats, invoke the exported function to create the

[travis-url]: https://travis-ci.org/SimenB/node-prometheus-gc-stats
[travis-image]: https://img.shields.io/travis/SimenB/node-prometheus-gc-stats.svg
[circle-ci-url]: https://circleci.com/gh/SimenB/node-prometheus-gc-stats
[circle-ci-image]: https://circleci.com/gh/SimenB/node-prometheus-gc-stats/tree/master.svg?style=shield&circle-token=05b6e173edee3b1494b0370d5d3caea00ad358a3
[npm-url]: https://npmjs.org/package/prometheus-gc-stats

@@ -50,9 +50,9 @@ [npm-image]: https://img.shields.io/npm/v/prometheus-gc-stats.svg

[david-image]: https://img.shields.io/david/SimenB/node-prometheus-gc-stats.svg
[david-dev-url]: https://david-dm.org/SimenB/node-prometheus-gc-stats#info=devDependencies
[david-dev-url]: https://david-dm.org/SimenB/node-prometheus-gc-stats?type=dev
[david-dev-image]: https://img.shields.io/david/dev/SimenB/node-prometheus-gc-stats.svg
[david-peer-url]: https://david-dm.org/SimenB/node-prometheus-gc-stats#info=peerDependencies
[david-peer-url]: https://david-dm.org/SimenB/node-prometheus-gc-stats?type=peer
[david-peer-image]: https://img.shields.io/david/peer/SimenB/node-prometheus-gc-stats.svg
[david-optional-url]: https://david-dm.org/SimenB/node-prometheus-gc-stats#info=optionalDependencies
[david-optional-url]: https://david-dm.org/SimenB/node-prometheus-gc-stats?type=optional
[david-optional-image]: https://img.shields.io/david/optional/SimenB/node-prometheus-gc-stats.svg
[greenkeeper-url]: greenkeeper-url
[greenkeeper-image]:https://badges.greenkeeper.io/SimenB/node-prometheus-gc-stats.svg
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc