add metric for active workers

This commit is contained in:
Brian Gough 2017-05-24 11:47:06 +01:00
parent 7497c066ee
commit c43f97e8e3

View file

@ -20,7 +20,9 @@ module.exports = DispatchManager =
[list_name, doc_key] = result [list_name, doc_key] = result
[project_id, doc_id] = Keys.splitProjectIdAndDocId(doc_key) [project_id, doc_id] = Keys.splitProjectIdAndDocId(doc_key)
# Dispatch this in the background # Dispatch this in the background
Metrics.gauge "processingUpdates", "+1" # increments/decrements gauge with +/- sign
UpdateManager.processOutstandingUpdatesWithLock project_id, doc_id, (error) -> UpdateManager.processOutstandingUpdatesWithLock project_id, doc_id, (error) ->
Metrics.gauge "processingUpdates", "-1"
logger.error err: error, project_id: project_id, doc_id: doc_id, "error processing update" if error? logger.error err: error, project_id: project_id, doc_id: doc_id, "error processing update" if error?
callback() callback()
@ -39,4 +41,4 @@ module.exports = DispatchManager =
createAndStartDispatchers: (number) -> createAndStartDispatchers: (number) ->
for i in [1..number] for i in [1..number]
worker = DispatchManager.createDispatcher() worker = DispatchManager.createDispatcher()
worker.run() worker.run()