Comparing version 1.3.0 to 1.3.1
@@ -201,3 +201,6 @@ 'use strict'; | ||
// 5. put the version in the config | ||
// 5. clean up anything that requires postprocessing | ||
this._canonicalize(); | ||
// 6. put the version in the config | ||
this.version = require(path.join(__dirname, '..', 'package.json')).version; | ||
@@ -416,3 +419,2 @@ } | ||
); | ||
this.emit(key, value); | ||
} | ||
@@ -570,2 +572,17 @@ }; | ||
/** | ||
* Depending on how the status codes are set, they could be strings, which | ||
* makes strict equality testing / indexOf fail. To keep things cheap, parse | ||
* them once, after configuration has finished loading. Other one-off shims | ||
* based on special properties of configuration values should go here as well. | ||
*/ | ||
Config.prototype._canonicalize = function () { | ||
var codes = this.error_collector && this.error_collector.ignore_status_codes; | ||
if (codes) { | ||
this.error_collector.ignore_status_codes = codes.map(function (code) { | ||
return parseInt(code, 10); | ||
}); | ||
} | ||
}; | ||
/** | ||
* The agent will use the supportability metrics object if it's | ||
@@ -572,0 +589,0 @@ * available. |
@@ -21,3 +21,4 @@ 'use strict'; | ||
shimmer.wrapMethod(connection, 'connection', 'query', function (query) { | ||
return tracer.callbackProxy(function (sql, values, callback) { | ||
return tracer.segmentProxy(function (sql, values, callback) { | ||
logger.trace("Potentially tracing node-mysql 2 query."); | ||
@@ -29,3 +30,3 @@ if (!tracer.getTransaction() || arguments.length < 1) { | ||
var actualSql, actualCallback; | ||
var actualSql, actualCallback, actualValues; | ||
if (typeof sql === 'object') { | ||
@@ -45,2 +46,3 @@ // function (options, callback) | ||
actualCallback = callback; | ||
actualValues = values; | ||
} | ||
@@ -62,4 +64,3 @@ | ||
transaction.id); | ||
var returned = query.call(this, sql, values, wrapped); | ||
var returned = query.call(this, sql, actualValues, wrapped); | ||
returned.once('end', function () { | ||
@@ -66,0 +67,0 @@ segment.end(); |
@@ -144,2 +144,45 @@ 'use strict'; | ||
/** | ||
* Test whether a URL path should be ignored. | ||
* | ||
* @param {string} path The URL path to test. | ||
* | ||
* @returns {boolean} Whether or not to ignore the path. | ||
*/ | ||
MetricNormalizer.prototype.isIgnored = function isIgnored(path) { | ||
var length = this.rules.length; | ||
for (var i = 0; i < length; i++) { | ||
var rule = this.rules[i]; | ||
if (rule.ignore && rule.matches(path)) { | ||
logger.trace("Ignoring %s because of rule: %j", path, rule); | ||
// prevent deoptimization | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
/** | ||
* Test whether a URL path will be normalized. | ||
* | ||
* @param {string} path The URL path to test. | ||
* | ||
* @returns {boolean} Whether or not any normalization rules match. | ||
*/ | ||
MetricNormalizer.prototype.isNormalized = function isNormalized(path) { | ||
var length = this.rules.length; | ||
for (var i = 0; i < length; i++) { | ||
var rule = this.rules[i]; | ||
if (!rule.ignore && rule.matches(path)) { | ||
logger.trace("Normalizing %s because of rule: %j", path, rule); | ||
// prevent deoptimization | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
/** | ||
* Turn a (scrubbed) URL path into partial metric name. | ||
@@ -149,19 +192,13 @@ * | ||
* | ||
* @returns {string} Either a name, or if the rules say to ignore the | ||
* associated metric, nothing. | ||
* @returns {string} The normalized name. | ||
*/ | ||
MetricNormalizer.prototype.normalize = function (path) { | ||
var last = path | ||
var last = path | ||
, length = this.rules.length | ||
, normalized | ||
; | ||
for (var i = 0; i < this.rules.length; i++) { | ||
for (var i = 0; i < length; i++) { | ||
var rule = this.rules[i]; | ||
if (rule.matches(last)) { | ||
if (rule.ignore) { | ||
logger.trace("Ignoring %s because of rule: %j", path, rule); | ||
// prevent deoptimization | ||
return ''; | ||
} | ||
normalized = rule.apply(last); | ||
@@ -168,0 +205,0 @@ logger.trace("Normalized %s to %s because of rule: %j", last, normalized, rule); |
@@ -100,39 +100,33 @@ 'use strict'; | ||
Transaction.prototype.setName = function (requestURL, statusCode) { | ||
var normalizer; | ||
this.url = urltils.scrub(requestURL); | ||
this.statusCode = statusCode; | ||
var normalizer = this.agent.userNormalizer | ||
, normalized = normalizer.normalize(this.url) | ||
; | ||
// normalization rules can ignore a transaction | ||
if (!normalized) { | ||
this.ignore = true; | ||
// 1. user normalization rules (set in configuration) | ||
normalizer = this.agent.userNormalizer; | ||
if (normalizer.isIgnored(this.url)) this.ignore = true; | ||
// User rules take precedence over the API and router introspection. | ||
// Only override names set via API if rules match. | ||
if (normalizer.isNormalized(this.url)) { | ||
this.partialName = NAMES.NORMALIZED + normalizer.normalize(this.url); | ||
} | ||
// only set the partial name if a user rule was actually applied | ||
else if (normalized !== this.url) { | ||
this.partialName = NAMES.NORMALIZED + normalized; | ||
} | ||
// 2. URL normalization rules (sent by server) | ||
normalizer = this.agent.urlNormalizer; | ||
if (normalizer.isIgnored(this.url)) this.ignore = true; | ||
/* Nothing has already set a name for this transaction, so normalize and | ||
* potentially apply the URL backstop now. | ||
* potentially apply the URL backstop now. Only do so if no user rules | ||
* matched. | ||
*/ | ||
if (!this.partialName) { | ||
this.partialName = this.agent.urlNormalizer.normalize(this.url); | ||
} | ||
if (!this.partialName) this.partialName = normalizer.normalize(this.url); | ||
// the URL normalizer returns no name if a path should be ignored | ||
if (this.partialName) { | ||
normalizer = this.agent.transactionNameNormalizer; | ||
normalized = normalizer.normalize(NAMES.WEB + '/' + this.partialName); | ||
// 3. transaction name normalization rules (sent by server) | ||
normalizer = this.agent.transactionNameNormalizer; | ||
var fullName = NAMES.WEB + '/' + this.partialName; | ||
if (normalizer.isIgnored(fullName)) this.ignore = true; | ||
// Always applied. | ||
this.name = normalizer.normalize(fullName); | ||
if (!normalized) { | ||
this.ignore = true; | ||
} | ||
else { | ||
this.name = normalized; | ||
} | ||
} | ||
// allow the API to explicitly set the ignored status | ||
// Allow the API to explicitly set the ignored status. | ||
if (this.forceIgnore === true || this.forceIgnore === false) { | ||
@@ -139,0 +133,0 @@ this.ignore = this.forceIgnore; |
15
NEWS.md
@@ -0,1 +1,16 @@ | ||
### v1.3.1 (2014-01-31): | ||
* Ignored status codes are now always casted to numbers so that people using | ||
environment-variable configuration or strings in config still get error | ||
status ignored properly. | ||
* If you disabled server-side configuration, the server was still able to | ||
set the value of apdex_t for your app. This was an oversight, and has | ||
been corrected. | ||
* Before, if you had request renaming rules, if the end result was the same | ||
as the match pattern (mapping `/path` to `/path`), they would be silently | ||
ignored. This has been fixed. | ||
* MySQL instrumentation handles callback more consistently, so the transaction | ||
tracer doesn't get confused and stop tracking transactions with MySQL calls | ||
in it. | ||
### v1.3.0 (2014-01-17): | ||
@@ -2,0 +17,0 @@ |
@@ -71,3 +71,7 @@ { | ||
"_id": "bunyan@0.14.6", | ||
"_from": "bunyan@0.14.6" | ||
"dist": { | ||
"shasum": "37047c9e5c4f8bfc2eda66d9c49f261580782a4c" | ||
}, | ||
"_from": "bunyan@0.14.6", | ||
"_resolved": "https://registry.npmjs.org/bunyan/-/bunyan-0.14.6.tgz" | ||
} |
@@ -51,3 +51,7 @@ { | ||
"_id": "async-listener@0.4.5", | ||
"_from": "async-listener@0.4.5" | ||
"dist": { | ||
"shasum": "ea246828799b39db40af0822f6acd5efbd3044ab" | ||
}, | ||
"_from": "async-listener@0.4.5", | ||
"_resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.4.5.tgz" | ||
} |
@@ -43,3 +43,7 @@ { | ||
"_id": "emitter-listener@1.0.1", | ||
"_from": "emitter-listener@1.0.1" | ||
"dist": { | ||
"shasum": "b2499ea6e58230a52c268d5df261eecd9f10fe97" | ||
}, | ||
"_from": "emitter-listener@1.0.1", | ||
"_resolved": "https://registry.npmjs.org/emitter-listener/-/emitter-listener-1.0.1.tgz" | ||
} |
@@ -56,3 +56,7 @@ { | ||
"_id": "continuation-local-storage@2.6.2", | ||
"_from": "continuation-local-storage@2.6.2" | ||
"dist": { | ||
"shasum": "904a9a8dadf4178c8aaf30514f5fe2ba023651cf" | ||
}, | ||
"_from": "continuation-local-storage@2.6.2", | ||
"_resolved": "https://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-2.6.2.tgz" | ||
} |
{ | ||
"name": "newrelic", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"author": "New Relic Node.js agent team <nodejs@newrelic.com>", | ||
@@ -5,0 +5,0 @@ "licenses": [ |
@@ -158,3 +158,3 @@ 'use strict'; | ||
should.exist(tc.error_collector.ignore_status_codes); | ||
expect(tc.error_collector.ignore_status_codes).eql(['401', '404', '502']); | ||
expect(tc.error_collector.ignore_status_codes).eql([401, 404, 502]); | ||
}); | ||
@@ -495,2 +495,3 @@ }); | ||
expect(config.apdex_t).equal(0.1); | ||
config.on('apdex_t', function (value) { expect(value).equal(0.05); }); | ||
config.onConnect({'apdex_t' : 0.05}); | ||
@@ -776,2 +777,3 @@ expect(config.apdex_t).equal(0.05); | ||
expect(config.apdex_t).equal(0.1); | ||
config.on('apdex_t', function () { throw new Error("shouldn't happen"); }); | ||
config.onConnect({'apdex_t' : 0.05}); | ||
@@ -778,0 +780,0 @@ expect(config.apdex_t).equal(0.1); |
@@ -115,3 +115,3 @@ 'use strict'; | ||
it("should correctly ignore a matching name", function () { | ||
it("should ignore a matching name", function () { | ||
normalizer.load([ | ||
@@ -123,3 +123,3 @@ {each_segment : false, eval_order : 0, terminate_chain : true, | ||
return expect(normalizer.normalize('/long_polling')).empty; | ||
expect(normalizer.isIgnored('/long_polling')).equal(true); | ||
}); | ||
@@ -126,0 +126,0 @@ |
@@ -195,5 +195,11 @@ 'use strict'; | ||
trans.setName('/test/string?do=thing&another=thing', 200); | ||
return expect(trans.ignore).true; | ||
expect(trans.ignore).equal(true); | ||
}); | ||
it("should pass through a name when told to by a rule", function () { | ||
agent.userNormalizer.addSimple('^/config', '/config'); | ||
trans.setName('/config', 200); | ||
expect(trans.name).equal('WebTransaction/NormalizedUri/config'); | ||
}); | ||
describe("with no partial name set", function () { | ||
@@ -200,0 +206,0 @@ it("produces a normalized (backstopped) name when status is 200", function () { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1497238
372
31872
389