Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: siimon/prom-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v11.1.1
Choose a base ref
...
head repository: siimon/prom-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v11.1.2
Choose a head ref
  • 9 commits
  • 15 files changed
  • 7 contributors

Commits on Jul 6, 2018

  1. Updated README.md (#204)

    Improved readability for the visual impaired.
    Swivelgames authored and siimon committed Jul 6, 2018
    Copy the full SHA
    f651c41 View commit details

Commits on Aug 15, 2018

  1. Add getMetricsAsArray to index.d.ts (#211)

    CubeKap authored and SimenB committed Aug 15, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8d792aa View commit details
  2. adding prefix to DefaultMetricsCollectorConfiguration, related to the…

    … release v11.1.0. (#208)
    OscSer authored and SimenB committed Aug 15, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    SimenB Simen Bekkhus
    Copy the full SHA
    d5d8b7d View commit details

Commits on Aug 16, 2018

  1. Allow setting Gauge values to NaN. (#202)

    TimDumol authored and siimon committed Aug 16, 2018
    Copy the full SHA
    00f1b79 View commit details

Commits on Sep 17, 2018

  1. Remove Sinon dev dependency (#217)

    frankie567 authored and SimenB committed Sep 17, 2018
    Copy the full SHA
    7fd5477 View commit details
  2. chore: upgrade prettier (#218)

    This adds support for yaml and removes the silly newlines in `package{-lock}.json` to avoid conflicts with npm
    SimenB authored Sep 17, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    SimenB Simen Bekkhus
    Copy the full SHA
    6a71f47 View commit details

Commits on Sep 19, 2018

  1. Fix histogram scrape performance (#219)

    Fixes #216
    nowells authored and SimenB committed Sep 19, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    SimenB Simen Bekkhus
    Copy the full SHA
    45e0c3e View commit details
  2. prepare for 11.1.2

    SimenB committed Sep 19, 2018
    Copy the full SHA
    707bff9 View commit details
  3. 11.1.2

    SimenB committed Sep 19, 2018
    Copy the full SHA
    25255c3 View commit details
Showing with 1,040 additions and 1,848 deletions.
  1. +50 −43 CHANGELOG.md
  2. +23 −23 README.md
  3. +4 −4 appveyor.yml
  4. +6 −0 index.d.ts
  5. +3 −1 lib/counter.js
  6. +1 −1 lib/gauge.js
  7. +1 −1 lib/histogram.js
  8. +1 −0 lib/metrics/processOpenFileDescriptors.js
  9. +2 −1 lib/registry.js
  10. +18 −2 lib/util.js
  11. +827 −1,760 package-lock.json
  12. +24 −8 package.json
  13. +15 −0 test/gaugeTest.js
  14. +5 −4 test/metrics/processOpenFileDescriptorsTest.js
  15. +60 −0 test/registerTest.js
93 changes: 50 additions & 43 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -13,163 +13,170 @@ project adheres to [Semantic Versioning](http://semver.org/).

### Added

## [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

### Changed

* 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

## [11.0.0] - 2018-03-10

### Breaking

* 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

## [10.2.3] - 2018-02-28

### Breaking

### Changed

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

### Added

## [10.2.2] - 2017-11-02

### Changed

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

## [10.2.1] - 2017-10-27

### Changed

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

## [10.2.0] - 2017-10-16

### Changed

* 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

## [10.1.1] - 2017-09-26

### Changed

* 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

## [10.1.0] - 2017-09-04

### Added

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

## [10.0.4] - 2017-08-22

### Changed

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

## [10.0.3] - 2017-08-07

### Added

* 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

## [10.0.2] - 2017-07-07

### Changed

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

## [10.0.1] - 2017-07-06

### Added

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

## [10.0.0] - 2017-07-04

### Breaking

* 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

### Changed

* 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`

## [9.1.1] - 2017-06-17

### Changed

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

## [9.1.0] - 2017-06-07

### Added

* Ability to merge registries
- Ability to merge registries

### Changed

* Correct typedefs for object constructor of metrics
- Correct typedefs for object constructor of metrics

## [9.0.0] - 2017-05-06

### Added

* 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()`.

### Deprecated

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

[unreleased]: https://github.com/siimon/prom-client/compare/v10.2.2...HEAD
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,13 +3,13 @@
A prometheus client for node.js that supports histogram, summaries, gauges and
counters.

### Usage
## Usage

See example folder for a sample usage. The library does not bundle any web
framework, to expose the metrics just return the `metrics()` function in the
registry.

#### Usage with Node.js's `cluster` module
### Usage with Node.js's `cluster` module

Node.js's `cluster` module spawns multiple processes and hands off socket
connections to those workers. Returning metrics from a worker's local registry
@@ -32,13 +32,13 @@ registry, call
`client.AggregatorRegistry.setRegistries(registryOrArrayOfRegistries)` from the
worker processes.

### API
## API

#### Configuration
### Configuration

All metric types has 2 mandatory parameters, name and help.

#### Default metrics
### Default metrics

There are some default metrics recommended by Prometheus
[itself](https://prometheus.io/docs/instrumenting/writing_clientlibs/#standard-and-runtime-collectors).
@@ -114,7 +114,7 @@ NOTE: `unref` is called on the `interval` internally, so it will not keep your
node process going indefinitely if it's the only thing keeping it from shutting
down.

##### Stop polling default metrics
#### Stop polling default metrics

To stop collecting the default metrics, you have to call the function and pass
it to `clearInterval`.
@@ -128,7 +128,7 @@ clearInterval(client.collectDefaultMetrics());
client.register.clear();
```

#### Counter
### Counter

Counters go up, and reset when the process restarts.

@@ -150,7 +150,7 @@ counter.reset();
counter.inc(); // Inc with 1 starting from 0
```

#### Gauge
### Gauge

Gauges are similar to Counters but Gauges value can be decreased.

@@ -183,7 +183,7 @@ xhrRequest(function(err, res) {
});
```

#### Histogram
### Histogram

Histograms track sizes and frequency of events.

@@ -240,7 +240,7 @@ and reinitializes the observations.
histogram.reset();
```

#### Summary
### Summary

Summaries calculate percentiles of observed values.

@@ -285,7 +285,7 @@ reinitializes the observations.
summary.reset();
```

#### Labels
### Labels

All metrics can take a labelNames property in the configuration object. All
labelNames that the metric support needs to be declared here. There are 2 ways
@@ -317,7 +317,7 @@ xhrRequest(function(err, res) {
});
```

##### Default Labels (segmented by registry)
#### Default Labels (segmented by registry)

Static labels may be applied to every metric emitted by a registry:

@@ -339,7 +339,7 @@ Default labels will be overridden if there is a name conflict.

`register.clear()` will clear default labels.

#### Timestamps
### Timestamps

Counter and gauge metrics can take a timestamp argument after the value
argument. This argument must be a Date or a number (milliseconds since Unix
@@ -355,7 +355,7 @@ gauge.labels('GET', '200').set(100, new Date()); // Same as above
counter.inc(1, new Date()); // Increment counter with timestamp
```

#### Multiple registries
### Multiple registries

By default, metrics are automatically registered to the global registry (located
at `require('prom-client').register`). You can prevent this by setting last
@@ -399,37 +399,37 @@ AggregatorRegistry.setRegistries(registry);
AggregatorRegistry.setRegistries([registry1, registry2]);
```

#### Register
### Register

You can get all metrics by running `register.metrics()`, which will output a
string for prometheus to consume.

`register.metrics()` takes an optional object with a `timestamps` field. Setting
this to false will strip timestamps from the string.

##### Getting a single metric for Prometheus displaying
#### Getting a single metric for Prometheus displaying

If you need to output a single metric for Prometheus, you can use
`register.getSingleMetricAsString(*name of metric*)`, it will output a string
for Prometheus to consume.

##### Getting a single metric
#### Getting a single metric

If you need to get a reference to a previously registered metric, you can use
`register.getSingleMetric(*name of metric*)`.

##### Removing metrics
#### Removing metrics

You can remove all metrics by calling `register.clear()`. You can also remove a
single metric by calling `register.removeSingleMetric(*name of metric*)`.

##### Resetting metrics
#### Resetting metrics

If you need to reset all metrics, you can use `register.resetMetrics()`. The
metrics will remain present in the register and can be used without the need to
instantiate them again, like you would need to do after `register.clear()`.

##### Cluster metrics
#### Cluster metrics

You can get aggregated metrics for all workers in a node.js cluster with
`register.clusterMetrics()`. This method both returns a promise and accepts a
@@ -453,7 +453,7 @@ register.clusterMetrics((err, metrics) => {
});
```

#### Pushgateway
### Pushgateway

It is possible to push metrics via a
[Pushgateway](https://github.com/prometheus/pushgateway).
@@ -480,7 +480,7 @@ gateway.pushAdd({ jobName: 'test', groupings: { key: 'value' } }, function(
gateway = new client.Pushgateway('http://127.0.0.1:9091', { timeout: 5000 }); //Set the request timeout to 5000ms
```

#### Utilites
### Utilites

For convenience, there are 2 bucket generator functions - linear and
exponential.
@@ -503,7 +503,7 @@ new client.Histogram({
The content-type prometheus expects is also exported as a constant, both on the
`register` and from the main file of this project, called `contentType`.

### 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
Loading