Skip to content

Commit

Permalink
fix: remove useless setting timestamp after #333 (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
melikhov-dev authored Mar 3, 2020
1 parent f382748 commit 236a767
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
11 changes: 3 additions & 8 deletions lib/metrics/heapSpacesSizeAndUsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = (registry, config = {}) => {
used: {},
available: {}
};
const now = Date.now();

v8.getHeapSpaceStatistics().forEach(space => {
const spaceName = space.space_name.substr(
Expand All @@ -43,13 +42,9 @@ module.exports = (registry, config = {}) => {
data.used[spaceName] = space.space_used_size;
data.available[spaceName] = space.space_available_size;

gauges.total.set({ space: spaceName }, space.space_size, now);
gauges.used.set({ space: spaceName }, space.space_used_size, now);
gauges.available.set(
{ space: spaceName },
space.space_available_size,
now
);
gauges.total.set({ space: spaceName }, space.space_size);
gauges.used.set({ space: spaceName }, space.space_used_size);
gauges.available.set({ space: spaceName }, space.space_available_size);
});

return data;
Expand Down
2 changes: 1 addition & 1 deletion lib/metrics/osMemoryHeap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function notLinuxVariant(registry, config = {}) {

// I don't think the other things returned from `process.memoryUsage()` is relevant to a standard export
if (memUsage) {
residentMemGauge.set(memUsage.rss, Date.now());
residentMemGauge.set(memUsage.rss);
}
};
}
Expand Down
7 changes: 3 additions & 4 deletions lib/metrics/processCpuTotal.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ module.exports = (registry, config = {}) => {

return () => {
const cpuUsage = process.cpuUsage();
const now = Date.now();

const userUsageMicros = cpuUsage.user - lastCpuUsage.user;
const systemUsageMicros = cpuUsage.system - lastCpuUsage.system;

lastCpuUsage = cpuUsage;

cpuUserUsageCounter.inc(userUsageMicros / 1e6, now);
cpuSystemUsageCounter.inc(systemUsageMicros / 1e6, now);
cpuUsageCounter.inc((userUsageMicros + systemUsageMicros) / 1e6, now);
cpuUserUsageCounter.inc(userUsageMicros / 1e6);
cpuSystemUsageCounter.inc(systemUsageMicros / 1e6);
cpuUsageCounter.inc((userUsageMicros + systemUsageMicros) / 1e6);
};
};

Expand Down
2 changes: 1 addition & 1 deletion lib/metrics/processRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = (registry, config = {}) => {
return () => {
const requests = process._getActiveRequests();
updateMetrics(gauge, aggregateByObjectName(requests));
totalGauge.set(requests.length, Date.now());
totalGauge.set(requests.length);
};
};

Expand Down

0 comments on commit 236a767

Please sign in to comment.