diff --git a/services/spelling/app/coffee/ASpellWorker.coffee b/services/spelling/app/coffee/ASpellWorker.coffee index 0f5ca8c98a..a33032bd4c 100644 --- a/services/spelling/app/coffee/ASpellWorker.coffee +++ b/services/spelling/app/coffee/ASpellWorker.coffee @@ -1,5 +1,6 @@ child_process = require("child_process") logger = require 'logger-sharelatex' +metrics = require('metrics-sharelatex') BATCH_SIZE = 100 @@ -9,9 +10,11 @@ class ASpellWorker @count = 0 @pipe = child_process.spawn("aspell", ["pipe", "-t", "--encoding=utf-8", "-d", language]) logger.log process: @pipe.pid, lang: @language, "starting new aspell worker" + metrics.inc "aspellWorker-start-" + @language @pipe.on 'exit', () => @state = 'killed' logger.log process: @pipe.pid, lang: @language, "aspell worker has exited" + metrics.inc "aspellWorker-exit-" + @language @pipe.on 'error', (err) => @state = 'error' @callback err, [] diff --git a/services/spelling/app/coffee/ASpellWorkerPool.coffee b/services/spelling/app/coffee/ASpellWorkerPool.coffee index 2e847938ff..0e87e9647d 100644 --- a/services/spelling/app/coffee/ASpellWorkerPool.coffee +++ b/services/spelling/app/coffee/ASpellWorkerPool.coffee @@ -1,6 +1,7 @@ ASpellWorker = require "./ASpellWorker" _ = require "underscore" logger = require 'logger-sharelatex' +metrics = require('metrics-sharelatex') class ASpellWorkerPool MAX_REQUESTS: 100*1024 @@ -18,12 +19,14 @@ class ASpellWorkerPool worker.pipe.on 'exit', () => @cleanup() @PROCESS_POOL.push(worker) + metrics.gauge 'aspellWorkerPool-size', @PROCESS_POOL.length return worker cleanup: () -> active = @PROCESS_POOL.filter (worker) -> worker.state != 'killed' @PROCESS_POOL = active + metrics.gauge 'aspellWorkerPool-size', @PROCESS_POOL.length check: (language, words, timeout, callback) -> # look for an existing process in the pool