Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: siimon/prom-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v11.3.0
Choose a base ref
...
head repository: siimon/prom-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v11.4.0
Choose a head ref
  • 3 commits
  • 8 files changed
  • 2 contributors

Commits on Jun 1, 2019

  1. Split process request and process handles by type (#260)

    * Report process handles and requests grouped by type
    
    * return names of new metrics
    
    * replace let with const
    
    * Fix unit test
    
    * fix linter errors
    
    * Update CHANGELOG. Improve metrics documentation
    
    * Fix unit tests
    yvasiyarov authored and siimon committed Jun 1, 2019
    Copy the full SHA
    da970a3 View commit details

Commits on Jun 4, 2019

  1. chore: prepare for release

    SimenB committed Jun 4, 2019

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    SimenB Simen Bekkhus
    Copy the full SHA
    58336d4 View commit details
  2. 11.4.0

    SimenB committed Jun 4, 2019

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    SimenB Simen Bekkhus
    Copy the full SHA
    6d1f37e View commit details
Showing with 1,445 additions and 1,025 deletions.
  1. +7 −0 CHANGELOG.md
  2. +26 −0 lib/metrics/helpers/processMetricsHelpers.js
  3. +19 −4 lib/metrics/processHandles.js
  4. +20 −5 lib/metrics/processRequests.js
  5. +1,265 −921 package-lock.json
  6. +89 −89 package.json
  7. +10 −3 test/metrics/processHandlesTest.js
  8. +9 −3 test/metrics/processRequestsTest.js
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,13 @@ project adheres to [Semantic Versioning](http://semver.org/).

### Added

## [11.4.0] - 2019-06-04

### Added

- `nodejs_active_handles` metric to the `collectDefaultMetrics()`. Unlike `nodejs_active_handles_total` it split count of active handles by type.
- `nodejs_active_requests` metric to the `collectDefaultMetrics()`. Unlike `nodejs_active_requests_total` it split count of active requests by type.

## [11.3.0] - 2019-04-02

### Changed
26 changes: 26 additions & 0 deletions lib/metrics/helpers/processMetricsHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

function aggregateByObjectName(list) {
const data = {};

for (const key in list) {
if (data.hasOwnProperty(list[key].constructor.name)) {
data[list[key].constructor.name] += 1;
} else {
data[list[key].constructor.name] = 1;
}
}
return data;
}

function updateMetrics(gauge, data) {
gauge.reset();
for (const key in data) {
gauge.set({ type: key }, data[key], Date.now());
}
}

module.exports = {
aggregateByObjectName,
updateMetrics
};
23 changes: 19 additions & 4 deletions lib/metrics/processHandles.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
'use strict';

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

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

module.exports = (registry, config = {}) => {
// Don't do anything if the function is removed in later nodes (exists in node@6)
@@ -14,13 +17,25 @@ module.exports = (registry, config = {}) => {

const gauge = new Gauge({
name: namePrefix + NODEJS_ACTIVE_HANDLES,
help: 'Number of active handles.',
help:
'Number of active libuv handles grouped by handle type. Every handle type is C++ class name.',
labelNames: ['type'],
registers: registry ? [registry] : undefined
});
const totalGauge = new Gauge({
name: namePrefix + NODEJS_ACTIVE_HANDLES_TOTAL,
help: 'Total number of active handles.',
registers: registry ? [registry] : undefined
});

return () => {
gauge.set(process._getActiveHandles().length, Date.now());
const handles = process._getActiveHandles();
updateMetrics(gauge, aggregateByObjectName(handles));
totalGauge.set(handles.length, Date.now());
};
};

module.exports.metricNames = [NODEJS_ACTIVE_HANDLES];
module.exports.metricNames = [
NODEJS_ACTIVE_HANDLES,
NODEJS_ACTIVE_HANDLES_TOTAL
];
25 changes: 20 additions & 5 deletions lib/metrics/processRequests.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use strict';

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

const NODEJS_ACTIVE_REQUESTS = 'nodejs_active_requests_total';
const NODEJS_ACTIVE_REQUESTS = 'nodejs_active_requests';
const NODEJS_ACTIVE_REQUESTS_TOTAL = 'nodejs_active_requests_total';

module.exports = (registry, config = {}) => {
// Don't do anything if the function is removed in later nodes (exists in node@6)
@@ -14,13 +16,26 @@ module.exports = (registry, config = {}) => {

const gauge = new Gauge({
name: namePrefix + NODEJS_ACTIVE_REQUESTS,
help: 'Number of active requests.',
help:
'Number of active libuv requests grouped by request type. Every request type is C++ class name.',
labelNames: ['type'],
registers: registry ? [registry] : undefined
});

const totalGauge = new Gauge({
name: namePrefix + NODEJS_ACTIVE_REQUESTS_TOTAL,
help: 'Total number of active requests.',
registers: registry ? [registry] : undefined
});

return () => {
gauge.set(process._getActiveRequests().length, Date.now());
const requests = process._getActiveRequests();
updateMetrics(gauge, aggregateByObjectName(requests));
totalGauge.set(requests.length, Date.now());
};
};

module.exports.metricNames = [NODEJS_ACTIVE_REQUESTS];
module.exports.metricNames = [
NODEJS_ACTIVE_REQUESTS,
NODEJS_ACTIVE_REQUESTS_TOTAL
];
Loading