Skip to content

Commit

Permalink
fix: align compliancy to Prometheus naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Morgachev committed Sep 18, 2019
1 parent f326857 commit c73c243
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/metrics/processHandles.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

const Gauge = require('../gauge');
const { aggregateByObjectName } = require('./helpers/processMetricsHelpers');
const { updateMetrics } = require('./helpers/processMetricsHelpers');
const Gauge = require('../gauge');

const NODEJS_ACTIVE_HANDLES = 'nodejs_active_handles';
const NODEJS_ACTIVE_HANDLES_TOTAL = 'nodejs_active_handles_total';
const NODEJS_ACTIVE_HANDLES_TOTAL_NUMBER = 'nodejs_active_handles_total_number';

module.exports = (registry, config = {}) => {
// Don't do anything if the function is removed in later nodes (exists in node@6)
Expand All @@ -23,7 +23,7 @@ module.exports = (registry, config = {}) => {
registers: registry ? [registry] : undefined
});
const totalGauge = new Gauge({
name: namePrefix + NODEJS_ACTIVE_HANDLES_TOTAL,
name: namePrefix + NODEJS_ACTIVE_HANDLES_TOTAL_NUMBER,
help: 'Total number of active handles.',
registers: registry ? [registry] : undefined
});
Expand All @@ -45,5 +45,5 @@ module.exports = (registry, config = {}) => {

module.exports.metricNames = [
NODEJS_ACTIVE_HANDLES,
NODEJS_ACTIVE_HANDLES_TOTAL
NODEJS_ACTIVE_HANDLES_TOTAL_NUMBER
];
7 changes: 4 additions & 3 deletions lib/metrics/processRequests.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';

const Gauge = require('../gauge');
const { aggregateByObjectName } = require('./helpers/processMetricsHelpers');
const { updateMetrics } = require('./helpers/processMetricsHelpers');

const NODEJS_ACTIVE_REQUESTS = 'nodejs_active_requests';
const NODEJS_ACTIVE_REQUESTS_TOTAL = 'nodejs_active_requests_total';
const NODEJS_ACTIVE_REQUESTS_TOTAL_NUMBER = 'nodejs_active_requests_total_number'; //eslint-disable-line prettier/prettier

module.exports = (registry, config = {}) => {
// Don't do anything if the function is removed in later nodes (exists in node@6)
Expand All @@ -23,7 +24,7 @@ module.exports = (registry, config = {}) => {
});

const totalGauge = new Gauge({
name: namePrefix + NODEJS_ACTIVE_REQUESTS_TOTAL,
name: namePrefix + NODEJS_ACTIVE_REQUESTS_TOTAL_NUMBER,
help: 'Total number of active requests.',
registers: registry ? [registry] : undefined
});
Expand All @@ -37,5 +38,5 @@ module.exports = (registry, config = {}) => {

module.exports.metricNames = [
NODEJS_ACTIVE_REQUESTS,
NODEJS_ACTIVE_REQUESTS_TOTAL
NODEJS_ACTIVE_REQUESTS_TOTAL_NUMBER
];
2 changes: 1 addition & 1 deletion test/metrics/processHandlesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ describe('processHandles', () => {

expect(metrics[1].help).toEqual('Total number of active handles.');
expect(metrics[1].type).toEqual('gauge');
expect(metrics[1].name).toEqual('nodejs_active_handles_total');
expect(metrics[1].name).toEqual('nodejs_active_handles_total_number');
});
});
2 changes: 1 addition & 1 deletion test/metrics/processRequestsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ describe('processRequests', () => {

expect(metrics[1].help).toEqual('Total number of active requests.');
expect(metrics[1].type).toEqual('gauge');
expect(metrics[1].name).toEqual('nodejs_active_requests_total');
expect(metrics[1].name).toEqual('nodejs_active_requests_total_number');
});
});

0 comments on commit c73c243

Please sign in to comment.