Skip to content

Commit 67e0c1b

Browse files
committed
use same metrics object
1 parent 971355e commit 67e0c1b

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

lib/dashboard-agent.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,27 @@ var dashboardAgent = function () {
1616

1717
var socket = new SocketIO("http://localhost:" + options.port);
1818

19-
var eventLoop = {
20-
delay: 0,
21-
high: 0
19+
var metrics = {
20+
eventLoop: {
21+
delay: 0,
22+
high: 0,
23+
},
24+
mem: {
25+
systemTotal: os.totalmem()
26+
},
27+
cpu: {
28+
utilization: 0
29+
}
2230
};
2331

2432
var _delayed = function (delay) {
25-
eventLoop.high = Math.max(eventLoop.high, delay);
26-
eventLoop.delay = delay;
33+
metrics.eventLoop.high = Math.max(metrics.eventLoop.high, delay);
34+
metrics.eventLoop.delay = delay;
2735
};
2836

2937
blocked(_delayed, { threshold: options.blockedThreshold });
3038

3139
var _getStats = function (cb) {
32-
var metrics = {
33-
eventLoop: eventLoop,
34-
mem: {
35-
systemTotal: os.totalmem()
36-
},
37-
cpu: {
38-
utilization: 0
39-
}
40-
};
41-
4240
_.merge(metrics.mem, process.memoryUsage());
4341

4442
pusage.stat(process.pid, function (err, stat) {
@@ -54,7 +52,7 @@ var dashboardAgent = function () {
5452
};
5553

5654
var resetEventMetrics = function () {
57-
eventLoop.delay = 0;
55+
metrics.eventLoop.delay = 0;
5856
};
5957

6058
var _emitStats = function () {

0 commit comments

Comments
 (0)