diff --git a/libraries/metrics/event_loop.coffee b/libraries/metrics/event_loop.coffee new file mode 100644 index 0000000000..ab6955afc7 --- /dev/null +++ b/libraries/metrics/event_loop.coffee @@ -0,0 +1,18 @@ +seconds = 1000 + +module.exports = EventLoopMonitor = + monitor: (logger) -> + interval = setInterval () -> + EventLoopMonitor.Delay() + , 1 * seconds + Metrics = require "./metrics" + Metrics.registerDestructor () -> + clearInterval(interval) + + Delay: () -> + Metrics = require "./metrics" + t1 = process.hrtime() + setImmediate () -> + delta = process.hrtime(t1) + responseTime = delta[0]*1e6 + delta[1]*1e-3 + Metrics.timing("event-loop-microsec", responseTime) diff --git a/libraries/metrics/metrics.coffee b/libraries/metrics/metrics.coffee index 59e4ee9899..a0cd3070fb 100644 --- a/libraries/metrics/metrics.coffee +++ b/libraries/metrics/metrics.coffee @@ -39,6 +39,7 @@ module.exports = mongodb: require "./mongodb" http: require "./http" open_sockets: require "./open_sockets" + event_loop: require "./event_loop" close: () -> for func in destructors