Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yorch committed Mar 9, 2021
1 parent 3d4c486 commit 13cda73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/metrics-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = (appVersion, projectName, framework = 'express') => {
});

setupOptions.includeQueryParams = includeQueryParams;

setupOptions.defaultMetricsInterval = defaultMetricsInterval;

setupOptions.additionalLabels = utils.validateInput({
Expand Down Expand Up @@ -118,9 +119,6 @@ module.exports = (appVersion, projectName, framework = 'express') => {
const defaultMetricLabels = ['method', 'route', 'code'];

const metricLabels = [
'method',
'route',
'code',
...additionalLabels,
...excludeDefaultMetricLabels === true
? []
Expand Down
9 changes: 5 additions & 4 deletions test/unit-test/metric-middleware-koa-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 13cda73

Please sign in to comment.