Skip to content

Commit 3105b65

Browse files
author
dkhan
committed
Added GC events
1 parent 4c13448 commit 3105b65

File tree

5 files changed

+517431
-4
lines changed

5 files changed

+517431
-4
lines changed

app.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
2+
3+
// CPU Profiling
14
// require('./monitoring/CpuProfiler').init('./public/metrics');
5+
6+
// Heap Dumps and Metrics
27
// require('./monitoring/HeapDump').init('./public/metrics');
3-
var createNamespace = require('continuation-local' + '-storage').createNamespace;
4-
var asyncCallbackMiddleware = require('./monitoring/AsyncCallbackMiddleware');
8+
9+
// See below for callback timings
510

611

712

@@ -19,7 +24,9 @@ var todo = require('./routes/todo');
1924

2025
var app = express();
2126

22-
// Switch on callback listener
27+
// Callback timings
28+
var asyncCallbackMiddleware = require('./monitoring/AsyncCallbackMiddleware');
29+
var createNamespace = require('continuation-local' + '-storage').createNamespace;
2330
app.use(asyncCallbackMiddleware);
2431

2532
// view engine setup

monitoring/HeapDump.js

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ var fs = require('fs');
1010
var profiler = require('v8-profiler');
1111
var _datadir = null;
1212
var nextMBThreshold = 0;
13+
var gcprofiler = require('gc-profiler');
14+
15+
// Listen to GC events
16+
gcprofiler.on('gc', function (info) {
17+
console.log('GC happened');
18+
console.log(info);
19+
});
20+
1321

1422
/**
1523
* Init and scheule heap dump runs

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"cookie-parser": "~1.3.5",
1212
"debug": "~2.2.0",
1313
"express": "~4.12.4",
14+
"gc-profiler": "^1.2.0",
1415
"jade": "~1.9.2",
1516
"less-middleware": "1.0.x",
1617
"morgan": "~1.5.3",

0 commit comments

Comments
 (0)