[client-app] Measure and report task performLocal times

Summary: See title

Test Plan: manual

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4015
This commit is contained in:
Juan Tejada 2017-02-22 09:55:19 -08:00
parent ae9aede300
commit b819889b36

View file

@ -149,25 +149,7 @@ class TaskQueue
task.runLocal() task.runLocal()
.then => .then =>
runLocalTime = Date.now() - runLocalStart runLocalTime = Date.now() - runLocalStart
if runLocalTime >= 500 @_reportRunLocalTime(task, runLocalTime)
taskJSON = JSON.parse(JSON.stringify(task.toJSON()))
taskData = _.mapObject(taskJSON, (val, key) =>
if key is 'folder'
return val.display_name
if key in ['labelsToAdd', 'labelsToRemove']
return val.map((l) => l.display_name)
return val
)
taskData = _.omit(taskData, (val, key) =>
if key in ['thread', 'message', 'draft', 'messages', 'threads', 'queueState']
return true
return key.startsWith('_')
)
eventData = Object.assign({}, taskData, {
duration: runLocalTime,
taskName: task.constructor.name,
})
Actions.recordUserEvent("Task performLocal took more than 500ms", eventData)
@_queue.push(task) @_queue.push(task)
@_updateSoon() @_updateSoon()
@ -246,6 +228,28 @@ class TaskQueue
if reprocessIn isnt Number.MAX_VALUE if reprocessIn isnt Number.MAX_VALUE
@_processQueueTimeout = setTimeout(@_processQueue, reprocessIn + 500) @_processQueueTimeout = setTimeout(@_processQueue, reprocessIn + 500)
_reportRunLocalTime: (task, runLocalTime) =>
taskJSON = JSON.parse(JSON.stringify(task.toJSON()))
taskData = _.mapObject(taskJSON, (val, key) =>
if key is 'folder'
return val.display_name
if key in ['labelsToAdd', 'labelsToRemove']
return val.map((l) => l.display_name)
return val
)
taskData = _.omit(taskData, (val, key) =>
if key in ['thread', 'message', 'draft', 'messages', 'threads', 'queueState']
return true
return key.startsWith('_')
)
eventData = Object.assign({}, taskData, {
action: 'perform-local-task'
actionTimeMs: runLocalTime,
taskName: task.constructor.name,
maxValue: 1000,
})
Actions.recordPerfMetric(eventData)
_processTask: (task) => _processTask: (task) =>
return if task.queueState.isProcessing return if task.queueState.isProcessing