overleaf/libraries/metrics/event_loop.coffee
Brian Gough ffa523bced 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
2015-06-23 10:51:48 +01:00

18 lines
467 B
CoffeeScript

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)