Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from RuntimeTools/builderror
Browse files Browse the repository at this point in the history
Builderror
  • Loading branch information
stalleyj authored Oct 24, 2017
2 parents 3ce2254 + fb4f011 commit 34af137
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appmetrics-zipkin",
"version": "1.0.0",
"version": "1.0.1",
"description": "Zipkin support for appmetrics.",
"main": "index.js",
"dependencies": {
Expand Down
15 changes: 13 additions & 2 deletions probes/http-probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
20 changes: 1 addition & 19 deletions probes/https-probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;

0 comments on commit 34af137

Please sign in to comment.