All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- Drop support for Node.js versions 16, 18, 21 and 23
- Metric internal storage ('hashMap') changed to a separate object, LabelMap. If you have subclassed the built-in metric types you may need to adjust your code.
- Improve types for no labels
- perf: Faster stats gathering with lower memory overhead
- Simplified number format logic
- Simplified Histogram.observe() call stack
- Fix memory leak in cluster.js by deleting all expired requests
- perf: Sped up Map accesses
- perf: Remove truthy conditionals in hot code paths
- Show the invalid name in the validation errors
- perf: Improve performance of registry defaultLabels during metric processing
- perf: New, more space-efficient storage engine, 20-45% faster stats recording
- perf: Further improvement to key generation cost
- fix: Browser compatibility for Gauge.startTimer()
- ci: Run benchmarks for pull requests
- ci: switch out deprecated benchmark-regression library for replacement
- AggregatorRegistry renamed to ClusterRegistry, old name deprecated
- chore: update faceoff to 1.1
- Expanded benchmarking code
- new WorkerRegistry to provide equivalent support to AggregatorRegistry
- Improve error message when number of registered labels mismatch with the number of labels provided
- Add
Registry.PROMETHEUS_CONTENT_TYPEandRegistry.OPENMETRICS_CONTENT_TYPEconstants to the TypeScript types - Correctly read and set
contentTypetop level export
- Enable
bun.jsby catchingNotImplementederror (Fixes #570)
- Improve the memory usage of histograms when the
enableExemplarsoption is disabled - fix: Avoid updating exemplar values during subsequent metric changes (Fixes #616)
15.1.0 - 2023-12-15
- remove unnecessary loop from
osMemoryHeapLinux - Improve performance of
hashObjectby using pre-sorted array of label names - Fix type of
collectDefaultMetrics.metricsList
- Allow Pushgateway to now require job names for compatibility with Gravel Gateway.
- Allow
histogram.startTime()to be used with exemplars.
15.0.0 - 2023-10-09
- drop support for Node.js versions 10, 12, 14, 17 and 19
- Refactor histogram internals and provide a fast path for rendering metrics to Prometheus strings when there are many labels shared across different values.
- Disable custom content encoding for pushgateway delete requests in order to
avoid failures from the server when using
Content-Encoding: gzipheader. - Refactor
escapeStringhelper inlib/registry.jsto improve performance and avoid an unnecessarily complex regex. - Cleanup code and refactor to be more efficient
- Correct TS types for working with OpenMetrics
- Updated Typescript and Readme docs for
setToCurrentTime()to reflect units as seconds. - Do not ignore error if request to pushgateway fails
- Make sure to reject the request to pushgateway if it times out
- Support for OpenMetrics and Exemplars
14.2.0 - 2023-03-06
- Refactor
getMetricAsPrometheusStringmethod in theRegistryclass to useArray.prototype.joininstead of loop of string concatenations. - Also use
Array.prototype.map, and object spread instead of an explicitforloop - changed: updated the sample output in
example/default-metrics.js summarymetrics now has apruneAgedBucketsconfig parameter to remove entries without any new values in the lastmaxAgeSeconds. Default isfalse(old behavior)
- Add
getmethod to type definitions of metric classes
14.1.1 - 2022-12-31
- Increase compatibility with external build system such as
rollupby making perf_hooks optional in gc.js
14.1.0 - 2022-08-23
-
types: converted all the generic Metric types to be optional
-
The
done()functions returned bygauge.startTimer()andsummary.startTimer()now return the timed duration. Histograms already had this behavior. -
types: fixed type for
registry.getMetricsAsArray() -
Improve performance of
gague.inc()andgauge.dec()by callinghashObject()once.
-
The
processResourcesmetric was added, which keeps a track of all sorts of active resources. It consists of the following gauges:nodejs_active_resources- Number of active resources that are currently keeping the event loop alive, grouped by async resource type.nodejs_active_resources_total- Total number of active resources. It is supposed to provide the combined result of theprocessHandlesandprocessRequestsmetrics along with information about any other types of async resources that these metrics do not keep a track of (like timers).
-
Support gzipped pushgateway requests
14.0.1 - 2021-11-02
- changed: typedef for pushgateway to reflect js implementation.
14.0.0 - 2021-09-18
-
changed:
linearBucketsdoes not propagate rounding errors anymore.Fewer bucket bounds will be affected by rounding errors. Histogram bucket labels may change.
6f1f3b2 -
changed: The push gateway methods
pushAdd(),push()anddelete()now return Promises instead of accepting a callback:// Old: gateway.pushAdd({ jobName: 'test' }, (err, resp, body) => {}); // New: gateway .pushAdd({ jobName: 'test' }) .then(({ resp, body }) => {}) .catch(err => {}); // or const { resp, body } = await gateway.pushAdd({ jobName: 'test' });
-
changed: The default
nodejs_eventloop_lag_*metrics are now reset every time they are observed. This prevents these metrics from "stabilizing" over a long period of time and becoming insensitive to small changes. For more info, see #370.0f444cd
- Add missing
await/thens to examples.074f339 - Add missing type declaration for
client.contentType.3b66641 - Modernize some label processing code.
c9bf1d8
13.2.0 - 2021-08-08
- Don't add event listener to
processif cluster module is not used. - fix: set labels for default memory metrics on linux.
- fix: fix DEP0152 deprecation warning in Node.js v16+.
- fix: Set aggregation mode for newer event loop metrics. (Fixes #418)
- Improve performance of/reduce memory allocations in Gauge.
- feat: added
zero()toHistogramfor setting the metrics for a given label combination to zero - fix: allow
Gauge.inc/dec(0)without defaulting to 1
13.1.0 - 2021-01-24
- fix: push client attempting to write Promise (fixes #390)
- types: improve type checking of labels
- fix: Summary#observe should throw when adding additional labels to labelset (fixes #262)
- feat: added the ability to pass labels as an object to
labels()andremove() - Added: More examples with commented output
13.0.0 - 2020-12-16
-
changed: The following functions are now async (return a promise):
registry.metrics()registry.getMetricsAsJSON()registry.getMetricsAsArray()registry.getSingleMetricAsString()If your metrics server has a line like
res.send(register.metrics()), you should change it tores.send(await register.metrics()).Additionally, all metric types now accept an optional
collectfunction, which is called when the metric's value should be collected and within which you should set the metric's value. You should provide acollectfunction for point-in-time metrics (e.g. current memory usage, as opposed to HTTP request durations that are continuously logged in a histogram). -
changed:
register.clusterMetrics()no longer accepts a callback; it only returns a promise. -
removed: v12.0.0 added the undocumented functions
registry.registerCollectorandregistry.collectors(). These have been removed. If you were using them, you should instead provide acollectfunction as described above.
- fix: provide nodejs_version_info metric value after calling
registry.resetMetrics()(#238) - fix: provide process_max_fds metric value after calling
registry.resetMetrics() - fix: provide process_start_time_seconds metric value after calling
registry.resetMetrics() - chore: improve performance of
registry.getMetricAsPrometheusString - chore: refactor metrics to reduce code duplication
- chore: replace
utils.getPropertiesFromObjwithObject.values - chore: remove unused
catchbindings - chore: upgrade Prettier to 2.x
- fix: startTimer returns
numberin typescript instead ofvoid - fix: incorrect typings of `registry.getSingleMetric' (#388)
- chore: stop testing node v13 on CI
- feat: exposed
registry.registerCollector()andregistry.collectors()methods in TypeScript declaration - Added: complete working example of a pushgateway push in
example/pushgateway.js - feat: added support for adding labels to default metrics (#374)
- Added CHANGELOG reminder
12.0.0 - 2020-02-20
- Dropped support for end-of-life Node.js versions 6.x and 8.x
- Dropped the previously deprecated support for positional parameters in constructors, only the config object forms remain.
- Default metrics are collected on scrape of metrics endpoint, not on an
interval. The
timeoutoption tocollectDefaultMetrics(conf)is no longer supported or needed, and the function no longer returns aTimeoutobject.
- chore: remove ignored package-lock.json
- fix:
process_max_fdsis process limit, not OS (#314) - Changed
MetriclabelNames & labelValues in TypeScript declaration to a generic typeT extends string, instead ofstring - Lazy-load Node.js Cluster module to fix Passenger support (#293)
- fix: avoid mutation bug in
registry.getMetricsAsJSON() - fix: improve performance of
registry.getMetrics* - End function of histogram
startTimer, when invoked returns the number of seconds - chore: reindent package.json
- chore: correct var name in processStartTime
- chore: add test for
process_start_time_seconds - chore: spelling corrections in README
- feat: implement GC metrics collection without native(C++) modules.
- feat: implement advanced event loop monitoring
11.5.3 - 2019-06-27
- Parameter
compressCountin Summaries to control compression of data in t-digest. - Compress t-digest in Summaries
11.5.2 - 2019-06-20
- fix: avoid mutation bug in registry
11.5.1 - 2019-06-13
- fix: guard against missing constructor
11.5.0 - 2019-06-04
- Added
timestampstoggle tocollectDefaultMetricsoptions - Export
validateMetricName
11.4.0 - 2019-06-04
nodejs_active_handlesmetric to thecollectDefaultMetrics(). Unlikenodejs_active_handles_totalit split count of active handles by type.nodejs_active_requestsmetric to thecollectDefaultMetrics(). Unlikenodejs_active_requests_totalit split count of active requests by type.
11.3.0 - 2019-04-02
- Check that cluster worker is still connected before attempting to query it for metrics. (#244)
- Added a
remove()method on each metric type, based on Prometheus "Writing Client Libraries" section on labels
- Updated types for Summary in typescript definition file
- Updated child dependency
mergepatch version to remove vulnerability.
- Added an initial
benchmarksuite which can be run withnpm run benchmarks. - Add support for sliding windows in Summaries
11.1.3 - 2018-09-22
- Fixed performance by avoiding
Object.assignon hot paths, as well as mutating objects when appropriate.
11.1.2 - 2018-09-19
- Allow setting Gauge values to NaN, +Inf, and -Inf
- Fixed
histogramscrape performance by usingacc.pushinstead ofacc.concat. Fixes #216 with #219
11.1.1 - 2018-06-29
- Fixed
processOpenFileDescriptorsmetric when no custom config was set
11.1.0 - 2018-06-29
- Added ability to set a name prefix in the default metrics
- Fixed
startTimerutility to not mutate objects passed asstartLabels - Fixed
Counterto validate labels parameter ofinc()against initial labelset - Fixed
AggregatorFactorylosing the aggregator method of metrics
11.0.0 - 2018-03-10
- Fixed
gauge.setToCurrentTime()to use seconds instead of milliseconds- This conforms to Prometheus best practices
- Dropped support for node 4
10.2.3 - 2018-02-28
- Fixed issue that
registry.getMetricsAsJSON()ignores registry default labels
10.2.2 - 2017-11-02
- Fixed invalid
process_virtual_memory_bytesreported under linux
10.2.1 - 2017-10-27
- Only resolve/reject
clusterMetricspromise if no callback is provided
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
- Added
resetto Counter and Gauge - Added
resetMetricsto register to callingresetof all metric instances
10.1.1 - 2017-09-26
- Update TypeScript definitions and JSDoc comments to match JavaScript sources
- Fix lexical scope of
argumentsin cluster code
10.1.0 - 2017-09-04
- Support aggregating metrics across workers in a Node.js cluster.
10.0.4 - 2017-08-22
- Include invalid values in the error messages
10.0.3 - 2017-08-07
- Added registerMetric to definitions file
- Fixed typing of DefaultMetricsCollectorConfiguration in definitions file
- Don't pass timestamps through to pushgateway by default
10.0.2 - 2017-07-07
- Don't poll default metrics every single tick
10.0.1 - 2017-07-06
- Metrics should be initialized to 0 when there are no labels
10.0.0 - 2017-07-04
- Print deprecation warning when metrics are constructed using non-objects
- Print deprecation warning when
collectDefaultMetricsis called with a number
- Ability to set default labels by registry
- Allow passing in
registryas second argument tocollectDefaultMetricsto use that instead of the default registry
- Convert code base to ES2015 code (node 4)
- add engines field to package.json
- Use object shorthand
- Remove
util-extendin favor ofObject.assign - Arrow functions over binding or putting
thisin a variable - Use template strings
prototype->class
9.1.1 - 2017-06-17
- Don't set timestamps for metrics that are never updated
9.1.0 - 2017-06-07
- Ability to merge registries
- Correct typedefs for object constructor of metrics
9.0.0 - 2017-05-06
- Support for multiple registers
- Support for object literals in metric constructors
- Timestamp support
- Collection of default metrics is now disabled by default. Start collection by
running
collectDefaultMetrics().
- Creating metrics with one argument per parameter - use object literals instead.