Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dynatrace-agent-api

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynatrace-agent-api - npm Package Compare versions

Comparing version 1.0.0 to 1.1.1

77

lib/index.js

@@ -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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc