Skip to content

Commit 48bef21

Browse files
committed
chore: show all useful metrics
1 parent fc03f5a commit 48bef21

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

src/server/views/helpers/queueHelpers.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,21 @@ const Helpers = {
4242
const usedMemoryPrefix = 'used_memory:';
4343
const lines = doc.split(/\r?\n/);
4444

45-
for (let i = 0; i < lines.length; i++) {
46-
if (lines[i].indexOf(totalSystemMemoryPrefix) === 0) {
47-
stats.total_system_memory = formatBytes(
48-
parseInt(lines[i].substr(totalSystemMemoryPrefix.length), 10)
49-
);
50-
}
51-
52-
if (lines[i].indexOf(usedMemoryPrefix) === 0) {
53-
stats.used_memory = formatBytes(
54-
parseInt(lines[i].substr(usedMemoryPrefix.length), 10)
55-
);
45+
for (const line of lines) {
46+
for (const metric of Helpers._usefulMetrics) {
47+
const metricPrefix = metric + ':';
48+
if (line.indexOf(metricPrefix) === 0) {
49+
if (
50+
metricPrefix === totalSystemMemoryPrefix ||
51+
metricPrefix === usedMemoryPrefix
52+
) {
53+
stats[metric] = formatBytes(
54+
parseInt(line.substr(metricPrefix.length), 10)
55+
);
56+
} else {
57+
stats[metric] = line.substr(metricPrefix.length);
58+
}
59+
}
5660
}
5761
}
5862
}

0 commit comments

Comments
 (0)