Skip to content

Commit

Permalink
Merge pull request #46 from Financial-Times/miss-scarlet
Browse files Browse the repository at this point in the history
Remove scarlet from the metric logging
  • Loading branch information
adgad committed Oct 8, 2015
2 parents 79e1773 + adc01b4 commit fa5f546
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 141 deletions.
105 changes: 0 additions & 105 deletions lib/metrics/counter.js

This file was deleted.

14 changes: 5 additions & 9 deletions lib/metrics/express/http-response-v2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use strict";

var Scarlet = require('scarlet');
var scarlet = new Scarlet();
var metrics = require('metrics');

var HttpResponse = module.exports = function HttpResponse() {
Expand Down Expand Up @@ -76,11 +74,9 @@ HttpResponse.prototype.reporter = function() {
// proxy for res.writeHead - http://nodejs.org/api/http.html#http_response_writehead_statuscode_reasonphrase_headers
HttpResponse.prototype._writeHead = function(fn, method, dt) {
var self = this;
return scarlet
.intercept(fn)
.using(function(invocation, proceed) {
var statusCode = parseInt(('' + invocation.args[0]).toString().substr(0, 3));
self.measure('express.default_route_' + method + '.res.status.' + statusCode, Date.now() - dt);
proceed();
}).proxy();
return function() {
var statusCode = parseInt(('' + arguments[0]).toString().substr(0, 3));
self.measure('express.default_route_' + method + '.res.status.' + statusCode, Date.now() - dt);
fn.apply(this, arguments);
};
};
48 changes: 22 additions & 26 deletions lib/metrics/express/http-response.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use strict";

var Scarlet = require('scarlet');
var _ = require('lodash');
var scarlet = new Scarlet();
var metrics = require('metrics');

var HttpResponse = module.exports = function HttpResponse() {
Expand Down Expand Up @@ -140,28 +138,26 @@ HttpResponse.prototype.reporter = function() {
// proxy for res.writeHead - http://nodejs.org/api/http.html#http_response_writehead_statuscode_reasonphrase_headers
HttpResponse.prototype._writeHead = function(fn, dt) {
var self = this;
return scarlet
.intercept(fn)
.using(function(invocation, proceed) {
var statusCode = parseInt(('' + invocation.args[0]).toString().charAt(0));
switch (statusCode) {
case 2:
self.counters.status_2xx.inc(1);
self.counters.status_2xx_response_time.update(Date.now() - dt);
break;
case 3:
self.counters.status_3xx.inc(1);
break;
case 4:
self.counters.status_4xx.inc(1);
self.counters.status_4xx_response_time.update(Date.now() - dt);
break;
case 5:
self.counters.status_5xx.inc(1);
self.counters.status_5xx_response_time.update(Date.now() - dt);
break;
default:
}
proceed();
}).proxy();
return function() {
var statusCode = parseInt(('' + arguments[0]).toString().charAt(0));
switch (statusCode) {
case 2:
self.counters.status_2xx.inc(1);
self.counters.status_2xx_response_time.update(Date.now() - dt);
break;
case 3:
self.counters.status_3xx.inc(1);
break;
case 4:
self.counters.status_4xx.inc(1);
self.counters.status_4xx_response_time.update(Date.now() - dt);
break;
case 5:
self.counters.status_5xx.inc(1);
self.counters.status_5xx_response_time.update(Date.now() - dt);
break;
default:
}
fn.apply(this, arguments);
};
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"lodash": "^2.4.1",
"metrics": "^0.1.8",
"mocha": "^2.2.4",
"scarlet": "^2.0.20",
"swig": "^1.4.2"
},
"devDependencies": {
Expand Down

0 comments on commit fa5f546

Please sign in to comment.