diff --git a/package.json b/package.json index a91990c..e339263 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "appmetrics-zipkin", - "version": "1.0.0", + "version": "1.0.1", "description": "Zipkin support for appmetrics.", "main": "index.js", "dependencies": { diff --git a/probes/http-probe.js b/probes/http-probe.js index df39537..53ea54d 100755 --- a/probes/http-probe.js +++ b/probes/http-probe.js @@ -73,7 +73,7 @@ HttpProbe.prototype.attach = function(name, target) { traceId128Bit: true // to generate 128-bit trace IDs. }); - var that = this; + if (name == 'http') { if (target.__zipkinProbeAttached__) return target; target.__zipkinProbeAttached__ = true; @@ -88,7 +88,7 @@ HttpProbe.prototype.attach = function(name, target) { var httpReq = args[0]; var res = args[1]; // Filter out urls where filter.to is '' - var traceUrl = that.filterUrl(httpReq); + var traceUrl = parse(httpReq.url); // console.log(util.inspect(httpReq)); if (traceUrl !== '') { const method = httpReq.method; @@ -134,5 +134,16 @@ HttpProbe.prototype.attach = function(name, target) { } return target; }; +/* + * Custom req.url parser that strips out any trailing query + */ +function parse(url) { + ['?', '#'].forEach(function(separator) { + var index = url.indexOf(separator); + if (index !== -1) url = url.substring(0, index); + }); + return url; +}; + module.exports = HttpProbe; diff --git a/probes/https-probe.js b/probes/https-probe.js index 65c7503..77bf5da 100644 --- a/probes/https-probe.js +++ b/probes/https-probe.js @@ -73,7 +73,6 @@ HttpsProbe.prototype.attach = function(name, target) { traceId128Bit: true // to generate 128-bit trace IDs. }); - var that = this; if (name == 'https') { if (target.__zipkinProbeAttached__) return target; target.__zipkinProbeAttached__ = true; @@ -88,7 +87,7 @@ HttpsProbe.prototype.attach = function(name, target) { var httpsReq = args[0]; var res = args[1]; // Filter out urls where filter.to is '' - var traceUrl = that.filterUrl(httpsReq); + var traceUrl = parse(httpsReq.url); if (traceUrl !== '') { const method = httpsReq.method; @@ -145,22 +144,5 @@ var parse = function(url) { return url; }; -/* - * Ignore requests for URLs which we've been configured via regex to ignore - */ -HttpsProbe.prototype.filterUrl = function(req) { - var resultUrl = parse(req.url); - var filters = this.config.filters; - if (filters.length == 0) return resultUrl; - - var identifier = req.method + ' ' + resultUrl; - for (var i = 0; i < filters.length; ++i) { - var filter = filters[i]; - if (filter.regex.test(identifier)) { - return filter.to; - } - } - return resultUrl; -}; module.exports = HttpsProbe;