Socket
Socket
Sign inDemoInstall

prom-client

Package Overview
Dependencies
Maintainers
2
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prom-client - npm Package Compare versions

Comparing version 11.2.1 to 11.3.0

111

CHANGELOG.md

@@ -16,2 +16,13 @@ # Changelog

## [11.3.0] - 2019-04-02
### Changed
- Check that cluster worker is still connected before attempting to query it for
metrics. (#244)
### Added
- Added a `remove()` method on each metric type, based on [Prometheus "Writing Client Libraries" section on labels](https://prometheus.io/docs/instrumenting/writing_clientlibs/#labels)
## [11.2.1]

@@ -25,3 +36,3 @@

* Updated types for Summary in typescript definition file
- Updated types for Summary in typescript definition file

@@ -32,8 +43,8 @@ ## [11.2.0]

* Updated child dependency `merge` patch version to remove vulnerability.
- Updated child dependency `merge` patch version to remove vulnerability.
### Added
* Added an initial `benchmark` suite which can be run with `npm run benchmarks`.
* Add support for sliding windows in Summaries
- Added an initial `benchmark` suite which can be run with `npm run benchmarks`.
- Add support for sliding windows in Summaries

@@ -44,3 +55,3 @@ ## [11.1.3] - 2018-09-22

* Fixed performance by avoiding `Object.assign` on hot paths, as well as
- Fixed performance by avoiding `Object.assign` on hot paths, as well as
mutating objects when appropriate.

@@ -52,4 +63,4 @@

* Allow setting Gauge values to NaN, +Inf, and -Inf
* Fixed `histogram` scrape performance by using `acc.push` instead of `acc.concat`. Fixes #216 with #219
- Allow setting Gauge values to NaN, +Inf, and -Inf
- Fixed `histogram` scrape performance by using `acc.push` instead of `acc.concat`. Fixes #216 with #219

@@ -60,14 +71,14 @@ ## [11.1.1] - 2018-06-29

* Fixed `processOpenFileDescriptors` metric when no custom config was set
- Fixed `processOpenFileDescriptors` metric when no custom config was set
## [11.1.0] - 2018-06-29
* Added ability to set a name prefix in the default metrics
- Added ability to set a name prefix in the default metrics
### Changed
* Fixed `startTimer` utility to not mutate objects passed as `startLabels`
* Fixed `Counter` to validate labels parameter of `inc()` against initial
- Fixed `startTimer` utility to not mutate objects passed as `startLabels`
- Fixed `Counter` to validate labels parameter of `inc()` against initial
labelset
* Fixed `AggregatorFactory` losing the aggregator method of metrics
- Fixed `AggregatorFactory` losing the aggregator method of metrics

@@ -78,6 +89,6 @@ ## [11.0.0] - 2018-03-10

* Fixed `gauge.setToCurrentTime()` to use seconds instead of milliseconds
* This conforms to Prometheus
- Fixed `gauge.setToCurrentTime()` to use seconds instead of milliseconds
- This conforms to Prometheus
[best practices](https://prometheus.io/docs/practices/naming/#base-units)
* Dropped support for node 4
- Dropped support for node 4

@@ -90,3 +101,3 @@ ## [10.2.3] - 2018-02-28

* Fixed issue that `registry.getMetricsAsJSON()` ignores registry default labels
- Fixed issue that `registry.getMetricsAsJSON()` ignores registry default labels

@@ -99,3 +110,3 @@ ### Added

* Fixed invalid `process_virtual_memory_bytes` reported under linux
- Fixed invalid `process_virtual_memory_bytes` reported under linux

@@ -106,3 +117,3 @@ ## [10.2.1] - 2017-10-27

* Only resolve/reject `clusterMetrics` promise if no callback is provided
- Only resolve/reject `clusterMetrics` promise if no callback is provided

@@ -113,9 +124,9 @@ ## [10.2.0] - 2017-10-16

* Don't add event listeners if cluster module is not used.
* Fixed issue with counters having extra records when using empty labels
- Don't add event listeners if cluster module is not used.
- Fixed issue with counters having extra records when using empty labels
### Added
* Added `reset` to Counter and Gauge
* Added `resetMetrics` to register to calling `reset` of all metric instances
- Added `reset` to Counter and Gauge
- Added `resetMetrics` to register to calling `reset` of all metric instances

@@ -126,4 +137,4 @@ ## [10.1.1] - 2017-09-26

* Update TypeScript definitions and JSDoc comments to match JavaScript sources
* Fix lexical scope of `arguments` in cluster code
- Update TypeScript definitions and JSDoc comments to match JavaScript sources
- Fix lexical scope of `arguments` in cluster code

@@ -134,3 +145,3 @@ ## [10.1.0] - 2017-09-04

* Support aggregating metrics across workers in a Node.js cluster.
- Support aggregating metrics across workers in a Node.js cluster.

@@ -141,3 +152,3 @@ ## [10.0.4] - 2017-08-22

* Include invalid values in the error messages
- Include invalid values in the error messages

@@ -148,8 +159,8 @@ ## [10.0.3] - 2017-08-07

* Added registerMetric to definitions file
- Added registerMetric to definitions file
### Changed
* Fixed typing of DefaultMetricsCollectorConfiguration in definitions file
* Don't pass timestamps through to pushgateway by default
- Fixed typing of DefaultMetricsCollectorConfiguration in definitions file
- Don't pass timestamps through to pushgateway by default

@@ -160,3 +171,3 @@ ## [10.0.2] - 2017-07-07

* Don't poll default metrics every single tick
- Don't poll default metrics every single tick

@@ -167,3 +178,3 @@ ## [10.0.1] - 2017-07-06

* Metrics should be initialized to 0 when there are no labels
- Metrics should be initialized to 0 when there are no labels

@@ -174,9 +185,9 @@ ## [10.0.0] - 2017-07-04

* Print deprecation warning when metrics are constructed using non-objects
* Print deprecation warning when `collectDefaultMetrics` is called with a number
- Print deprecation warning when metrics are constructed using non-objects
- Print deprecation warning when `collectDefaultMetrics` is called with a number
### Added
* Ability to set default labels by registry
* Allow passing in `registry` as second argument to `collectDefaultMetrics` to
- Ability to set default labels by registry
- Allow passing in `registry` as second argument to `collectDefaultMetrics` to
use that instead of the default registry

@@ -186,9 +197,9 @@

* Convert code base to ES2015 code (node 4)
* add engines field to package.json
* Use object shorthand
* Remove `util-extend` in favor of `Object.assign`
* Arrow functions over binding or putting `this` in a variable
* Use template strings
* `prototype` -> `class`
- Convert code base to ES2015 code (node 4)
- add engines field to package.json
- Use object shorthand
- Remove `util-extend` in favor of `Object.assign`
- Arrow functions over binding or putting `this` in a variable
- Use template strings
- `prototype` -> `class`

@@ -199,3 +210,3 @@ ## [9.1.1] - 2017-06-17

* Don't set timestamps for metrics that are never updated
- Don't set timestamps for metrics that are never updated

@@ -206,7 +217,7 @@ ## [9.1.0] - 2017-06-07

* Ability to merge registries
- Ability to merge registries
### Changed
* Correct typedefs for object constructor of metrics
- Correct typedefs for object constructor of metrics

@@ -217,9 +228,9 @@ ## [9.0.0] - 2017-05-06

* Support for multiple registers
* Support for object literals in metric constructors
* Timestamp support
- Support for multiple registers
- Support for object literals in metric constructors
- Timestamp support
### Changed
* Collection of default metrics is now disabled by default. Start collection by
- Collection of default metrics is now disabled by default. Start collection by
running `collectDefaultMetrics()`.

@@ -229,3 +240,3 @@

* Creating metrics with one argument per parameter - use object literals
- Creating metrics with one argument per parameter - use object literals
instead.

@@ -232,0 +243,0 @@

@@ -203,2 +203,8 @@ // Type definitions for prom-client

reset(): void;
/**
* Remove metrics for the given label values
* @param values Label values
*/
remove(...values: string[]): void;
}

@@ -311,2 +317,8 @@

reset(): void;
/**
* Remove metrics for the given label values
* @param values Label values
*/
remove(...values: string[]): void;
}

@@ -418,2 +430,8 @@

labels(...values: string[]): Histogram.Internal;
/**
* Remove metrics for the given label values
* @param values Label values
*/
remove(...values: string[]): void;
}

@@ -515,2 +533,8 @@

labels(...values: string[]): Summary.Internal;
/**
* Remove metrics for the given label values
* @param values Label values
*/
remove(...values: string[]): void;
}

@@ -517,0 +541,0 @@

@@ -41,4 +41,2 @@ 'use strict';

return new Promise((resolve, reject) => {
const nWorkers = Object.keys(cluster.workers).length;
function done(err, result) {

@@ -54,9 +52,5 @@ // Don't resolve/reject the promise if a callback is provided

if (nWorkers === 0) {
return process.nextTick(() => done(null, ''));
}
const request = {
responses: [],
pending: nWorkers,
pending: 0,
done,

@@ -76,3 +70,17 @@ errorTimeout: setTimeout(() => {

};
for (const id in cluster.workers) cluster.workers[id].send(message);
for (const id in cluster.workers) {
// If the worker exits abruptly, it may still be in the workers
// list but not able to communicate.
if (cluster.workers[id].isConnected()) {
cluster.workers[id].send(message);
request.pending++;
}
}
if (request.pending === 0) {
// No workers were up
clearTimeout(request.errorTimeout);
process.nextTick(() => done(null, ''));
}
});

@@ -153,9 +161,3 @@ }

// Listen for worker responses to requests for local metrics
cluster.on('message', function(worker, message) {
if (arguments.length === 2) {
// pre-Node.js v6.0
message = worker;
worker = undefined;
}
cluster.on('message', (worker, message) => {
if (message.type === GET_METRICS_RES) {

@@ -162,0 +164,0 @@ const request = requests.get(message.requestId);

@@ -15,3 +15,4 @@ /**

printDeprecationObjectConstructor,
getLabels
getLabels,
removeLabels
} = require('./util');

@@ -126,2 +127,7 @@

}
remove() {
const labels = getLabels(this.labelNames, arguments) || {};
return removeLabels.call(this, this.hashMap, labels);
}
}

@@ -165,4 +171,4 @@

: Number.isFinite(timestamp)
? timestamp
: undefined;
? timestamp
: undefined;
if (hashMap[hash]) {

@@ -169,0 +175,0 @@ hashMap[hash].value += value;

@@ -17,3 +17,4 @@ /**

isObject,
printDeprecationObjectConstructor
printDeprecationObjectConstructor,
removeLabels
} = require('./util');

@@ -172,2 +173,7 @@ const {

}
remove() {
const labels = getLabels(this.labelNames, arguments);
removeLabels.call(this, this.hashMap, labels);
}
}

@@ -174,0 +180,0 @@

@@ -14,3 +14,4 @@ /**

isObject,
printDeprecationObjectConstructor
printDeprecationObjectConstructor,
removeLabels
} = require('./util');

@@ -153,2 +154,7 @@ const {

}
remove() {
const labels = getLabels(this.labelNames, arguments);
removeLabels.call(this, this.hashMap, labels);
}
}

@@ -155,0 +161,0 @@

@@ -43,2 +43,4 @@ 'use strict';

function useGateway(method, job, groupings, callback) {
// `URL` first added in v6.13.0
// eslint-disable-next-line node/no-deprecated-api
const gatewayUrlParsed = url.parse(this.gatewayUrl);

@@ -53,3 +55,5 @@ const gatewayUrlPath =

// eslint-disable-next-line node/no-deprecated-api
const target = url.resolve(this.gatewayUrl, path);
// eslint-disable-next-line node/no-deprecated-api
const requestParams = url.parse(target);

@@ -56,0 +60,0 @@ const httpModule = isHttps(requestParams.href) ? https : http;

@@ -51,3 +51,3 @@ 'use strict';

if (labels) {
metricName += `{${labels.replace(/,$/, '')}}`;
metricName += `{${labels.substring(0, labels.length - 1)}}`;
}

@@ -72,3 +72,3 @@

return metrics.replace(/\n$/, '');
return metrics.substring(0, metrics.length - 1);
}

@@ -75,0 +75,0 @@

@@ -14,3 +14,4 @@ /**

isObject,
printDeprecationObjectConstructor
printDeprecationObjectConstructor,
removeLabels
} = require('./util');

@@ -159,2 +160,7 @@ const {

}
remove() {
const labels = getLabels(this.labelNames, arguments);
removeLabels.call(this, this.hashMap, labels);
}
}

@@ -161,0 +167,0 @@

@@ -26,2 +26,7 @@ 'use strict';

exports.removeLabels = function removeLabels(hashMap, labels) {
const hash = hashObject(labels);
delete hashMap[hash];
};
exports.setValue = function setValue(hashMap, value, labels, timestamp) {

@@ -35,4 +40,4 @@ const hash = hashObject(labels);

: Number.isFinite(timestamp)
? timestamp
: undefined
? timestamp
: undefined
};

@@ -68,7 +73,10 @@ return hashMap;

const elems = [];
for (let i = 0; i < keys.length; i++) {
elems.push(`${keys[i]}:${labels[keys[i]]}`);
let hash = '';
let i = 0;
const size = keys.length;
for (; i < size - 1; i++) {
hash += `${keys[i]}:${labels[keys[i]]},`;
}
return elems.join(',');
hash += `${keys[i]}:${labels[keys[i]]}`;
return hash;
}

@@ -75,0 +83,0 @@ exports.hashObject = hashObject;

{
"name": "prom-client",
"version": "11.2.1",
"description": "Client for prometheus",
"main": "index.js",
"files": ["lib/", "index.js", "index.d.ts"],
"engines": {
"node": ">=6.1"
},
"scripts": {
"benchmarks": "node ./benchmarks/index.js",
"test": "npm run lint && npm run compile-typescript && npm run test-unit",
"lint": "eslint .",
"test-unit": "jest",
"compile-typescript": "tsc index.d.ts --noImplicitAny --target es6",
"precommit": "lint-staged"
},
"repository": {
"type": "git",
"url": "git@github.com:siimon/prom-client.git"
},
"keywords": ["Prometheus", "Metrics", "Client"],
"author": "Simon Nyberg",
"license": "Apache-2.0",
"homepage": "https://github.com/siimon/prom-client",
"devDependencies": {
"@clevernature/benchmark-regression": "^1.0.0",
"eslint": "^5.6.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-prettier": "^2.1.2",
"express": "^4.13.3",
"husky": "^0.14.3",
"jest": "^23.6.0",
"lint-staged": "^7.0.0",
"lolex": "^2.1.3",
"prettier": "1.14.3",
"typescript": "^3.0.3"
},
"dependencies": {
"tdigest": "^0.1.1"
},
"types": "./index.d.ts",
"jest": {
"testEnvironment": "node",
"testRegex": ".*Test\\.js$"
},
"lint-staged": {
"*.js": ["eslint --fix", "git add"],
"*.{ts,md,json,yml}": ["prettier --write", "git add"],
".{eslintrc,travis.yml}": ["prettier --write", "git add"]
},
"prettier": {
"singleQuote": true,
"useTabs": true,
"overrides": [
{
"files": "*.md",
"options": {
"useTabs": false
}
},
{
"files": ".eslintrc",
"options": {
"parser": "json"
}
}
]
}
"name": "prom-client",
"version": "11.3.0",
"description": "Client for prometheus",
"main": "index.js",
"files": [
"lib/",
"index.js",
"index.d.ts"
],
"engines": {
"node": ">=6.1"
},
"scripts": {
"benchmarks": "node ./benchmarks/index.js",
"test": "npm run lint && npm run compile-typescript && npm run test-unit",
"lint": "eslint .",
"test-unit": "jest",
"compile-typescript": "tsc index.d.ts --noImplicitAny --target es6"
},
"repository": {
"type": "git",
"url": "git@github.com:siimon/prom-client.git"
},
"keywords": [
"Prometheus",
"Metrics",
"Client"
],
"author": "Simon Nyberg",
"license": "Apache-2.0",
"homepage": "https://github.com/siimon/prom-client",
"devDependencies": {
"@clevernature/benchmark-regression": "^1.0.0",
"eslint": "^5.6.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.1",
"express": "^4.13.3",
"husky": "^1.3.1",
"jest": "^23.6.0",
"lint-staged": "^7.0.0",
"lolex": "^3.0.0",
"prettier": "1.15.3",
"typescript": "^3.0.3"
},
"dependencies": {
"tdigest": "^0.1.1"
},
"types": "./index.d.ts",
"jest": {
"testEnvironment": "node",
"testRegex": ".*Test\\.js$"
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
],
"*.{ts,md,json,yml}": [
"prettier --write",
"git add"
],
".{eslintrc,travis.yml}": [
"prettier --write",
"git add"
]
},
"prettier": {
"singleQuote": true,
"useTabs": true,
"overrides": [
{
"files": "*.md",
"options": {
"useTabs": false
}
},
{
"files": ".eslintrc",
"options": {
"parser": "json"
}
}
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}

@@ -145,10 +145,2 @@ # Prometheus client for node.js [![Build Status](https://travis-ci.org/siimon/prom-client.svg?branch=master)](https://travis-ci.org/siimon/prom-client) [![Build status](https://ci.appveyor.com/api/projects/status/k2e0gwonkcee3lp9/branch/master?svg=true)](https://ci.appveyor.com/project/siimon/prom-client/branch/master)

A counter can be reset manually. This removes the label-values combinations and
initializes to 0.
```js
counter.reset();
counter.inc(); // Inc with 1 starting from 0
```
### Gauge

@@ -168,10 +160,2 @@

A gauge can be reset manually. This removes the label-values combinations and
initializes to 0.
```js
gauge.reset();
gauge.inc(); // Inc with 1 starting from 0
```
There are some utilities for common use cases:

@@ -238,9 +222,2 @@

A Histogram can be reset manually. This removes the label-values combinations
and reinitializes the observations.
```js
histogram.reset();
```
### Summary

@@ -301,9 +278,2 @@

A Summary can be reset manually. This removes the label-values combinations and
reinitializes the observations.
```js
summary.reset();
```
### Labels

@@ -310,0 +280,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc