added monitoring of event loop time

should indicate if node is blocking on libuv threads
as described in https://nodejs.org/api/dns.html#dns_dns_lookup
This commit is contained in:
Brian Gough 2015-06-23 10:51:48 +01:00
parent 9329249bc9
commit ffa523bced
2 changed files with 19 additions and 0 deletions

View file

@ -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)

View file

@ -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