From ea6183f79c864245963e961edf08120d51d39e20 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Thu, 4 Feb 2021 13:20:10 +0100 Subject: [PATCH] fix: upgrade prom-client from 12.0.0 to 13.1.0 --- lib/metrics.test.js | 20 ++++++++++---------- lib/routes/backstage.js | 6 ++++-- package.json | 2 +- yarn.lock | 8 ++++---- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/metrics.test.js b/lib/metrics.test.js index 27b0ec9427..74dad47d29 100644 --- a/lib/metrics.test.js +++ b/lib/metrics.test.js @@ -34,7 +34,7 @@ test.after(() => { monitor.stopMonitoring(); }); -test('should collect metrics for requests', t => { +test('should collect metrics for requests', async t => { eventBus.emit(REQUEST_TIME, { path: 'somePath', method: 'GET', @@ -42,23 +42,23 @@ test('should collect metrics for requests', t => { time: 1337, }); - const metrics = prometheusRegister.metrics(); + const metrics = await prometheusRegister.metrics(); t.regex( metrics, /http_request_duration_milliseconds{quantile="0\.99",path="somePath",method="GET",status="200"} 1337/, ); }); -test('should collect metrics for updated toggles', t => { +test('should collect metrics for updated toggles', async t => { eventStore.emit(FEATURE_UPDATED, { data: { name: 'TestToggle' }, }); - const metrics = prometheusRegister.metrics(); + const metrics = await prometheusRegister.metrics(); t.regex(metrics, /feature_toggle_update_total{toggle="TestToggle"} 1/); }); -test('should collect metrics for client metric reports', t => { +test('should collect metrics for client metric reports', async t => { clientMetricsStore.emit('metrics', { bucket: { toggles: { @@ -70,28 +70,28 @@ test('should collect metrics for client metric reports', t => { }, }); - const metrics = prometheusRegister.metrics(); + const metrics = await prometheusRegister.metrics(); t.regex( metrics, /feature_toggle_usage_total{toggle="TestToggle",active="true",appName="undefined"} 10\nfeature_toggle_usage_total{toggle="TestToggle",active="false",appName="undefined"} 5/, ); }); -test('should collect metrics for db query timings', t => { +test('should collect metrics for db query timings', async t => { eventBus.emit(DB_TIME, { store: 'foo', action: 'bar', time: 0.1337, }); - const metrics = prometheusRegister.metrics(); + const metrics = await prometheusRegister.metrics(); t.regex( metrics, /db_query_duration_seconds{quantile="0\.99",store="foo",action="bar"} 0.1337/, ); }); -test('should collect metrics for feature toggle size', t => { - const metrics = prometheusRegister.metrics(); +test('should collect metrics for feature toggle size', async t => { + const metrics = await prometheusRegister.metrics(); t.regex(metrics, /feature_toggles_total{version="(.*)"} 123/); }); diff --git a/lib/routes/backstage.js b/lib/routes/backstage.js index cc91d06072..8d6cba43b3 100644 --- a/lib/routes/backstage.js +++ b/lib/routes/backstage.js @@ -7,10 +7,12 @@ class BackstageController extends Controller { constructor(config) { super(); + this.logger = config.getLogger('backstage.js'); + if (config.serverMetrics) { - this.get('/prometheus', (req, res) => { + this.get('/prometheus', async (req, res) => { res.set('Content-Type', prometheusRegister.contentType); - res.end(prometheusRegister.metrics()); + res.end(await prometheusRegister.metrics()); }); } } diff --git a/package.json b/package.json index b5d8e51f5a..02be0af759 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "parse-database-url": "^0.3.0", "pg": "^8.0.3", "pkginfo": "^0.4.1", - "prom-client": "^12.0.0", + "prom-client": "^13.1.0", "response-time": "^2.3.2", "serve-favicon": "^2.5.0", "unleash-frontend": "3.11.1", diff --git a/yarn.lock b/yarn.lock index 79a5a7596a..1f890011ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4830,10 +4830,10 @@ progress@^2.0.0: resolved "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== -prom-client@^12.0.0: - version "12.0.0" - resolved "https://registry.npmjs.org/prom-client/-/prom-client-12.0.0.tgz" - integrity sha512-JbzzHnw0VDwCvoqf8y1WDtq4wSBAbthMB1pcVI/0lzdqHGJI3KBJDXle70XK+c7Iv93Gihqo0a5LlOn+g8+DrQ== +prom-client@^13.1.0: + version "13.1.0" + resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-13.1.0.tgz#1185caffd8691e28d32e373972e662964e3dba45" + integrity sha512-jT9VccZCWrJWXdyEtQddCDszYsiuWj5T0ekrPszi/WEegj3IZy6Mm09iOOVM86A4IKMWq8hZkT2dD9MaSe+sng== dependencies: tdigest "^0.1.1"