prom-client
Advanced tools
Comparing version 11.1.1 to 11.1.2
@@ -16,2 +16,9 @@ # Changelog | ||
## [11.1.2] - 2018-09-19 | ||
### Changed | ||
- 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 | ||
## [11.1.1] - 2018-06-29 | ||
@@ -21,14 +28,14 @@ | ||
* 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 | ||
@@ -39,6 +46,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 | ||
@@ -51,3 +58,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 | ||
@@ -60,3 +67,3 @@ ### Added | ||
* Fixed invalid `process_virtual_memory_bytes` reported under linux | ||
- Fixed invalid `process_virtual_memory_bytes` reported under linux | ||
@@ -67,3 +74,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 | ||
@@ -74,9 +81,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 | ||
@@ -87,4 +94,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 | ||
@@ -95,3 +102,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. | ||
@@ -102,3 +109,3 @@ ## [10.0.4] - 2017-08-22 | ||
* Include invalid values in the error messages | ||
- Include invalid values in the error messages | ||
@@ -109,8 +116,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 | ||
@@ -121,3 +128,3 @@ ## [10.0.2] - 2017-07-07 | ||
* Don't poll default metrics every single tick | ||
- Don't poll default metrics every single tick | ||
@@ -128,3 +135,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 | ||
@@ -135,9 +142,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 | ||
@@ -147,9 +154,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` | ||
@@ -160,3 +167,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 | ||
@@ -167,7 +174,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 | ||
@@ -178,9 +185,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()`. | ||
@@ -190,3 +197,3 @@ | ||
* Creating metrics with one argument per parameter - use object literals | ||
- Creating metrics with one argument per parameter - use object literals | ||
instead. | ||
@@ -193,0 +200,0 @@ |
@@ -45,2 +45,7 @@ // Type definitions for prom-client | ||
/** | ||
* Get all metrics as objects | ||
*/ | ||
getMetricsAsArray(): metric[]; | ||
/** | ||
* Remove a single metric | ||
@@ -618,2 +623,3 @@ * @param name The name of the metric to remove | ||
register?: Registry; | ||
prefix?: string; | ||
} | ||
@@ -620,0 +626,0 @@ |
@@ -159,3 +159,5 @@ /** | ||
? timestamp.valueOf() | ||
: Number.isFinite(timestamp) ? timestamp : undefined; | ||
: Number.isFinite(timestamp) | ||
? timestamp | ||
: undefined; | ||
if (hashMap[hash]) { | ||
@@ -162,0 +164,0 @@ hashMap[hash].value += value; |
@@ -218,3 +218,3 @@ /** | ||
return (value, timestamp) => { | ||
if (!Number.isFinite(value)) { | ||
if (typeof value !== 'number') { | ||
throw new TypeError(`Value is not a valid number: ${util.format(value)}`); | ||
@@ -221,0 +221,0 @@ } |
@@ -291,3 +291,3 @@ /** | ||
return (acc, d) => { | ||
acc = acc.concat(d.buckets); | ||
acc.push(...d.buckets); | ||
@@ -294,0 +294,0 @@ const infLabel = Object.assign({ le: '+Inf' }, d.data.labels); |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const fs = require('fs'); | ||
const process = require('process'); | ||
@@ -7,0 +8,0 @@ const PROCESS_OPEN_FDS = 'process_open_fds'; |
'use strict'; | ||
const getValueAsString = require('./util').getValueAsString; | ||
@@ -47,3 +48,3 @@ function escapeString(str) { | ||
const line = [metricName, val.value]; | ||
const line = [metricName, getValueAsString(val.value)]; | ||
if (opts.timestamps) { | ||
@@ -50,0 +51,0 @@ line.push(val.timestamp); |
@@ -12,10 +12,26 @@ 'use strict'; | ||
exports.getValueAsString = function getValueString(value) { | ||
if (Number.isNaN(value)) { | ||
return 'Nan'; | ||
} else if (!Number.isFinite(value)) { | ||
if (value < 0) { | ||
return '-Inf'; | ||
} else { | ||
return '+Inf'; | ||
} | ||
} else { | ||
return `${value}`; | ||
} | ||
}; | ||
exports.setValue = function setValue(hashMap, value, labels, timestamp) { | ||
const hash = hashObject(labels); | ||
hashMap[hash] = { | ||
value: Number.isFinite(value) ? value : 0, | ||
value: typeof value === 'number' ? value : 0, | ||
labels: labels || {}, | ||
timestamp: isDate(timestamp) | ||
? timestamp.valueOf() | ||
: Number.isFinite(timestamp) ? timestamp : undefined | ||
: Number.isFinite(timestamp) | ||
? timestamp | ||
: undefined | ||
}; | ||
@@ -22,0 +38,0 @@ return hashMap; |
{ | ||
"name": "prom-client", | ||
"version": "11.1.1", | ||
"version": "11.1.2", | ||
"description": "Client for prometheus", | ||
"main": "index.js", | ||
"files": ["lib/", "index.js", "index.d.ts"], | ||
"files": [ | ||
"lib/", | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"engines": { | ||
@@ -21,3 +25,7 @@ "node": ">=6" | ||
}, | ||
"keywords": ["Prometheus", "Metrics", "Client"], | ||
"keywords": [ | ||
"Prometheus", | ||
"Metrics", | ||
"Client" | ||
], | ||
"author": "Simon Nyberg", | ||
@@ -34,4 +42,3 @@ "license": "Apache-2.0", | ||
"lolex": "^2.1.3", | ||
"prettier": "1.11.1", | ||
"sinon": "^6.0.1", | ||
"prettier": "1.14.2", | ||
"typescript": "^2.5.2" | ||
@@ -48,5 +55,14 @@ }, | ||
"lint-staged": { | ||
"*.js": ["eslint --fix", "git add"], | ||
"*.{ts,md,json}": ["prettier --write", "git add"], | ||
".eslintrc": ["prettier --write", "git add"] | ||
"*.js": [ | ||
"eslint --fix", | ||
"git add" | ||
], | ||
"*.{ts,md,json,yml}": [ | ||
"prettier --write", | ||
"git add" | ||
], | ||
".{eslintrc,travis.yml}": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
}, | ||
@@ -53,0 +69,0 @@ "prettier": { |
@@ -6,3 +6,3 @@ # 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) | ||
### Usage | ||
## Usage | ||
@@ -13,3 +13,3 @@ See example folder for a sample usage. The library does not bundle any web | ||
#### Usage with Node.js's `cluster` module | ||
### Usage with Node.js's `cluster` module | ||
@@ -37,9 +37,9 @@ Node.js's `cluster` module spawns multiple processes and hands off socket | ||
### API | ||
## API | ||
#### Configuration | ||
### Configuration | ||
All metric types has 2 mandatory parameters, name and help. | ||
#### Default metrics | ||
### Default metrics | ||
@@ -120,3 +120,3 @@ There are some default metrics recommended by Prometheus | ||
##### Stop polling default metrics | ||
#### Stop polling default metrics | ||
@@ -135,3 +135,3 @@ To stop collecting the default metrics, you have to call the function and pass | ||
#### Counter | ||
### Counter | ||
@@ -158,3 +158,3 @@ Counters go up, and reset when the process restarts. | ||
#### Gauge | ||
### Gauge | ||
@@ -192,3 +192,3 @@ Gauges are similar to Counters but Gauges value can be decreased. | ||
#### Histogram | ||
### Histogram | ||
@@ -250,3 +250,3 @@ Histograms track sizes and frequency of events. | ||
#### Summary | ||
### Summary | ||
@@ -296,3 +296,3 @@ Summaries calculate percentiles of observed values. | ||
#### Labels | ||
### Labels | ||
@@ -329,3 +329,3 @@ All metrics can take a labelNames property in the configuration object. All | ||
##### Default Labels (segmented by registry) | ||
#### Default Labels (segmented by registry) | ||
@@ -352,3 +352,3 @@ Static labels may be applied to every metric emitted by a registry: | ||
#### Timestamps | ||
### Timestamps | ||
@@ -369,3 +369,3 @@ Counter and gauge metrics can take a timestamp argument after the value | ||
#### Multiple registries | ||
### Multiple registries | ||
@@ -414,3 +414,3 @@ By default, metrics are automatically registered to the global registry (located | ||
#### Register | ||
### Register | ||
@@ -423,3 +423,3 @@ You can get all metrics by running `register.metrics()`, which will output a | ||
##### Getting a single metric for Prometheus displaying | ||
#### Getting a single metric for Prometheus displaying | ||
@@ -430,3 +430,3 @@ If you need to output a single metric for Prometheus, you can use | ||
##### Getting a single metric | ||
#### Getting a single metric | ||
@@ -436,3 +436,3 @@ If you need to get a reference to a previously registered metric, you can use | ||
##### Removing metrics | ||
#### Removing metrics | ||
@@ -442,3 +442,3 @@ You can remove all metrics by calling `register.clear()`. You can also remove a | ||
##### Resetting metrics | ||
#### Resetting metrics | ||
@@ -449,3 +449,3 @@ If you need to reset all metrics, you can use `register.resetMetrics()`. The | ||
##### Cluster metrics | ||
#### Cluster metrics | ||
@@ -474,3 +474,3 @@ You can get aggregated metrics for all workers in a node.js cluster with | ||
#### Pushgateway | ||
### Pushgateway | ||
@@ -502,3 +502,3 @@ It is possible to push metrics via a | ||
#### Utilites | ||
### Utilites | ||
@@ -526,5 +526,5 @@ For convenience, there are 2 bucket generator functions - linear and | ||
### Garbage Collection | ||
## Garbage Collection | ||
To avoid dependencies in this module, GC stats are kept outside of it. If you | ||
want GC stats, you can use https://github.com/SimenB/node-prometheus-gc-stats |
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
105857
9
2572