add metrics for latexmk runs and errors

This commit is contained in:
Brian Gough 2016-03-15 14:04:37 +00:00
parent 124c91e302
commit a26f4fc5f6
3 changed files with 25 additions and 6 deletions

View file

@ -10,6 +10,7 @@ child_process = require "child_process"
CommandRunner = require(Settings.clsi?.commandRunner or "./CommandRunner")
DraftModeManager = require "./DraftModeManager"
fs = require("fs")
os = require("os")
module.exports = CompileManager =
doCompile: (request, callback = (error, outputFiles) ->) ->
@ -38,10 +39,17 @@ module.exports = CompileManager =
compiler: request.compiler
timeout: request.timeout
image: request.imageName
}, (error) ->
}, (error, output, stats) ->
return callback(error) if error?
logger.log project_id: request.project_id, time_taken: Date.now() - timer.start, "done compile"
timer.done()
Metrics.inc("compiles")
for metric_key, metric_value of stats or {}
Metrics.count(metric_key, metric_value)
loadavg = os.loadavg?()
Metrics.gauge("load-avg", loadavg[0]) if loadavg?
ts = timer.done()
logger.log {project_id: request.project_id, time_taken: ts, stats:stats, loadavg:loadavg}, "done compile"
if stats?["latex-runs"] > 0
Metrics.timing("run-compile-per-pass", ts / stats["latex-runs"])
OutputFileFinder.findOutputFiles request.resources, compileDir, (error, outputFiles) ->
return callback(error) if error?

View file

@ -27,9 +27,20 @@ module.exports = LatexRunner =
else
return callback new Error("unknown compiler: #{compiler}")
CommandRunner.run project_id, command, directory, image, timeout, callback
CommandRunner.run project_id, command, directory, image, timeout, (error, output) ->
return callback(error) if error?
runs = output?.stderr?.match(/^Run number \d+ of .*latex/mg)?.length or 0
failed = if output?.stdout?.match(/^Latexmk: Errors/m)? then 1 else 0
# counters from latexmk output
stats = {}
stats["latexmk-errors"] = failed
stats["latex-runs"] = runs
stats["latex-runs-with-errors"] = if failed then runs else 0
stats["latex-runs-#{runs}"] = 1
stats["latex-runs-with-errors-#{runs}"] = if failed then 1 else 0
callback error, output, stats
_latexmkBaseCommand: [ "latexmk", "-cd", "-f", "-jobname=output", "-auxdir=$COMPILE_DIR", "-outdir=$COMPILE_DIR"]
_latexmkBaseCommand: ["latexmk", "-cd", "-f", "-jobname=output", "-auxdir=$COMPILE_DIR", "-outdir=$COMPILE_DIR"]
_pdflatexCommand: (mainFile) ->
LatexRunner._latexmkBaseCommand.concat [

View file

@ -15,7 +15,7 @@
"request": "~2.21.0",
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0",
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.3.0",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.5.0",
"sequelize": "^2.1.3",
"wrench": "~1.5.4",
"smoke-test-sharelatex": "git+https://github.com/sharelatex/smoke-test-sharelatex.git#v0.2.0",