mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 03:30:49 +00:00
use per-channel event metrics
This commit is contained in:
parent
8c82faa966
commit
e91b967bdb
3 changed files with 9 additions and 5 deletions
|
@ -23,7 +23,7 @@ module.exports = DocumentUpdaterController =
|
|||
return
|
||||
if message.op?
|
||||
if message._id?
|
||||
EventLogger.checkEventOrder(message._id, message)
|
||||
EventLogger.checkEventOrder("applied-ops", message._id, message)
|
||||
DocumentUpdaterController._applyUpdateFromDocumentUpdater(io, message.doc_id, message.op)
|
||||
else if message.error?
|
||||
DocumentUpdaterController._processErrorFromDocumentUpdater(io, message.doc_id, message.error, message)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
logger = require 'logger-sharelatex'
|
||||
metrics = require 'metrics-sharelatex'
|
||||
|
||||
# keep track of message counters to detect duplicate and out of order events
|
||||
# messsage ids have the format "UNIQUEHOSTKEY-COUNTER"
|
||||
|
@ -11,7 +12,7 @@ module.exports = EventLogger =
|
|||
|
||||
MAX_STALE_TIME_IN_MS: 3600 * 1000
|
||||
|
||||
checkEventOrder: (message_id, message) ->
|
||||
checkEventOrder: (channel, message_id, message) ->
|
||||
return if typeof(message_id) isnt 'string'
|
||||
[key, count] = message_id.split("-", 2)
|
||||
count = parseInt(count, 10)
|
||||
|
@ -20,12 +21,15 @@ module.exports = EventLogger =
|
|||
# store the last count in a hash for each host
|
||||
previous = EventLogger._storeEventCount(key, count)
|
||||
if !previous? || count == (previous + 1)
|
||||
metrics.inc "event.#{channel}.valid"
|
||||
return # order is ok
|
||||
if (count == previous)
|
||||
logger.error {key:key, previous: previous, count:count, message:message}, "duplicate event"
|
||||
metrics.inc "event.#{channel}.duplicate"
|
||||
# logger.error {key:key, previous: previous, count:count, message:message}, "duplicate event"
|
||||
return "duplicate"
|
||||
else
|
||||
logger.error {key:key, previous: previous, count:count, message:message}, "events out of order"
|
||||
metrics.inc "event.#{channel}.out-of-order"
|
||||
# logger.error {key:key, previous: previous, count:count, message:message}, "events out of order"
|
||||
return # out of order
|
||||
|
||||
_storeEventCount: (key, count) ->
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = WebsocketLoadBalancer =
|
|||
io.sockets.emit(message.message, message.payload...)
|
||||
else if message.room_id?
|
||||
if message._id?
|
||||
EventLogger.checkEventOrder(message._id, message)
|
||||
EventLogger.checkEventOrder("editor-events", message._id, message)
|
||||
io.sockets.in(message.room_id).emit(message.message, message.payload...)
|
||||
else if message.health_check?
|
||||
logger.debug {message}, "got health check message in editor events channel"
|
||||
|
|
Loading…
Reference in a new issue