prom-client
Advanced tools
Comparing version 11.4.0 to 11.5.0
@@ -16,2 +16,9 @@ # Changelog | ||
## [11.5.0] - 2019-06-04 | ||
### Added | ||
- Added `timestamps` toggle to `collectDefaultMetrics` options | ||
- Export `validateMetricName` | ||
## [11.4.0] - 2019-06-04 | ||
@@ -18,0 +25,0 @@ |
@@ -647,2 +647,3 @@ // Type definitions for prom-client | ||
timeout?: number; | ||
timestamps?: boolean; | ||
register?: Registry; | ||
@@ -659,3 +660,3 @@ prefix?: string; | ||
config?: DefaultMetricsCollectorConfiguration | ||
): number; | ||
): ReturnType<typeof setInterval>; | ||
@@ -676,1 +677,8 @@ /** | ||
} | ||
/** | ||
* Validate a metric name | ||
* @param name The name to validate | ||
* @return True if the metric name is valid, false if not | ||
*/ | ||
export function validateMetricName(name: string): boolean; |
@@ -11,2 +11,3 @@ /** | ||
exports.contentType = require('./lib/registry').globalRegistry.contentType; | ||
exports.validateMetricName = require('./lib/validation').validateMetricName; | ||
@@ -13,0 +14,0 @@ exports.Counter = require('./lib/counter'); |
@@ -45,3 +45,9 @@ 'use strict'; | ||
normalizedConfig = Object.assign({ timeout: 10000 }, normalizedConfig); | ||
normalizedConfig = Object.assign( | ||
{ | ||
timestamps: true, | ||
timeout: 10000 | ||
}, | ||
normalizedConfig | ||
); | ||
@@ -61,3 +67,3 @@ if (existingInterval !== null) { | ||
return defaultMetric(normalizedConfig.register, config); | ||
return defaultMetric(normalizedConfig.register, normalizedConfig); | ||
}); | ||
@@ -64,0 +70,0 @@ |
@@ -43,7 +43,15 @@ 'use strict'; | ||
if (memUsage) { | ||
const now = Date.now(); | ||
heapSizeTotal.set(memUsage.heapTotal, now); | ||
heapSizeUsed.set(memUsage.heapUsed, now); | ||
if (memUsage.external && externalMemUsed) { | ||
externalMemUsed.set(memUsage.external, now); | ||
if (config.timestamps) { | ||
const now = Date.now(); | ||
heapSizeTotal.set(memUsage.heapTotal, now); | ||
heapSizeUsed.set(memUsage.heapUsed, now); | ||
if (memUsage.external && externalMemUsed) { | ||
externalMemUsed.set(memUsage.external, now); | ||
} | ||
} else { | ||
heapSizeTotal.set(memUsage.heapTotal); | ||
heapSizeUsed.set(memUsage.heapUsed); | ||
if (memUsage.external && externalMemUsed) { | ||
externalMemUsed.set(memUsage.external); | ||
} | ||
} | ||
@@ -50,0 +58,0 @@ } |
@@ -16,6 +16,10 @@ 'use strict'; | ||
function updateMetrics(gauge, data) { | ||
function updateMetrics(gauge, data, includeTimestamp) { | ||
gauge.reset(); | ||
for (const key in data) { | ||
gauge.set({ type: key }, data[key], Date.now()); | ||
if (includeTimestamp) { | ||
gauge.set({ type: key }, data[key], Date.now()); | ||
} else { | ||
gauge.set({ type: key }, data[key]); | ||
} | ||
} | ||
@@ -22,0 +26,0 @@ } |
@@ -31,7 +31,15 @@ 'use strict'; | ||
return () => { | ||
const handles = process._getActiveHandles(); | ||
updateMetrics(gauge, aggregateByObjectName(handles)); | ||
totalGauge.set(handles.length, Date.now()); | ||
}; | ||
const updater = config.timestamps | ||
? () => { | ||
const handles = process._getActiveHandles(); | ||
updateMetrics(gauge, aggregateByObjectName(handles), true); | ||
totalGauge.set(handles.length, Date.now()); | ||
} | ||
: () => { | ||
const handles = process._getActiveHandles(); | ||
updateMetrics(gauge, aggregateByObjectName(handles), false); | ||
totalGauge.set(handles.length); | ||
}; | ||
return updater; | ||
}; | ||
@@ -38,0 +46,0 @@ |
{ | ||
"name": "prom-client", | ||
"version": "11.4.0", | ||
"version": "11.5.0", | ||
"description": "Client for prometheus", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
"test-unit": "jest", | ||
"compile-typescript": "tsc index.d.ts --noImplicitAny --target es6" | ||
"compile-typescript": "tsc --project ." | ||
}, | ||
@@ -37,2 +37,3 @@ "repository": { | ||
"eslint": "^5.6.0", | ||
"eslint-config-prettier": "^4.3.0", | ||
"eslint-plugin-node": "^8.0.0", | ||
@@ -42,6 +43,6 @@ "eslint-plugin-prettier": "^3.0.1", | ||
"husky": "^1.3.1", | ||
"jest": "^23.6.0", | ||
"jest": "^24.8.0", | ||
"lint-staged": "^7.0.0", | ||
"lolex": "^3.0.0", | ||
"prettier": "1.15.3", | ||
"lolex": "^4.0.1", | ||
"prettier": "1.17.1", | ||
"typescript": "^3.0.3" | ||
@@ -48,0 +49,0 @@ }, |
@@ -91,2 +91,13 @@ # 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) | ||
To disable metric timestamps set `timestamps` to `false` (You can find the list of metrics that support this feature in `test/defaultMetricsTest.js`): | ||
```js | ||
const client = require('prom-client'); | ||
const collectDefaultMetrics = client.collectDefaultMetrics; | ||
// Probe every 5th second. | ||
collectDefaultMetrics({ timestamps: false }); | ||
``` | ||
You can get the full list of metrics by inspecting | ||
@@ -93,0 +104,0 @@ `client.collectDefaultMetrics.metricsList`. |
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
112364
2783
508
12