appdynamics 23.7.0 → 23.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/appdynamics_version.json +2 -2
- package/lib/core/agent.js +27 -2
- package/lib/libagent/libagent-connector.js +2 -4
- package/lib/libagent/libagent.js +3 -2
- package/lib/probes/apollo-entry-probe.js +64 -6
- package/lib/probes/http-entry-probe.js +11 -0
- package/lib/probes/http-probe.js +26 -8
- package/package.json +4 -4
- package/packageBck.json +4 -4
package/appdynamics_version.json
CHANGED
package/lib/core/agent.js
CHANGED
|
@@ -163,6 +163,27 @@ Agent.computeTmpDir = function (rootTmpDir,
|
|
|
163
163
|
return path.join(rootTmpDir, sha256.digest('hex').slice(0, 32));
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
+
Agent.prototype.setKubernetesConfig = function() {
|
|
167
|
+
var self = this;
|
|
168
|
+
try {
|
|
169
|
+
const NSPACE_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/namespace";
|
|
170
|
+
|
|
171
|
+
let clusterService = (process.env.APPDYNAMICS_CONTAINERINFO_FETCH_SERVICE).split(":");
|
|
172
|
+
if(clusterService.length != 2) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
self.opts.kbHost = clusterService[0];
|
|
177
|
+
self.opts.kbPort = parseInt(clusterService[1]);
|
|
178
|
+
self.opts.kbPodName = process.env.HOSTNAME;
|
|
179
|
+
self.opts.kbContainerName = process.env.APPDYNAMICS_CONTAINER_NAME;
|
|
180
|
+
self.opts.kbNspace = fs.readFileSync(NSPACE_PATH, 'utf-8').trim();
|
|
181
|
+
self.opts.kbConfigEnabled = true;
|
|
182
|
+
} catch(err) {
|
|
183
|
+
self.logger.warn('Kubernetes containerid disabled due to' + err + '\n' + err.stack);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
166
187
|
/* istanbul ignore next -- requires too much stubbing and mocking to unit test */
|
|
167
188
|
Agent.prototype.init = function (opts) {
|
|
168
189
|
var self = this;
|
|
@@ -177,6 +198,10 @@ Agent.prototype.init = function (opts) {
|
|
|
177
198
|
|
|
178
199
|
self.opts.clsDisabled = !!self.opts.clsDisabled;
|
|
179
200
|
|
|
201
|
+
if(process.env.APPDYNAMICS_CONTAINERINFO_FETCH_SERVICE) {
|
|
202
|
+
self.setKubernetesConfig();
|
|
203
|
+
}
|
|
204
|
+
|
|
180
205
|
self.backendConnector = new LibAgent(this);
|
|
181
206
|
|
|
182
207
|
if (opts.openTelemetry && opts.openTelemetry.enabled) {
|
|
@@ -225,7 +250,7 @@ Agent.prototype.init = function (opts) {
|
|
|
225
250
|
self.logger.error('AppDynamics agent cannot be started: node name/node name prefix is either missing or empty');
|
|
226
251
|
return;
|
|
227
252
|
}
|
|
228
|
-
|
|
253
|
+
|
|
229
254
|
var nodeName;
|
|
230
255
|
if(self.opts.nodeName && self.opts.nodeName.length) {
|
|
231
256
|
nodeName = self.opts.nodeName;
|
|
@@ -363,8 +388,8 @@ Agent.prototype.initializeOpts = function (opts) {
|
|
|
363
388
|
if (self.opts.analyticsMaxMessageSizeInBytes === undefined && process.env.APPDYNAMICS_ANALYTICS_MAX_MESSAGE_SIZE) {
|
|
364
389
|
self.opts.analyticsMaxMessageSizeInBytes = parseInt(process.env.APPDYNAMICS_ANALYTICS_MAX_MESSAGE_SIZE, 10);
|
|
365
390
|
}
|
|
366
|
-
};
|
|
367
391
|
|
|
392
|
+
};
|
|
368
393
|
|
|
369
394
|
Agent.prototype.fetchMetadata = function (cb) {
|
|
370
395
|
var self = this, key;
|
|
@@ -99,7 +99,6 @@ LibagentConnector.prototype.initLogger = function () {
|
|
|
99
99
|
|
|
100
100
|
LibagentConnector.prototype.init = function () {
|
|
101
101
|
var self = this;
|
|
102
|
-
|
|
103
102
|
// initialize protobuf
|
|
104
103
|
self.protobufModel = new ProtobufModel(self.agent);
|
|
105
104
|
self.protobufModel.init();
|
|
@@ -108,7 +107,6 @@ LibagentConnector.prototype.init = function () {
|
|
|
108
107
|
|
|
109
108
|
self.libagent.init(self.agent);
|
|
110
109
|
self.agent.TracerProvider && self.agent.TracerProvider.updateResourceAttributes({ "container.id": self.getContainerId() });
|
|
111
|
-
|
|
112
110
|
self.exceptionHandlers = new ExceptionHandlers();
|
|
113
111
|
self.exceptionHandlers.init(
|
|
114
112
|
self.agent,
|
|
@@ -257,7 +255,7 @@ LibagentConnector.prototype.startExitCall = function (transaction, exitCall) {
|
|
|
257
255
|
|
|
258
256
|
LibagentConnector.prototype.disableResolutionForExitCall = function (exitCall) {
|
|
259
257
|
var self = this;
|
|
260
|
-
|
|
258
|
+
|
|
261
259
|
if(!self.agent.profiler.isValidThreadId(exitCall.threadId)) {
|
|
262
260
|
return;
|
|
263
261
|
}
|
|
@@ -580,7 +578,7 @@ LibagentConnector.prototype.setupEum = function (agent) {
|
|
|
580
578
|
var libAgentConnector = this;
|
|
581
579
|
agent.eum.eumCookie.prototype.setFieldValues = function () {
|
|
582
580
|
var self = this;
|
|
583
|
-
|
|
581
|
+
|
|
584
582
|
if(!agent.profiler.isValidThreadId(self.transaction.threadId)) {
|
|
585
583
|
return false;
|
|
586
584
|
}
|
package/lib/libagent/libagent.js
CHANGED
|
@@ -18,6 +18,7 @@ function LibAgent(agent) {
|
|
|
18
18
|
self.agent.libagentConnector.init();
|
|
19
19
|
});
|
|
20
20
|
this.nodeIndexComputed = false;
|
|
21
|
+
|
|
21
22
|
// For unit-testing
|
|
22
23
|
this.libagent = true;
|
|
23
24
|
}
|
|
@@ -50,11 +51,11 @@ LibAgent.prototype.addNodeIndexToNodeName = function() {
|
|
|
50
51
|
if (process.argv.filter(arg => arg.includes("yarn")).length !== 0) {
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
|
|
54
55
|
if (process.argv.filter(arg => arg.includes("npm")).length !== 0) {
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
|
-
}
|
|
58
|
+
}
|
|
58
59
|
// create or update node name
|
|
59
60
|
var computedNodeName = (self.agent.opts.nodeName || os.hostname());
|
|
60
61
|
if (!self.agent.opts.noNodeNameSuffix) {
|
|
@@ -12,13 +12,25 @@ function ApolloEntryProbe(agent) {
|
|
|
12
12
|
|
|
13
13
|
ApolloEntryProbe.prototype.init = function () {};
|
|
14
14
|
|
|
15
|
-
ApolloEntryProbe.prototype.attach = function (obj) {
|
|
15
|
+
ApolloEntryProbe.prototype.attach = function (obj, moduleName) {
|
|
16
|
+
|
|
16
17
|
let self = this;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
|
|
19
|
+
if(moduleName == 'apollo-server') {
|
|
20
|
+
self.agent.proxy.before(
|
|
21
|
+
obj.ApolloServer.prototype,
|
|
22
|
+
"createServerInfo",
|
|
23
|
+
(args) => this.addLifeCycleHooks(args)
|
|
24
|
+
);
|
|
25
|
+
} else {
|
|
26
|
+
const originalObject = obj;
|
|
27
|
+
const overriddenObject = {};
|
|
28
|
+
|
|
29
|
+
overriddenObject.startStandaloneServer = proxyStartStandaloneServer(self, originalObject);
|
|
30
|
+
overriddenObject.__proto__ = originalObject;
|
|
31
|
+
return overriddenObject;
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
};
|
|
23
35
|
|
|
24
36
|
ApolloEntryProbe.prototype.addLifeCycleHooks = function (obj) {
|
|
@@ -67,3 +79,49 @@ ApolloEntryProbe.prototype.addLifeCycleHooks = function (obj) {
|
|
|
67
79
|
...obj.plugins,
|
|
68
80
|
];
|
|
69
81
|
};
|
|
82
|
+
|
|
83
|
+
function proxyStartStandaloneServer(self, originalObject) {
|
|
84
|
+
|
|
85
|
+
return async function startStandaloneServerProxy(server, options) {
|
|
86
|
+
const overriddenOptions = options || {};
|
|
87
|
+
|
|
88
|
+
const context = options ? options.context : undefined;
|
|
89
|
+
const overriddenContext = async function (contextParam) {
|
|
90
|
+
const contextValue = context ? await context(contextParam) : {};
|
|
91
|
+
contextValue.gqlReq = contextParam.req;
|
|
92
|
+
contextValue.gqlRes = contextParam.res;
|
|
93
|
+
return contextValue;
|
|
94
|
+
};
|
|
95
|
+
overriddenOptions.context = overriddenContext;
|
|
96
|
+
|
|
97
|
+
const plugin = {
|
|
98
|
+
async requestDidStart() {
|
|
99
|
+
return {
|
|
100
|
+
didResolveOperation(requestContext) {
|
|
101
|
+
requestContext.contextValue.gqlReq.graphqlop = requestContext.operationName;
|
|
102
|
+
requestContext.contextValue.gqlReq.transactionStarted = true;
|
|
103
|
+
|
|
104
|
+
HttpCommon.startTransactionHandler(
|
|
105
|
+
requestContext.contextValue.gqlReq,
|
|
106
|
+
requestContext.contextValue.gqlRes,
|
|
107
|
+
self.agent
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
didEncounterErrors(requestContext) {
|
|
111
|
+
requestContext.contextValue.gqlRes.error = requestContext.errors[0];
|
|
112
|
+
if(requestContext.contextValue.gqlReq.transactionStarted) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
HttpCommon.startTransactionHandler(
|
|
116
|
+
requestContext.contextValue.gqlReq,
|
|
117
|
+
requestContext.contextValue.gqlRes,
|
|
118
|
+
self.agent
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
server.addPlugin(plugin);
|
|
125
|
+
return await originalObject.startStandaloneServer(server, overriddenOptions);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -8,6 +8,7 @@ All Rights Reserved
|
|
|
8
8
|
var utility = require("../utility");
|
|
9
9
|
var HttpCommon = require("./http-common");
|
|
10
10
|
var getGraphQLParams;
|
|
11
|
+
var parseRequestParams;
|
|
11
12
|
|
|
12
13
|
function HttpEntryProbe(agent) {
|
|
13
14
|
this.agent = agent;
|
|
@@ -21,6 +22,10 @@ HttpEntryProbe.prototype.enableGraphQL = function (egql) {
|
|
|
21
22
|
getGraphQLParams = egql.getGraphQLParams;
|
|
22
23
|
};
|
|
23
24
|
|
|
25
|
+
HttpEntryProbe.prototype.enableGraphQLHttp = function (obj) {
|
|
26
|
+
parseRequestParams = obj.parseRequestParams;
|
|
27
|
+
};
|
|
28
|
+
|
|
24
29
|
HttpEntryProbe.prototype.attach = function (obj, moduleName) {
|
|
25
30
|
var self = this;
|
|
26
31
|
|
|
@@ -71,6 +76,12 @@ HttpEntryProbe.prototype.__createRequestHandler = function (callback, isHTTPs) {
|
|
|
71
76
|
}
|
|
72
77
|
self.agent.context.run(requestHandler, req, res);
|
|
73
78
|
});
|
|
79
|
+
} else if (parseRequestParams) {
|
|
80
|
+
parseRequestParams(req).then(function(params) {
|
|
81
|
+
const { operationName } = params;
|
|
82
|
+
req.graphqlop = operationName;
|
|
83
|
+
});
|
|
84
|
+
self.agent.context.run(requestHandler, req, res);
|
|
74
85
|
} else {
|
|
75
86
|
if (
|
|
76
87
|
self.agent.opts.enableGraphQL
|
package/lib/probes/http-probe.js
CHANGED
|
@@ -9,9 +9,17 @@ var HttpEntryProbe = require('./http-entry-probe').HttpEntryProbe;
|
|
|
9
9
|
var HttpExitProbe = require('./http-exit-probe').HttpExitProbe;
|
|
10
10
|
var ApolloEntryProbe = require('./apollo-entry-probe').ApolloEntryProbe;
|
|
11
11
|
|
|
12
|
+
const graphQLHttpImplementationPaths = [
|
|
13
|
+
'graphql-http/lib/use/http',
|
|
14
|
+
'graphql-http/lib/use/http2',
|
|
15
|
+
'graphql-http/lib/use/express'
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const apolloPackages = ['apollo-server', '@apollo/server/standalone'];
|
|
19
|
+
|
|
12
20
|
function HttpProbe(agent) {
|
|
13
21
|
this.agent = agent;
|
|
14
|
-
this.packages = ['http', 'https', 'express-graphql',
|
|
22
|
+
this.packages = ['http', 'https', 'express-graphql', ...apolloPackages, ...graphQLHttpImplementationPaths];
|
|
15
23
|
|
|
16
24
|
this.entryProbe = new HttpEntryProbe(agent);
|
|
17
25
|
this.exitProbe = new HttpExitProbe(agent);
|
|
@@ -33,17 +41,19 @@ HttpProbe.prototype.attach = function (obj, moduleName) {
|
|
|
33
41
|
|
|
34
42
|
if (obj.__appdynamicsProbeAttached__) return;
|
|
35
43
|
obj.__appdynamicsProbeAttached__ = true;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
|
|
45
|
+
if(moduleName == 'http' || moduleName == 'https') {
|
|
46
|
+
// Skipping destroy for graphql-http modules as we do not modify them
|
|
47
|
+
self.agent.on('destroy', function () {
|
|
48
|
+
if (obj.__appdynamicsProbeAttached__) {
|
|
49
|
+
delete obj.__appdynamicsProbeAttached__;
|
|
40
50
|
proxy.release(obj.Server.prototype.on);
|
|
41
51
|
proxy.release(obj.Server.prototype.addListener);
|
|
42
52
|
proxy.release(obj.request);
|
|
43
53
|
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
if (moduleName === 'express-graphql') {
|
|
48
58
|
if (self.agent.opts.enableGraphQL) {
|
|
49
59
|
this.entryProbe.enableGraphQL(obj);
|
|
@@ -52,6 +62,14 @@ HttpProbe.prototype.attach = function (obj, moduleName) {
|
|
|
52
62
|
if(self.agent.opts.enableGraphQL) {
|
|
53
63
|
this.apolloEntryProbe.attach(obj, moduleName);
|
|
54
64
|
}
|
|
65
|
+
} else if (moduleName === '@apollo/server/standalone') {
|
|
66
|
+
if(self.agent.opts.enableGraphQL) {
|
|
67
|
+
return this.apolloEntryProbe.attach(obj, moduleName);
|
|
68
|
+
}
|
|
69
|
+
} else if (moduleName.includes('graphql-http')) {
|
|
70
|
+
if(self.agent.opts.enableGraphQL) {
|
|
71
|
+
this.entryProbe.enableGraphQLHttp(obj);
|
|
72
|
+
}
|
|
55
73
|
} else {
|
|
56
74
|
this.entryProbe.attach(obj, moduleName);
|
|
57
75
|
this.exitProbe.attach(obj, moduleName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appdynamics",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.10.0",
|
|
4
4
|
"description": "Performance Profiler and Monitor",
|
|
5
5
|
"author": "AppDynamics, Inc.",
|
|
6
6
|
"homepage": "https://www.appdynamics.com",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"https-proxy-agent": "^5.0.0",
|
|
47
47
|
"uuid": "^8.3.2",
|
|
48
48
|
"y18n": "^5.0.8",
|
|
49
|
-
"appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/23.
|
|
50
|
-
"appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/23.
|
|
51
|
-
"appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/23.
|
|
49
|
+
"appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/23.10.0.0/appdynamics-libagent-napi-node.tgz",
|
|
50
|
+
"appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/23.10.0.0/appdynamics-native-node.tgz",
|
|
51
|
+
"appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/23.10.0.0/appdynamics-protobuf-node.tgz"
|
|
52
52
|
},
|
|
53
53
|
"overrides": {
|
|
54
54
|
"semver": "7.5.4"
|
package/packageBck.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appdynamics",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.10.0",
|
|
4
4
|
"description": "Performance Profiler and Monitor",
|
|
5
5
|
"author": "AppDynamics, Inc.",
|
|
6
6
|
"homepage": "https://www.appdynamics.com",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"https-proxy-agent": "^5.0.0",
|
|
47
47
|
"uuid": "^8.3.2",
|
|
48
48
|
"y18n": "^5.0.8",
|
|
49
|
-
"appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/23.
|
|
50
|
-
"appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/23.
|
|
51
|
-
"appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/23.
|
|
49
|
+
"appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/23.10.0.0/appdynamics-libagent-napi-node.tgz",
|
|
50
|
+
"appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/23.10.0.0/appdynamics-native-node.tgz",
|
|
51
|
+
"appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/23.10.0.0/appdynamics-protobuf-node.tgz"
|
|
52
52
|
},
|
|
53
53
|
"overrides": {
|
|
54
54
|
"semver": "7.5.4"
|