diff --git a/lib/metrics.js b/lib/metrics.js index 9b7e3a5033..f88b13dc28 100644 --- a/lib/metrics.js +++ b/lib/metrics.js @@ -8,8 +8,10 @@ exports.startMonitoring = (enable, eventBus) => { } const client = require('prom-client'); + const gcStats = require('prometheus-gc-stats'); client.collectDefaultMetrics(); + gcStats()(); const requestDuration = new client.Summary({ name: 'http_request_duration_milliseconds', diff --git a/lib/metrics.test.js b/lib/metrics.test.js index 2918035c21..729984805f 100644 --- a/lib/metrics.test.js +++ b/lib/metrics.test.js @@ -19,6 +19,6 @@ test('should collect metrics for requests', t => { const metrics = prometheusRegister.metrics(); t.regex( metrics, - /http_request_duration_milliseconds{quantile="0.99",status="200",method="GET",path="somePath"} 1337/ + /http_request_duration_milliseconds{quantile="0\.99",path="somePath",method="GET",status="200"} 1337/ ); }); diff --git a/package.json b/package.json index 1eaba04ee9..76989de5ec 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,8 @@ "moment": "^2.15.2", "parse-database-url": "^0.3.0", "pg": "^6.4.2", - "prom-client": "^9.1.1", + "prom-client": "^10.0.4", + "prometheus-gc-stats": "^0.5.0", "response-time": "^2.3.2", "serve-favicon": "^2.3.0", "unleash-frontend": "^3.0.0-alpha.1", diff --git a/yarn.lock b/yarn.lock index 5ff96e8a9b..5e17ee737f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1974,6 +1974,13 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" +gc-stats@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/gc-stats/-/gc-stats-1.0.2.tgz#4d9ec98441e19888205452062ad6da30c9876e11" + dependencies: + nan "^2.6.2" + node-pre-gyp "^0.6.36" + generate-function@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" @@ -3172,7 +3179,7 @@ mute-stream@0.0.7, mute-stream@~0.0.4: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" -nan@^2.3.0: +nan@^2.3.0, nan@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" @@ -3371,6 +3378,10 @@ option-chain@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/option-chain/-/option-chain-1.0.0.tgz#938d73bd4e1783f948d34023644ada23669e30f2" +optional@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/optional/-/optional-0.1.4.tgz#cdb1a9bedc737d2025f690ceeb50e049444fd5b3" + optionator@^0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" @@ -3732,12 +3743,19 @@ progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" -prom-client@^9.1.1: - version "9.1.1" - resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-9.1.1.tgz#9588f1681a0869616c7de916ad33ae8f1e03fc10" +prom-client@^10.0.4: + version "10.0.4" + resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-10.0.4.tgz#c256473acafc65155009323721123490073d3173" dependencies: tdigest "^0.1.1" - util-extend "^1.0.1" + +prometheus-gc-stats@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/prometheus-gc-stats/-/prometheus-gc-stats-0.5.0.tgz#dce41ab205f1d7909f9ea605d85618126404a789" + dependencies: + optional "^0.1.3" + optionalDependencies: + gc-stats "^1.0.0" promise@^7.1.1: version "7.3.1" @@ -4919,10 +4937,6 @@ util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" -util-extend@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/util-extend/-/util-extend-1.0.3.tgz#a7c216d267545169637b3b6edc6ca9119e2ff93f" - utile@0.3.x: version "0.3.0" resolved "https://registry.yarnpkg.com/utile/-/utile-0.3.0.tgz#1352c340eb820e4d8ddba039a4fbfaa32ed4ef3a"