mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 16:23:12 +09:00
Add resident memory and heap size metrics
Implement the default resident memory and heap size metrics.
This commit is contained in:
1 parent
e908c5069b
commit
56488b2c2d
2 files changed
+60
No files matched your search
@@ -409,6 +409,26 @@ defaultCollectors.processCpuSecondsTotal = new Gauge(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
defaultCollectors.processResidentMemoryBytes = new Gauge(
|
||||||
|
'process_resident_memory_bytes',
|
||||||
|
"Resident memory size in bytes.",
|
||||||
|
{
|
||||||
|
callback: function() {
|
||||||
|
this.set(process.memoryUsage().rss);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
defaultCollectors.processHeapBytes = new Gauge(
|
||||||
|
'process_heap_bytes',
|
||||||
|
"Process heap size in bytes.",
|
||||||
|
{
|
||||||
|
callback: function() {
|
||||||
|
this.set(process.memoryUsage().heapUsed);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
defaultCollectors.processStartTimeSeconds = new Gauge(
|
defaultCollectors.processStartTimeSeconds = new Gauge(
|
||||||
'process_start_time_seconds',
|
'process_start_time_seconds',
|
||||||
"Start time of the process since unix epoch in seconds."
|
"Start time of the process since unix epoch in seconds."
|
||||||
|
|||||||
@@ -419,6 +419,46 @@ describe("lib/prometheus", function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe("processResidentMemoryBytes", function() {
|
||||||
|
it("should give a low value", async function() {
|
||||||
|
let results = []
|
||||||
|
let collector = prometheus.defaultCollectors.processResidentMemoryBytes;
|
||||||
|
for await (let result of collector.collect()) {
|
||||||
|
results.push(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(
|
||||||
|
results.length == 1,
|
||||||
|
"collector did not give exactly one result"
|
||||||
|
);
|
||||||
|
|
||||||
|
let value = results[0].samples.get('')
|
||||||
|
assert(
|
||||||
|
value < 200e6 && value > 0,
|
||||||
|
`resident memory is not between 0 and 200 MB (${value})`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("processHeapBytes", function() {
|
||||||
|
it("should give a low value", async function() {
|
||||||
|
let results = []
|
||||||
|
let collector = prometheus.defaultCollectors.processHeapBytes;
|
||||||
|
for await (let result of collector.collect()) {
|
||||||
|
results.push(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(
|
||||||
|
results.length == 1,
|
||||||
|
"collector did not give exactly one result"
|
||||||
|
);
|
||||||
|
|
||||||
|
let value = results[0].samples.get('')
|
||||||
|
assert(
|
||||||
|
value < 200e6 && value > 0,
|
||||||
|
`heap is not between 0 and 200 MB (${value})`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("exposition()", function() {
|
describe("exposition()", function() {
|
||||||
|
|||||||
Reference in new issue
Block a user