From 79362698049636d112026668632e76b4ed16e77c Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 12 Mar 2015 09:54:57 +0000 Subject: [PATCH] add metrics for ASpell workers --- services/spelling/app/coffee/ASpellWorker.coffee | 3 +++ services/spelling/app/coffee/ASpellWorkerPool.coffee | 3 +++ 2 files changed, 6 insertions(+) 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