dynatrace-agent-api
Advanced tools
Comparing version 1.0.0 to 1.1.1
@@ -1,36 +0,69 @@ | ||
'use strict'; | ||
"use strict"; | ||
const debug = require('debug')('dynatrace-agent-api'); | ||
const path = require('path'); | ||
const debug = require("debug")("dynatrace-agent-api"); | ||
const path = require("path"); | ||
// Dummy AgentApi, which acts as a nop | ||
function getDummyAgentApi() { | ||
return { | ||
passContext: function passContext(f) { | ||
return f; | ||
} | ||
}; | ||
} | ||
function findAgent() { | ||
return Object.keys(require('module')._cache).find((m) => { | ||
if(m.includes('nodejsagent.js') && (m.includes('dynatrace') || m.includes('ruxit'))) return m; | ||
return Object.keys(require("module")._cache).find((m) => { | ||
if(m.includes("nodejsagent.js") && (m.includes("dynatrace") || m.includes("ruxit"))) return m; | ||
}) || null; | ||
} | ||
module.exports = function dynatraceAgentAPI() { | ||
let core = null; | ||
function getLegacyAgentApi() { | ||
const agentPath = findAgent(); | ||
if(agentPath) { | ||
core = require(path.dirname(agentPath) + '/lib/core'); | ||
try { | ||
const directAsyncWrap = require(path.dirname(agentPath) + "/lib/core").directAsyncWrap; | ||
if (typeof(directAsyncWrap) !== "function") { | ||
debug("Failed to get core.directAsyncWrap() from agent"); | ||
return null; | ||
} | ||
return { | ||
/** | ||
* Passes context into a callback function (f) | ||
* @param {Function} f | ||
* @returns {Function} | ||
*/ | ||
passContext: function passContext(f) { | ||
const fname = f.prototype ? f.prototype.name : "anonymous function"; | ||
return directAsyncWrap(f, {}, "callback for " + fname); | ||
} | ||
} | ||
} catch (e) { | ||
debug("Failed to require path.dirname(agentPath) + '/lib/core'" + e); | ||
} | ||
} else { | ||
debug("No Dynatrace Node.js agent found."); | ||
debug("No legacy Dynatrace Node.js agent found."); | ||
} | ||
return { | ||
return null; | ||
} | ||
/** | ||
* Passes context into a callback function (f) | ||
* @param {Function} f | ||
* @returns {Function} | ||
*/ | ||
passContext: function passContext(f) { | ||
if(!core) { | ||
return f; | ||
} | ||
const fname = f.prototype ? f.prototype.name : 'anonymous function'; | ||
return core.directAsyncWrap(f, {}, 'callback for ' + fname); | ||
function getAgentApi() { | ||
if (typeof(global.__DT_GETAGENTAPI__) === "function") { | ||
try { | ||
return global.__DT_GETAGENTAPI__(1); | ||
} catch (e) { | ||
debug("Exception getting Dynatrace Agent Api." + e); | ||
} | ||
} | ||
}; | ||
debug("No Dynatrace AgentApi found."); | ||
return null; | ||
} | ||
module.exports = function dynatraceAgentAPI() { | ||
return getAgentApi() || getLegacyAgentApi() || getDummyAgentApi(); | ||
}; |
{ | ||
"name": "dynatrace-agent-api", | ||
"version": "1.0.0", | ||
"version": "1.1.1", | ||
"description": "Node.js bindings for Dynatrace OneAgent", | ||
@@ -26,5 +26,5 @@ "engines":{"node": ">= 4.0.0"}, | ||
"bugs": { | ||
"url": "https://github.com/Dynatrace/sdk-nodejs/issues" | ||
"url": "https://github.com/Dynatrace/nodejs-agent-api/issues" | ||
}, | ||
"homepage": "https://github.com/Dynatrace/sdk-nodejs#readme", | ||
"homepage": "https://github.com/Dynatrace/nodejs-agent-api#readme", | ||
"dependencies": { | ||
@@ -31,0 +31,0 @@ "debug": "^2.2.0" |
@@ -14,2 +14,4 @@ # Node.js API for Dynatrace OneAgent | ||
Deprecated. Please use @dynatrace/agent-api instead. | ||
### Installation | ||
@@ -103,7 +105,7 @@ `$ npm install --save dynatrace-agent-api` | ||
## Disclaimer | ||
This software is experimental and currently NOT SUPPORTED by Dynatrace. | ||
Please use at your own risk. You can contact the author via Github issues. | ||
This module is supported by the Dynatrace Innovation Lab. | ||
Please use the issue tracker to report any problems or ask questions. | ||
## License | ||
Licensed under the MIT License. See the LICENSE file for details. | ||
Licensed under the MIT License. See the LICENSE file for details. |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
8545
58
1
1
110
1