From 13cda73a10d0ce99b0af0b1f4d383837d2ba3203 Mon Sep 17 00:00:00 2001 From: Jorge Barnaby Date: Mon, 8 Mar 2021 22:28:04 -0500 Subject: [PATCH] Fixes --- src/metrics-middleware.js | 4 +--- test/unit-test/metric-middleware-koa-test.js | 9 +++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/metrics-middleware.js b/src/metrics-middleware.js index 34647aa..7e68e9a 100644 --- a/src/metrics-middleware.js +++ b/src/metrics-middleware.js @@ -56,6 +56,7 @@ module.exports = (appVersion, projectName, framework = 'express') => { }); setupOptions.includeQueryParams = includeQueryParams; + setupOptions.defaultMetricsInterval = defaultMetricsInterval; setupOptions.additionalLabels = utils.validateInput({ @@ -118,9 +119,6 @@ module.exports = (appVersion, projectName, framework = 'express') => { const defaultMetricLabels = ['method', 'route', 'code']; const metricLabels = [ - 'method', - 'route', - 'code', ...additionalLabels, ...excludeDefaultMetricLabels === true ? [] diff --git a/test/unit-test/metric-middleware-koa-test.js b/test/unit-test/metric-middleware-koa-test.js index d6929c1..eb9fa9d 100644 --- a/test/unit-test/metric-middleware-koa-test.js +++ b/test/unit-test/metric-middleware-koa-test.js @@ -812,10 +812,11 @@ describe('metrics-middleware', () => { expect(Prometheus.register.getSingleMetric('http_request_size_bytes').labelNames).to.have.members(['method']); }); it('and it\'s other type', () => { - middleware({ - excludeDefaultMetricLabels: 'invalid' - }); - expect(Prometheus.register.getSingleMetric('http_request_size_bytes').labelNames).to.have.members(['method', 'route', 'code']); + expect(() => { + middleware({ + excludeDefaultMetricLabels: 'invalid', + }); + }).to.throw('excludeDefaultMetricLabels should be an array or a boolean'); }); afterEach(() => { Prometheus.register.clear();