From 3b6bc14d1748e668b2e49a978f7c1beadb07cf6c Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Tue, 4 Oct 2016 13:19:29 +0200 Subject: [PATCH] Increment errors on err --- app/controllers/job_controller.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/app/controllers/job_controller.js b/app/controllers/job_controller.js index 7da6be70..c90b9414 100644 --- a/app/controllers/job_controller.js +++ b/app/controllers/job_controller.js @@ -96,6 +96,7 @@ JobController.prototype.cancelJob = function (req, res) { }, function handleResponse(err, result) { if ( err ) { + self.statsdClient.increment('sqlapi.job.error'); return handleException(err, res); } @@ -115,11 +116,7 @@ JobController.prototype.cancelJob = function (req, res) { res.header('X-SQLAPI-Profiler', req.profiler.toJSONString()); } - if ( err ) { - self.statsdClient.increment('sqlapi.job.error'); - } else { - self.statsdClient.increment('sqlapi.job.success'); - } + self.statsdClient.increment('sqlapi.job.success'); res.send(result.job); } @@ -171,6 +168,7 @@ JobController.prototype.getJob = function (req, res) { }, function handleResponse(err, result) { if ( err ) { + self.statsdClient.increment('sqlapi.job.error'); return handleException(err, res); } @@ -190,11 +188,7 @@ JobController.prototype.getJob = function (req, res) { res.header('X-SQLAPI-Profiler', req.profiler.toJSONString()); } - if ( err ) { - self.statsdClient.increment('sqlapi.job.error'); - } else { - self.statsdClient.increment('sqlapi.job.success'); - } + self.statsdClient.increment('sqlapi.job.success'); res.send(result.job); } @@ -252,6 +246,7 @@ JobController.prototype.createJob = function (req, res) { }, function handleResponse(err, result) { if ( err ) { + self.statsdClient.increment('sqlapi.job.error'); return handleException(err, res); } @@ -271,11 +266,7 @@ JobController.prototype.createJob = function (req, res) { res.header('X-SQLAPI-Profiler', req.profiler.toJSONString()); } - if ( err ) { - self.statsdClient.increment('sqlapi.job.error'); - } else { - self.statsdClient.increment('sqlapi.job.success'); - } + self.statsdClient.increment('sqlapi.job.success'); console.info(JSON.stringify({ type: 'sql_api_batch_job',