appdynamics 21.9.0 → 22.2.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.
@@ -43,18 +43,33 @@ MongodbProbe.prototype.attach = function (obj) {
43
43
  if (obj.__appdynamicsProbeAttached__) {
44
44
  delete obj.__appdynamicsProbeAttached__;
45
45
  }
46
-
47
46
  proxy.release(obj.Db.prototype.createCollection);
48
47
  proxy.release(obj.Db.prototype.dropCollection);
49
- proxy.release(obj.Server.prototype.cursor);
50
- proxy.release(obj.Server.prototype.insert);
51
- proxy.release(obj.Server.prototype.update);
52
- proxy.release(obj.Server.prototype.remove);
53
- proxy.release(obj.ReplSet.prototype.cursor);
54
- proxy.release(obj.ReplSet.prototype.insert);
55
- proxy.release(obj.ReplSet.prototype.update);
56
- proxy.release(obj.ReplSet.prototype.remove);
57
- proxy.release(obj.Cursor.prototype._next);
48
+ if(obj.Server){
49
+ proxy.release(obj.Server.prototype.cursor);
50
+ proxy.release(obj.Server.prototype.insert);
51
+ proxy.release(obj.Server.prototype.update);
52
+ proxy.release(obj.Server.prototype.remove);
53
+ }
54
+ if(obj.ReplSet){
55
+ proxy.release(obj.ReplSet.prototype.cursor);
56
+ proxy.release(obj.ReplSet.prototype.insert);
57
+ proxy.release(obj.ReplSet.prototype.update);
58
+ proxy.release(obj.ReplSet.prototype.remove);
59
+ }
60
+ if(obj.Cursor){
61
+ proxy.release(obj.Cursor.prototype.next);
62
+ }
63
+ if(obj.Collection){
64
+ proxy.release(obj.Collection.prototype.find);
65
+ proxy.release(obj.Collection.prototype.insert);
66
+ proxy.release(obj.Collection.prototype.aggregate);
67
+ proxy.release(obj.Collection.prototype.remove);
68
+ proxy.release(obj.Collection.prototype.update);
69
+ }
70
+ if(obj.AbstractCursor){
71
+ proxy.release(obj.AbstractCursor.prototype.next);
72
+ }
58
73
  });
59
74
 
60
75
  if ('instrument' in obj) {
@@ -138,127 +153,200 @@ MongodbProbe.prototype.attach = function (obj) {
138
153
  collectionCommands.forEach(function (command) {
139
154
  proxy.before(obj.Db.prototype, command, withAPMBeforeHandler);
140
155
  });
141
- } else if (!('version' in obj) && obj.Cursor) {
142
- // driver 2.x w/out APM API
143
- var commands = ['cursor', 'insert', 'update', 'remove'];
144
-
145
- // queries via a cursor find command must be reported after they complete:
146
- proxy.around(obj.Cursor.prototype, '_next', function (obj, args, locals) {
147
- locals.methodHasCb = proxy.callback(args, -1, function (obj_, args) {
148
- complete(args, obj);
149
- });
150
- }, after);
156
+ } else if (!('version' in obj)) {
157
+ if (obj.Cursor){
158
+ // driver 2.x w/out APM API
159
+ var commands = ['cursor', 'insert', 'update', 'remove'];
160
+
161
+ // queries via a cursor find command must be reported after they complete:
162
+ proxy.around(obj.Cursor.prototype, '_next', function (obj, args, locals) {
163
+ locals.methodHasCb = proxy.callback(args, -1, function (obj_, args) {
164
+ complete(args, obj);
165
+ });
166
+ }, after);
167
+
168
+ collectionCommands.forEach(function (command) {
169
+ function withoutAPMBeforeHandler(obj, args, locals) {
170
+ var commandDetails;
171
+ var category;
172
+ var commandName = command == 'cursor' ? 'find' : command;
173
+
174
+ if (command == 'cursor' && !args[1].find) return;
175
+ var serverPool = [];
176
+ if (obj.serverConfig instanceof mongoObj.ReplSet)
177
+ serverPool = self.getServerPool(obj.serverConfig.s, true);
178
+ else
179
+ serverPool = self.getServerPool(obj);
180
+ if (serverPool.length) {
181
+ commandDetails = {
182
+ command: commandName,
183
+ databaseName: obj.s.databaseName,
184
+ collectionName: args[0]
185
+ };
186
+
187
+ if (obj.auths && obj.auths.length > 0) {
188
+ commandDetails.auth = obj.auths[0];
189
+ }
151
190
 
152
- collectionCommands.forEach(function (command) {
153
- function withoutAPMBeforeHandler(obj, args, locals) {
154
- var commandDetails;
155
- var category;
156
- var commandName = command == 'cursor' ? 'find' : command;
191
+ category = "write";
157
192
 
158
- if (command == 'cursor' && !args[1].find) return;
159
- var serverPool = [];
160
- if (obj.serverConfig instanceof mongoObj.ReplSet)
161
- serverPool = self.getServerPool(obj.serverConfig.s, true);
162
- else
163
- serverPool = self.getServerPool(obj);
164
- if (serverPool.length) {
165
- commandDetails = {
166
- command: commandName,
167
- databaseName: obj.s.databaseName,
168
- collectionName: args[0]
169
- };
193
+ locals.time = profiler.time();
170
194
 
171
- if (obj.auths && obj.auths.length > 0) {
172
- commandDetails.auth = obj.auths[0];
195
+ locals.exitCall = self.createExitCall(locals.time, serverPool,
196
+ commandDetails, category, profiler.stackTrace());
173
197
  }
174
198
 
175
- category = "write";
176
-
177
- locals.time = profiler.time();
178
-
179
- locals.exitCall = self.createExitCall(locals.time, serverPool,
180
- commandDetails, category, profiler.stackTrace());
199
+ locals.methodHasCb = proxy.callback(args, -1, function (obj, args) {
200
+ self.addExitCall(locals.time, locals.exitCall, args);
201
+ });
181
202
  }
182
203
 
183
- locals.methodHasCb = proxy.callback(args, -1, function (obj, args) {
184
- self.addExitCall(locals.time, locals.exitCall, args);
185
- });
186
- }
187
-
188
- proxy.around(obj.Db.prototype, command, withoutAPMBeforeHandler, withoutAPMAfterHandler);
189
- });
204
+ proxy.around(obj.Db.prototype, command, withoutAPMBeforeHandler, withoutAPMAfterHandler);
205
+ });
190
206
 
191
- commands.forEach(function (command) {
192
- var commandName = command == 'cursor' ? 'find' : command;
193
- function withoutAPMBeforeHandler(obj, args, locals) {
194
- var commandDetails;
195
- var category;
196
- var opts = {};
197
- var query = '';
207
+ commands.forEach(function (command) {
208
+ var commandName = command == 'cursor' ? 'find' : command;
209
+ function withoutAPMBeforeHandler(obj, args, locals) {
210
+ var commandDetails;
211
+ var category;
212
+ var opts = {};
213
+ var query = '';
214
+
215
+ if (command == 'cursor' && !args[1].find) return;
216
+
217
+ var serverPool = [];
218
+ if (obj instanceof mongoObj.ReplSet)
219
+ serverPool = self.getServerPool(obj.s, true);
220
+ else
221
+ serverPool = self.getServerPool(obj.s);
222
+ if (serverPool.length) {
223
+ opts = {};
224
+ if (args[1] && args[1].query) {
225
+ query = args[1].query;
226
+ if (Object.prototype.toString.call(query) == "[object Object]") {
227
+ query = utility.filterSensitiveDataFromObject(Object.assign({}, args[1].query));
228
+ }
229
+ query = profiler.sanitize(JSON.stringify(query));
230
+ Object.keys(args[1]).forEach(function (key) {
231
+ if (key !== 'query') {
232
+ opts[key] = args[1][key];
233
+ }
234
+ });
235
+ }
198
236
 
199
- if (command == 'cursor' && !args[1].find) return;
237
+ commandDetails = {
238
+ command: commandName,
239
+ databaseName: args[0].split('.')[0],
240
+ collectionName: args[0].split('.')[1],
241
+ query: query,
242
+ numberToSkip: opts.skip,
243
+ numberToReturn: opts.limit
244
+ };
245
+
246
+ if (obj.s.auths && obj.s.auths.length > 0) {
247
+ commandDetails.auth = obj.s.auths[0];
248
+ }
200
249
 
201
- var serverPool = [];
202
- if (obj instanceof mongoObj.ReplSet)
203
- serverPool = self.getServerPool(obj.s, true);
204
- else
205
- serverPool = self.getServerPool(obj.s);
206
- if (serverPool.length) {
207
- opts = {};
208
- if (args[1] && args[1].query) {
209
- query = args[1].query;
210
- if (Object.prototype.toString.call(query) == "[object Object]") {
211
- query = utility.filterSensitiveDataFromObject(Object.assign({}, args[1].query));
250
+ if (commandName == 'find') {
251
+ category = "read";
252
+ } else {
253
+ category = "write";
212
254
  }
213
- query = profiler.sanitize(JSON.stringify(query));
214
- Object.keys(args[1]).forEach(function (key) {
215
- if (key !== 'query') {
216
- opts[key] = args[1][key];
217
- }
218
- });
219
- }
220
255
 
221
- commandDetails = {
222
- command: commandName,
223
- databaseName: args[0].split('.')[0],
224
- collectionName: args[0].split('.')[1],
225
- query: query,
226
- numberToSkip: opts.skip,
227
- numberToReturn: opts.limit
228
- };
256
+ locals.time = profiler.time();
229
257
 
230
- if (obj.s.auths && obj.s.auths.length > 0) {
231
- commandDetails.auth = obj.s.auths[0];
258
+ locals.exitCall = self.createExitCall(locals.time, serverPool,
259
+ commandDetails, category, profiler.stackTrace());
232
260
  }
233
261
 
234
262
  if (commandName == 'find') {
235
- category = "read";
263
+ // stash exit call for later processing
264
+ args[1].__appd_exitcall_info = {
265
+ time: locals.time,
266
+ exitCall: locals.exitCall
267
+ };
268
+ locals.methodHasCb = true;
236
269
  } else {
237
- category = "write";
270
+ locals.methodHasCb = proxy.callback(args, -1, function (obj, args) {
271
+ self.addExitCall(locals.time, locals.exitCall, args);
272
+ }, null, self.agent.thread.current());
238
273
  }
239
-
240
- locals.time = profiler.time();
241
-
242
- locals.exitCall = self.createExitCall(locals.time, serverPool,
243
- commandDetails, category, profiler.stackTrace());
244
274
  }
275
+ proxy.around(obj.Server.prototype, command, withoutAPMBeforeHandler, withoutAPMAfterHandler);
276
+ proxy.around(obj.ReplSet.prototype, command, withoutAPMBeforeHandler, withoutAPMAfterHandler);
277
+ });
278
+ }
279
+ else{
280
+ proxy.before(obj.MongoClient.prototype, 'connect', function(obj){
281
+ obj.monitorCommands = true;
282
+ var newServerPool;
283
+ var newOpQueue = {};
284
+ var newApmCollectionEvents = ['create', 'drop'];
285
+ var newCollectionCommandMap = {
286
+ 'create': 'createCollection',
287
+ 'drop': 'dropCollection',
288
+ 'find': 'find',
289
+ 'cursor': 'cursor',
290
+ 'insert': 'insert',
291
+ 'update': 'update',
292
+ 'remove': 'remove',
293
+ 'aggregate': 'aggregate'
294
+ };
295
+ var newSupportedCommands = ['find', 'cursor', 'insert', 'update', 'remove', 'aggregate'].concat(newApmCollectionEvents);
296
+
297
+ // expose opQueue for integration testing
298
+ self.__opQueue = newOpQueue;
299
+ obj.on('commandStarted', (event) => {
300
+ var requestId = event.requestId, newRequest, newCommandQuery;
301
+ if (newSupportedCommands.indexOf(event.commandName) < 0) return;
302
+ if (event.address) {
303
+ newServerPool = [event.address];
304
+ }
305
+ if (newServerPool) {
306
+ if (!newOpQueue[requestId]) {
307
+ newOpQueue[requestId] = {
308
+ time: profiler.time(),
309
+ serverPool: newServerPool
310
+ };
311
+ }
312
+ newRequest = newOpQueue[requestId];
313
+ newCommandQuery = event.command.filter;
314
+ if (event.command.filter && Object.prototype.toString.call(event.command.filter) == "[object Object]") {
315
+ newCommandQuery = utility.filterSensitiveDataFromObject(utility.deepCopy(event.command.filter));
316
+ }
317
+ var commandDetails = {
318
+ command: newCollectionCommandMap[event.commandName],
319
+ databaseName: event.databaseName,
320
+ collectionName: event.command[event.commandName],
321
+ query: profiler.sanitize(JSON.stringify(newCommandQuery)),
322
+ numberToSkip: event.command.skip,
323
+ numberToReturn: event.command.limit
324
+ };
325
+
326
+
327
+ newRequest.exitCall = self.createExitCall(newRequest.time, newServerPool,
328
+ commandDetails, event.commandName == 'find' ? 'read' : 'write',
329
+ profiler.stackTrace());
330
+ }
331
+ });
245
332
 
246
- if (commandName == 'find') {
247
- // stash exit call for later processing
248
- args[1].__appd_exitcall_info = {
249
- time: locals.time,
250
- exitCall: locals.exitCall
251
- };
252
- locals.methodHasCb = true;
253
- } else {
254
- locals.methodHasCb = proxy.callback(args, -1, function (obj, args) {
255
- self.addExitCall(locals.time, locals.exitCall, args);
256
- }, null, self.agent.thread.current());
257
- }
258
- }
259
- proxy.around(obj.Server.prototype, command, withoutAPMBeforeHandler, withoutAPMAfterHandler);
260
- proxy.around(obj.ReplSet.prototype, command, withoutAPMBeforeHandler, withoutAPMAfterHandler);
261
- });
333
+ obj.on('commandSucceeded', function (event) {
334
+ var requestId = event.requestId, newRequest = newOpQueue[requestId];
335
+ if (newRequest) {
336
+ self.addExitCall(newRequest.time, newRequest.exitCall);
337
+ newOpQueue[requestId] = undefined;
338
+ }
339
+ });
340
+
341
+ obj.on('commandFailed', function (event) {
342
+ var requestId = event.requestId, newRequest = newOpQueue[requestId];
343
+ if (newRequest) {
344
+ self.addExitCall(event.time, event.exitCall, event.failure);
345
+ newOpQueue[requestId] = undefined;
346
+ }
347
+ });
348
+ });
349
+ }
262
350
  }
263
351
 
264
352
  function complete(err, obj, driver) {
@@ -356,11 +444,10 @@ MongodbProbe.prototype.createExitCall = function (time, serverPool, commandDetai
356
444
  MongodbProbe.prototype.addExitCall = function (time, exitCall, args) {
357
445
  var self = this;
358
446
  if (!time || !time.done()) return;
359
-
360
447
  var error = self.agent.proxy.getErrorObject(args);
361
448
  var profiler = self.agent.profiler;
362
449
 
363
450
  if (exitCall) {
364
451
  profiler.addExitCall(time, exitCall, error);
365
452
  }
366
- };
453
+ };
@@ -84,7 +84,7 @@ Profiler.prototype.formatStackTrace = function (err) {
84
84
  };
85
85
 
86
86
 
87
- Profiler.prototype.startTransaction = function (time, req, entryType) {
87
+ Profiler.prototype.startTransaction = function(time, req, entryType, baggageCorrHeader) {
88
88
  var self = this;
89
89
 
90
90
  var transaction = new Transaction();
@@ -101,6 +101,10 @@ Profiler.prototype.startTransaction = function (time, req, entryType) {
101
101
  parsedParameterString: req.url ? url.parse(req.url).query : ''
102
102
  };
103
103
 
104
+ if(baggageCorrHeader) {
105
+ transaction.baggageCorrHeader = baggageCorrHeader;
106
+ }
107
+
104
108
  self.transactions[time.threadId] = transaction;
105
109
 
106
110
  var delayedCallbackAttached = false;
package/lib/utility.js CHANGED
@@ -1,3 +1,6 @@
1
+ var url = require('url');
2
+
3
+
1
4
  function filterSensitiveDataFromObject(objIns) {
2
5
  if (objIns && Object.prototype.toString.call(objIns) == "[object Object]") {
3
6
  Object.keys(objIns).forEach(function (key) {
@@ -21,5 +24,21 @@ function deepCopy(origObject) {
21
24
  return cpObj;
22
25
  }
23
26
 
27
+ function createBtNamingWrapper(req) {
28
+ // TODO: replace these with boost::regex in libagent bindings
29
+ if (req.url) {
30
+ var parsedUrl = url.parse(req.url);
31
+ req.parsedPathName = parsedUrl.pathname;
32
+ req.parsedParameterString = parsedUrl.query;
33
+ }
34
+ return req;
35
+ }
36
+
37
+ const constants = {
38
+ GRAPHQL_QUERY_TYPE: "gql"
39
+ };
40
+
41
+ module.exports.createBtNamingWrapper = createBtNamingWrapper;
24
42
  module.exports.filterSensitiveDataFromObject = filterSensitiveDataFromObject;
25
- module.exports.deepCopy = deepCopy;
43
+ module.exports.deepCopy = deepCopy;
44
+ module.exports.constants = constants;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appdynamics",
3
- "version": "21.9.0",
3
+ "version": "22.2.0",
4
4
  "description": "Performance Profiler and Monitor",
5
5
  "author": "AppDynamics, Inc.",
6
6
  "homepage": "https://www.appdynamics.com",
@@ -34,15 +34,18 @@
34
34
  "n": "^6.7.0"
35
35
  },
36
36
  "dependencies": {
37
+ "@opentelemetry/api": "^1.0.3",
38
+ "@opentelemetry/exporter-collector": "^0.25.0",
39
+ "@opentelemetry/node": "^0.24.0",
40
+ "@opentelemetry/semantic-conventions": "^1.0.1",
41
+ "@opentelemetry/tracing": "^0.24.0",
37
42
  "cls-hooked": "4.2.2",
38
- "log4js": "0.6.38",
39
43
  "n": "^6.7.0",
40
- "set-immediate": "0.1.1",
41
- "shelljs": "^0.8.4",
44
+ "shelljs": "^0.8.5",
42
45
  "uuid": "^8.3.2",
43
- "appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/21.9.0.0/appdynamics-libagent-napi-node.tgz",
44
- "appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/21.9.0.0/appdynamics-native-node.tgz",
45
- "appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/21.9.0.0/appdynamics-protobuf-node.tgz"
46
+ "appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/22.2.0.0/appdynamics-libagent-napi-node.tgz",
47
+ "appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/22.2.0.0/appdynamics-native-node.tgz",
48
+ "appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/22.2.0.0/appdynamics-protobuf-node.tgz"
46
49
  },
47
50
  "engines": {
48
51
  "node": ">=12 <=v16.*"
package/packageBck.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appdynamics",
3
- "version": "21.9.0",
3
+ "version": "22.2.0",
4
4
  "description": "Performance Profiler and Monitor",
5
5
  "author": "AppDynamics, Inc.",
6
6
  "homepage": "https://www.appdynamics.com",
@@ -34,15 +34,18 @@
34
34
  "n": "^6.7.0"
35
35
  },
36
36
  "dependencies": {
37
+ "@opentelemetry/api": "^1.0.3",
38
+ "@opentelemetry/exporter-collector": "^0.25.0",
39
+ "@opentelemetry/node": "^0.24.0",
40
+ "@opentelemetry/semantic-conventions": "^1.0.1",
41
+ "@opentelemetry/tracing": "^0.24.0",
37
42
  "cls-hooked": "4.2.2",
38
- "log4js": "0.6.38",
39
43
  "n": "^6.7.0",
40
- "set-immediate": "0.1.1",
41
- "shelljs": "^0.8.4",
44
+ "shelljs": "^0.8.5",
42
45
  "uuid": "^8.3.2",
43
- "appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/21.9.0.0/appdynamics-libagent-napi-node.tgz",
44
- "appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/21.9.0.0/appdynamics-native-node.tgz",
45
- "appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/21.9.0.0/appdynamics-protobuf-node.tgz"
46
+ "appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/22.2.0.0/appdynamics-libagent-napi-node.tgz",
47
+ "appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/22.2.0.0/appdynamics-native-node.tgz",
48
+ "appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/22.2.0.0/appdynamics-protobuf-node.tgz"
46
49
  },
47
50
  "engines": {
48
51
  "node": ">=12 <=v16.*"