@instana/core
Advanced tools
Comparing version 1.92.0 to 1.92.1
{ | ||
"name": "@instana/core", | ||
"version": "1.92.0", | ||
"version": "1.92.1", | ||
"description": "Core library for Instana's Node.js packages", | ||
@@ -136,3 +136,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "dac6d4a422f16c488ed6c97d6af39be156608e61" | ||
"gitHead": "635093d7c6223da4c5c3b0c0aaf0693ead407689" | ||
} |
@@ -15,3 +15,6 @@ 'use strict'; | ||
exports.init = function() { | ||
// mongodb >= 3.3.x | ||
requireHook.onFileLoad(/\/mongodb\/lib\/core\/connection\/pool.js/, instrumentPool); | ||
// mongodb < 3.3.x | ||
requireHook.onFileLoad(/\/mongodb-core\/lib\/connection\/pool.js/, instrumentPool); | ||
}; | ||
@@ -42,4 +45,4 @@ | ||
// mongodb/lib/core/connection/pool.js#write throws a sync error if there is no callback, so we can safely assume | ||
// there is one. If there isn't one, we wouldn't be able to finish the span, so we won't start one. | ||
// pool.js#write throws a sync error if there is no callback, so we can safely assume there is one. If there no | ||
// callback, we wouldn't be able to finish the span, so we won't start one. | ||
var originalCallback; | ||
@@ -83,21 +86,33 @@ var callbackIndex = -1; | ||
var cmdObj = message ? message.command : null; | ||
if (cmdObj.collection) { | ||
// only getMore commands have the collection attribute | ||
collection = cmdObj.collection; | ||
if ((!hostname || !port) && ctx.options) { | ||
// fallback for older versions of mongodb package | ||
if (!hostname) { | ||
hostname = ctx.options.host; | ||
} | ||
if (!port) { | ||
port = ctx.options.port; | ||
} | ||
} | ||
var cmdObj = message.command; | ||
if (!cmdObj) { | ||
// fallback for older mongodb versions | ||
cmdObj = message.query; | ||
} | ||
if (cmdObj) { | ||
for (var j = 0; j < commands.length; j++) { | ||
if (cmdObj[commands[j]]) { | ||
command = commands[j]; | ||
if (typeof cmdObj[commands[j]] === 'string') { | ||
// most commands (except for getMore) add the collection as the value for the command-specific key | ||
collection = cmdObj[commands[j]]; | ||
} | ||
break; | ||
} | ||
if (cmdObj.collection) { | ||
// only getMore commands have the collection attribute | ||
collection = cmdObj.collection; | ||
} | ||
if (!collection) { | ||
collection = findCollection(cmdObj); | ||
} | ||
command = findCommand(cmdObj); | ||
database = cmdObj.$db; | ||
} | ||
if (!database && typeof message.ns === 'string') { | ||
// fallback for older mongodb versions | ||
database = message.ns.split('.')[0]; | ||
} | ||
} | ||
@@ -153,7 +168,30 @@ | ||
function findCollection(cmdObj) { | ||
for (var j = 0; j < commands.length; j++) { | ||
if (cmdObj[commands[j]] && typeof cmdObj[commands[j]] === 'string') { | ||
// most commands (except for getMore) add the collection as the value for the command-specific key | ||
return cmdObj[commands[j]]; | ||
} | ||
} | ||
} | ||
function findCommand(cmdObj) { | ||
for (var j = 0; j < commands.length; j++) { | ||
if (cmdObj[commands[j]]) { | ||
return commands[j]; | ||
} | ||
} | ||
} | ||
function readJsonOrFilter(message, span) { | ||
if (!message || !message.command) { | ||
if (!message) { | ||
return; | ||
} | ||
var cmdObj = message.command; | ||
if (!cmdObj) { | ||
cmdObj = message.query; | ||
} | ||
if (!cmdObj) { | ||
return; | ||
} | ||
var json; | ||
@@ -160,0 +198,0 @@ var filter = cmdObj.filter || cmdObj.query; |
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
323077
8761