mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-27 14:33:22 +00:00
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:
parent
9329249bc9
commit
ffa523bced
2 changed files with 19 additions and 0 deletions
18
libraries/metrics/event_loop.coffee
Normal file
18
libraries/metrics/event_loop.coffee
Normal 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)
|
|
@ -39,6 +39,7 @@ module.exports =
|
||||||
mongodb: require "./mongodb"
|
mongodb: require "./mongodb"
|
||||||
http: require "./http"
|
http: require "./http"
|
||||||
open_sockets: require "./open_sockets"
|
open_sockets: require "./open_sockets"
|
||||||
|
event_loop: require "./event_loop"
|
||||||
|
|
||||||
close: () ->
|
close: () ->
|
||||||
for func in destructors
|
for func in destructors
|
||||||
|
|
Loading…
Reference in a new issue