appdynamics 21.6.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.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/appdynamics_version.json +2 -2
  3. package/lib/core/agent.js +21 -44
  4. package/lib/core/appDProxy.js +12 -12
  5. package/lib/core/logger.js +27 -79
  6. package/lib/core/opentelemetry-tracer.js +70 -0
  7. package/lib/libagent/libagent-connector.js +5 -47
  8. package/lib/libagent/libagent.js +2 -3
  9. package/lib/libagent/transaction-sender.js +15 -16
  10. package/lib/libagent/transactions/transaction-reporter.js +0 -5
  11. package/lib/{libagent/metrics → metrics}/metric.js +4 -1
  12. package/lib/metrics/metrics-manager.js +4 -3
  13. package/lib/probes/apollo-entry-probe.js +69 -0
  14. package/lib/probes/cluster-probe.js +1 -1
  15. package/lib/probes/couchbase-probe.js +19 -0
  16. package/lib/probes/grpc-exit-probe.js +1 -1
  17. package/lib/probes/http-common.js +97 -0
  18. package/lib/probes/http-entry-probe.js +42 -122
  19. package/lib/probes/http-exit-probe.js +112 -48
  20. package/lib/probes/http-ot-utils.js +113 -0
  21. package/lib/probes/http-probe.js +14 -7
  22. package/lib/probes/http2-entry-probe.js +1 -7
  23. package/lib/probes/http2-exit-probe.js +4 -7
  24. package/lib/probes/ioredis-probe.js +2 -2
  25. package/lib/probes/mongodb-probe.js +199 -112
  26. package/lib/probes/rabbitmq-entry-probe.js +184 -0
  27. package/lib/probes/rabbitmq-exit-probe.js +108 -0
  28. package/lib/probes/rabbitmq-probe.js +76 -0
  29. package/lib/process/process-scanner.js +2 -2
  30. package/lib/profiler/profiler.js +6 -2
  31. package/lib/profiler/time-promise.js +0 -3
  32. package/lib/proxy/protobuf-model.js +0 -264
  33. package/lib/transactions/correlation.js +1 -20
  34. package/lib/transactions/eum.js +2 -34
  35. package/lib/utility.js +20 -1
  36. package/package.json +13 -12
  37. package/packageBck.json +13 -12
  38. package/lib/libproxy/instance-info-sender.js +0 -41
  39. package/lib/libproxy/libproxy.js +0 -204
  40. package/lib/libproxy/metric.js +0 -109
  41. package/lib/libproxy/proxy-launcher.js +0 -308
  42. package/lib/libproxy/proxy-transport.js +0 -634
  43. package/lib/libproxy/transaction-reporter.js +0 -168
  44. package/lib/proxy/backend-config.js +0 -488
  45. package/lib/transactions/analytics-reporter.js +0 -187
  46. package/lib/transactions/config-manager.js +0 -87
  47. package/lib/transactions/correlation-header.js +0 -495
  48. package/lib/transactions/data-collectors.js +0 -95
  49. package/lib/transactions/sep-config.js +0 -66
  50. package/lib/transactions/transaction-naming.js +0 -231
  51. package/lib/transactions/transaction-registry.js +0 -156
  52. package/lib/transactions/transaction-rules.js +0 -173
  53. package/postInstallScript.js +0 -33
@@ -1,495 +0,0 @@
1
- /*
2
- Copyright (c) AppDynamics, Inc., and its affiliates
3
- 2015
4
- All Rights Reserved
5
- */
6
- 'use strict';
7
-
8
-
9
- function CorrelationHeader(agent) {
10
- this.agent = agent;
11
- this.correlation = agent.correlation;
12
-
13
- this.subHeaders = {};
14
- this.selfResolutionBackendId = undefined;
15
- this.crossAppCorrelation = false;
16
- this.crossAppCorrelationBackendId = undefined;
17
- this.txDetect = true;
18
- }
19
- exports.CorrelationHeader = CorrelationHeader;
20
-
21
-
22
- CorrelationHeader.prototype.addSubHeader = function(name, value) {
23
- var self = this;
24
-
25
- self.subHeaders[name] = value;
26
- };
27
-
28
- CorrelationHeader.prototype.getSubHeader = function(name, defaultValue) {
29
- var self = this;
30
-
31
- var value = self.subHeaders[name];
32
-
33
- if(value === undefined && defaultValue !== undefined) {
34
- return defaultValue;
35
- }
36
-
37
- return value;
38
- };
39
-
40
- CorrelationHeader.prototype.getStringSubHeader = function(name) {
41
- var self = this;
42
-
43
- var value = self.subHeaders[name];
44
- if(value) {
45
- if(Array.isArray(value)) {
46
- return value.join(',');
47
- }
48
- if(typeof(value) === 'boolean') {
49
- return value.toString();
50
- }
51
- else {
52
- return value;
53
- }
54
- }
55
- else {
56
- return undefined;
57
- }
58
- };
59
-
60
- CorrelationHeader.prototype.getStringHeader = function() {
61
- var self = this;
62
-
63
- var pairs = [];
64
-
65
- for(var name in self.subHeaders) {
66
- pairs.push(name + '=' + self.getStringSubHeader(name));
67
- }
68
-
69
- return pairs.join('*');
70
- };
71
-
72
- CorrelationHeader.prototype.parseHeaderString = function(headerString) {
73
- var self = this;
74
- // sanitize header based on CORE-20346
75
- var headerStringParts = headerString.split(', ');
76
- headerString = headerStringParts[headerStringParts.length - 1];
77
-
78
- var pairsMap = {};
79
- var pairs = headerString.split('*');
80
- pairs.forEach(function(pairString) {
81
- var pair = pairString.split('=');
82
-
83
- if(pair.length == 2 && pair[1] !== undefined) {
84
- pairsMap[pair[0]] = pair[1];
85
- }
86
- });
87
-
88
-
89
- // value lists
90
- [self.correlation.COMPONENT_ID_FROM,
91
- self.correlation.COMPONENT_ID_TO,
92
- self.correlation.EXIT_CALL_TYPE_ORDER,
93
- self.correlation.EXIT_CALL_SUBTYPE_KEY].forEach(function(name) {
94
- var value = pairsMap[name];
95
- if(value !== undefined) {
96
- self.addSubHeader(name, value.split(','));
97
- delete pairsMap[name];
98
- }
99
- });
100
-
101
-
102
- // boolean values
103
- [self.correlation.DONOTRESOLVE,
104
- self.correlation.SNAPSHOT_ENABLE,
105
- self.correlation.DISABLE_TRANSACTION_DETECTION,
106
- self.correlation.DEBUG_ENABLED].forEach(function(name) {
107
- var value = pairsMap[name];
108
- if(value !== undefined) {
109
- self.addSubHeader(name, value.toLowerCase() === 'true');
110
- delete pairsMap[name];
111
- }
112
- });
113
-
114
-
115
- // string values
116
- for(var name in pairsMap) {
117
- self.addSubHeader(name, pairsMap[name]);
118
- }
119
- };
120
-
121
- CorrelationHeader.prototype.parse = function(headerString) {
122
- var self = this;
123
-
124
- // parse string header to subheader pairs
125
- self.parseHeaderString(headerString);
126
-
127
- // TODO: debug == true -> enable logging for only this transaction
128
-
129
- // disable transaction detection if subheader is set
130
- if(self.getSubHeader(self.correlation.DISABLE_TRANSACTION_DETECTION)) {
131
- self.txDetect = false;
132
- self.agent.logger.debug("CorrelationHeader.parse: transaction disabled from the originating tier, not processing");
133
- return false;
134
- }
135
-
136
- var accountGuid = self.getSubHeader(self.correlation.ACCOUNT_GUID);
137
- var controllerGuid = self.getSubHeader(self.correlation.CONTROLLER_GUID);
138
- var appId = self.getSubHeader(self.correlation.APP_ID);
139
- if(accountGuid && accountGuid != self.correlation.accountGuid) {
140
- self.agent.logger.debug("CorrelationHeader.parse: Remote account GUID [" + accountGuid + "] and local [" + self.correlation.accountGuid + "] do not match, not processing");
141
- return false;
142
- }
143
-
144
- if(controllerGuid && controllerGuid != self.correlation.controllerGuid) {
145
- self.agent.logger.debug("CorrelationHeader.parse: Remote controller GUID [" + controllerGuid + "] and local [" + self.correlation.controllerGuid + "] do not match, not processing");
146
- return false;
147
- }
148
-
149
- var crossAppCorrelation = false;
150
- if(appId && appId !== self.correlation.appId) {
151
- if(!(accountGuid && controllerGuid)) {
152
- self.agent.logger.debug("CorrelationHeader.parse: Remote app ID [" + appId + "] and local app ID [" + self.correlation.appId + "] do not match, not processing");
153
- return false;
154
- }
155
- else {
156
- crossAppCorrelation = true;
157
- }
158
- }
159
-
160
- // parse components
161
- var componentLinks = []; // needed for size
162
- var componentLink;
163
- var m;
164
-
165
- var cidFrom = self.getSubHeader(self.correlation.COMPONENT_ID_FROM) || [];
166
- var cidTo = self.getSubHeader(self.correlation.COMPONENT_ID_TO) || [];
167
- var eTypeOrder = self.getSubHeader(self.correlation.EXIT_CALL_TYPE_ORDER) || [];
168
- var eSubType = self.getSubHeader(self.correlation.EXIT_CALL_SUBTYPE_KEY) || [];
169
-
170
- if(cidFrom.length != cidTo.length || cidFrom.length != eTypeOrder.length) {
171
- self.agent.logger.warn("CorrelationHeader.parse: malformed caller chain");
172
- return false;
173
- }
174
-
175
- for(var i = 0; i < cidFrom.length; i++) {
176
- componentLink = {};
177
- componentLink[self.correlation.COMPONENT_ID_FROM] = cidFrom[i];
178
- componentLink[self.correlation.COMPONENT_ID_TO] = cidTo[i];
179
- componentLink[self.correlation.EXIT_CALL_TYPE_ORDER] = eTypeOrder[i];
180
- componentLink[self.correlation.EXIT_CALL_SUBTYPE_KEY] = eSubType[i];
181
- componentLinks.push(componentLink);
182
- }
183
-
184
- var lastComponent = componentLinks[componentLinks.length - 1];
185
-
186
-
187
- // report cross app correlation backend ID
188
- var crossAppCorrelationBackendId;
189
- if(crossAppCorrelation) {
190
- var lastComponentToId = lastComponent[self.correlation.COMPONENT_ID_TO];
191
- m = self.correlation.cidRegex.exec(lastComponentToId);
192
- if(m && m.length == 2) {
193
- crossAppCorrelationBackendId = parseInt(m[1]) | 0;
194
- if (crossAppCorrelationBackendId <= 0) {
195
- self.agent.logger.debug("CorrelationHeader.parse: unresolved backend ID is invalid for cross app correlation: "+ lastComponentToId);
196
- return false;
197
- }
198
- self.agent.logger.debug("CorrelationHeader.parse: crossAppCorrelationBackendId = " + crossAppCorrelationBackendId);
199
- self.crossAppCorrelationBackendId = crossAppCorrelationBackendId;
200
- self.crossAppCorrelation = true;
201
- return false;
202
- }
203
- m = self.correlation.cidResolvedCrossAppRegEx.exec(lastComponentToId);
204
-
205
- // If the incoming cidto is not understood by us, then just try to
206
- // resolve the incoming backend id to this app. The legimate case
207
- // this approach handles is the case when lastComponentToId is a component
208
- // id from the upstream app.
209
- var crossAppCorrelationToAppId =
210
- (m && (m.length == 2)) ? (parseInt(m[1]) | 0) : 0;
211
-
212
- if (crossAppCorrelationToAppId == self.correlation.appId) {
213
- self.agent.logger.debug("CorrelationHeader.parse: foreign backend is already resolved to this application: " + lastComponentToId);
214
- self.crossAppCorrelation = true;
215
- return false;
216
- }
217
-
218
- crossAppCorrelationBackendId = self.getSubHeader(self.correlation.UNRESOLVED_EXIT_ID) | 0;
219
- if (crossAppCorrelationBackendId <= 0) {
220
- self.agent.logger.debug("CorrelationHeader.parse: cross app correlation header is missing valid " +
221
- self.correlation.UNRESOLVED_EXIT_ID + " subheader:" + headerString);
222
- return false;
223
- }
224
- self.agent.logger.debug("CorrelationHeader.parse: re-resolving foreign backend " +
225
- crossAppCorrelationBackendId + " to this application.");
226
- self.crossAppCorrelationBackendId = crossAppCorrelationBackendId;
227
- self.crossAppCorrelation = true;
228
- return false;
229
- }
230
- self.crossAppCorrelation = false;
231
-
232
- // add own component link
233
- if(self.getSubHeader(self.correlation.DONOTRESOLVE)) {
234
- cidFrom.push(lastComponent[self.correlation.COMPONENT_ID_TO]);
235
- cidTo.push(self.correlation.tierId.toString());
236
- eTypeOrder.push(lastComponent[self.correlation.EXIT_CALL_TYPE_ORDER]);
237
-
238
- componentLink = {};
239
- componentLink[self.correlation.COMPONENT_ID_FROM] = lastComponent[self.correlation.COMPONENT_ID_TO];
240
- componentLink[self.correlation.COMPONENT_ID_TO] = self.correlation.tierId.toString();
241
- componentLink[self.correlation.EXIT_CALL_TYPE_ORDER] = lastComponent[self.correlation.EXIT_CALL_TYPE_ORDER];
242
- componentLink[self.correlation.EXIT_CALL_SUBTYPE_KEY] = lastComponent[self.correlation.EXIT_CALL_SUBTYPE_KEY];
243
- componentLinks.push(componentLink);
244
- }
245
-
246
-
247
- // extract backend ID
248
- if(!self.getSubHeader(self.correlation.DONOTRESOLVE)) {
249
- m = self.correlation.cidRegex.exec(lastComponent[self.correlation.COMPONENT_ID_TO]);
250
- if(m && m.length == 2) {
251
- self.selfResolutionBackendId = parseInt(m[1]);
252
- }
253
- }
254
-
255
- // backend ID resolution
256
- if(self.getSubHeader(self.correlation.UNRESOLVED_EXIT_ID) !== undefined) {
257
- var unresolvedExitId = parseInt(self.getSubHeader(self.correlation.UNRESOLVED_EXIT_ID));
258
- if(unresolvedExitId > 0) {
259
- self.selfResolutionBackendId = unresolvedExitId;
260
-
261
- var correlatedComponentId = self.agent.transactionRegistry.resolvedBackendIds[unresolvedExitId];
262
- if(correlatedComponentId !== undefined && correlatedComponentId !== self.correlation.tierId) {
263
- self.agent.backendConnector.proxyTransport.sendSelfReResolution({
264
- backendId: unresolvedExitId
265
- });
266
-
267
- return false;
268
- }
269
- m = self.correlation.cidResolvedCrossAppRegEx.exec(lastComponent[self.correlation.COMPONENT_ID_TO]);
270
- if (m && (m.length == 2)) {
271
- self.agent.logger.debug("Re-resolving backend " + unresolvedExitId + " to this tier, it was resolve to an application.");
272
- self.agent.backendConnector.proxyTransport.sendSelfReResolution({
273
- backendId: unresolvedExitId
274
- });
275
-
276
- return false;
277
- }
278
- }
279
- }
280
-
281
-
282
- // apply header size limitations
283
- var size = 0;
284
- componentLinks.forEach(function(componentLink) {
285
- size += 30;
286
- size += componentLink[self.correlation.COMPONENT_ID_TO].length;
287
- size += componentLink[self.correlation.COMPONENT_ID_FROM].length;
288
- size += componentLink[self.correlation.EXIT_CALL_TYPE_ORDER].length;
289
- });
290
-
291
- if(size > 750 + 16 + 15 + 20) {
292
- return false;
293
- }
294
-
295
- return true;
296
- };
297
-
298
- CorrelationHeader.prototype.makeContinuingTransaction = function(transaction) {
299
- var self = this;
300
-
301
- var btId = self.getSubHeader(self.correlation.BT_ID);
302
- var btName = self.getSubHeader(self.correlation.BT_NAME);
303
-
304
- if(btId) {
305
- transaction.registrationId = btId;
306
- }
307
- else if(btName) {
308
- var btType = self.getSubHeader(self.correlation.ENTRY_POINT_TYPE);
309
- var btComp = self.getSubHeader(self.correlation.BT_COMPONENT_MAPPING);
310
- var mcType = self.getSubHeader(self.correlation.MATCH_CRITERIA_TYPE);
311
- var mcValue = self.getSubHeader(self.correlation.MATCH_CRITERIA_VALUE);
312
-
313
- if(mcType === self.correlation.MATCH_CRITERIA_TYPE_DISCOVERED) {
314
- transaction.isAutoDiscovered = true;
315
- transaction.namingSchemeType = mcValue;
316
- }
317
- else {
318
- transaction.isAutoDiscovered = false;
319
- }
320
-
321
- transaction.name = btName;
322
- transaction.entryType = btType;
323
- transaction.componentId = btComp;
324
- }
325
- else {
326
- self.agent.logger.warn("CorrelationHeader.makeContinuingTransaction: invalid correlation header, did not find BT id or name");
327
- return false;
328
- }
329
-
330
- transaction.guid = self.getSubHeader(self.correlation.REQUEST_GUID);
331
- transaction.skewAdjustedStartWallTime = self.getSubHeader(self.correlation.TIMESTAMP);
332
-
333
- return true;
334
- };
335
-
336
- var exitPointTypeToString = {
337
- 'EXIT_HTTP': 'HTTP',
338
- 'EXIT_CACHE': 'CACHE',
339
- 'EXIT_DB': 'DB'
340
- };
341
-
342
- CorrelationHeader.prototype.build = function(transaction, exitCall, doNotResolve, isApiCall) {
343
- var self = this;
344
-
345
- // if the upstream tier has sent a notxdetect=true, then we should
346
- // also pass it on to all downstream tiers
347
- if (transaction.corrHeader && transaction.corrHeader.txDetect === false) {
348
- self.disableTransactionDetection();
349
- }
350
-
351
- if (transaction.ignore) {
352
- return;
353
- }
354
-
355
- // assign backendID and componentID to backend call if available
356
- self.agent.transactionRegistry.matchBackendCall(exitCall);
357
-
358
-
359
- var incomingHeader;
360
- if (transaction.corrHeader) {
361
- if (!transaction.corrHeader.crossAppCorrelation) {
362
- incomingHeader = transaction.corrHeader;
363
- }
364
- }
365
-
366
- // if backend call is not registered
367
- if(!exitCall.registrationId) {
368
- self.disableTransactionDetection();
369
-
370
- if(incomingHeader && incomingHeader.getSubHeader(self.correlation.DEBUG_ENABLED)) {
371
- self.addSubHeader(self.correlation.DEBUG_ENABLED, true);
372
- }
373
-
374
- self.agent.logger.debug("CorrelationHeader.build: disabling correlation header generated: " + self.getStringHeader());
375
- return;
376
- }
377
-
378
-
379
- // add app id subheader
380
- self.addSubHeader(self.correlation.ACCOUNT_GUID, self.correlation.accountGuid);
381
- self.addSubHeader(self.correlation.CONTROLLER_GUID, self.correlation.controllerGuid);
382
- self.addSubHeader(self.correlation.APP_ID, self.correlation.appId);
383
-
384
-
385
- // add BT related subheaders
386
- if(transaction.registrationId) {
387
- self.addSubHeader(self.correlation.BT_ID, transaction.registrationId);
388
- }
389
- else {
390
- self.addSubHeader(self.correlation.BT_NAME, transaction.name);
391
- self.addSubHeader(self.correlation.ENTRY_POINT_TYPE, transaction.entryType);
392
- self.addSubHeader(self.correlation.BT_COMPONENT_MAPPING, self.correlation.tierId);
393
-
394
- if(incomingHeader) {
395
- if(transaction.isAutoDiscovered) {
396
- self.addSubHeader(self.correlation.MATCH_CRITERIA_TYPE, self.correlation.MATCH_CRITERIA_TYPE_DISCOVERED);
397
- self.addSubHeader(self.correlation.MATCH_CRITERIA_VALUE, transaction.namingSchemeType);
398
- }
399
- else {
400
- self.addSubHeader(self.correlation.MATCH_CRITERIA_TYPE, self.correlation.MATCH_CRITERIA_TYPE_DISCOVERED);
401
- self.addSubHeader(self.correlation.MATCH_CRITERIA_VALUE, transaction.name);
402
- }
403
- }
404
- else {
405
- if(transaction.isAutoDiscovered) {
406
- self.addSubHeader(self.correlation.MATCH_CRITERIA_TYPE, self.correlation.MATCH_CRITERIA_TYPE_DISCOVERED);
407
- self.addSubHeader(self.correlation.MATCH_CRITERIA_VALUE, self.correlation.namingSchemeType);
408
- }
409
- else {
410
- self.addSubHeader(self.correlation.MATCH_CRITERIA_TYPE, self.correlation.MATCH_CRITERIA_TYPE_DISCOVERED);
411
- if (isApiCall) {
412
- self.addSubHeader(self.correlation.MATCH_CRITERIA_VALUE, transaction.name);
413
- } else {
414
- self.addSubHeader(self.correlation.MATCH_CRITERIA_VALUE, transaction.customMatch.btName);
415
- }
416
- }
417
- }
418
- }
419
-
420
-
421
- // add request guid subheader
422
- self.addSubHeader(self.correlation.REQUEST_GUID, transaction.guid);
423
- if (transaction.skewAdjustedStartWallTime) {
424
- self.addSubHeader(self.correlation.TIMESTAMP, transaction.skewAdjustedStartWallTime);
425
- }
426
-
427
- // add debug subheader
428
- if(incomingHeader && incomingHeader.getSubHeader(self.correlation.DEBUG_ENABLED)) {
429
- self.addSubHeader(self.correlation.DEBUG_ENABLED, true);
430
- }
431
-
432
-
433
- // add snapshot enable subheader
434
- var btInfoResponse = transaction.btInfoResponse;
435
- if((incomingHeader && incomingHeader.getSubHeader(self.correlation.SNAPSHOT_ENABLE)) ||
436
- (btInfoResponse && btInfoResponse.isSnapshotRequired)) {
437
- self.addSubHeader(self.correlation.SNAPSHOT_ENABLE, true);
438
- }
439
-
440
- // add unresoved exit id subheader
441
- var componentId;
442
- if(exitCall.componentId !== undefined) {
443
- var crossAppPrefixIfNeeded =
444
- exitCall.componentIsForeignAppId ? self.correlation.CID_IS_APPID_PREFIX : "";
445
- componentId = crossAppPrefixIfNeeded + exitCall.componentId;
446
- }
447
- else {
448
- componentId = "{[UNRESOLVED][" + exitCall.registrationId + "]}";
449
- }
450
-
451
- self.addSubHeader(self.correlation.UNRESOLVED_EXIT_ID, exitCall.registrationId);
452
-
453
- // add exit guid subheader
454
- self.addSubHeader(self.correlation.EXIT_POINT_GUID, exitCall.sequenceInfo);
455
-
456
-
457
- // add component link subheaders
458
- var compFrom;
459
- var compTo;
460
- var exitOrder;
461
- var exitSubType;
462
-
463
- if(incomingHeader) {
464
- compFrom = incomingHeader.getSubHeader(self.correlation.COMPONENT_ID_FROM) || [];
465
- compTo = incomingHeader.getSubHeader(self.correlation.COMPONENT_ID_TO) || [];
466
- exitOrder = incomingHeader.getSubHeader(self.correlation.EXIT_CALL_TYPE_ORDER) || [];
467
- exitSubType = incomingHeader.getSubHeader(self.correlation.EXIT_CALL_SUBTYPE_KEY) || [];
468
- }
469
- else {
470
- compFrom = [];
471
- compTo = [];
472
- exitOrder = [];
473
- exitSubType = [];
474
- }
475
-
476
- compFrom.push(self.correlation.tierId);
477
- compTo.push(componentId);
478
- exitOrder.push(exitPointTypeToString[exitCall.exitType]);
479
- exitSubType.push(exitCall.exitSubType);
480
-
481
- self.addSubHeader(self.correlation.COMPONENT_ID_FROM, compFrom);
482
- self.addSubHeader(self.correlation.COMPONENT_ID_TO, compTo);
483
- self.addSubHeader(self.correlation.EXIT_CALL_TYPE_ORDER, exitOrder);
484
- self.addSubHeader(self.correlation.EXIT_CALL_SUBTYPE_KEY, exitSubType);
485
-
486
- if(doNotResolve) {
487
- self.addSubHeader(self.correlation.DONOTRESOLVE, true);
488
- }
489
-
490
- self.agent.logger.debug("CorrelationHeader.build: correlation header generated: " + self.getStringHeader());
491
- };
492
-
493
- CorrelationHeader.prototype.disableTransactionDetection = function() {
494
- this.addSubHeader(this.correlation.DISABLE_TRANSACTION_DETECTION, true);
495
- };
@@ -1,95 +0,0 @@
1
- /*
2
- Copyright (c) AppDynamics, Inc., and its affiliates
3
- 2015
4
- All Rights Reserved
5
- */
6
- var parseCookies = require('./cookie-util').parseCookies,
7
- parseUrl = require('url').parse;
8
-
9
- function DataCollectors(agent) {
10
- this.agent = agent;
11
- this.gatherersByID = [];
12
- this.btIDtoGathererIDs = [];
13
- }
14
-
15
- module.exports.DataCollectors = DataCollectors;
16
-
17
- DataCollectors.prototype.init = function() {
18
- var self = this;
19
-
20
- self.agent.on('configUpdated', function() {
21
- var dataGatherers = self.agent.configManager.getConfigValue('dataGatherers');
22
- self.gatherersByID = !dataGatherers ? [] : dataGatherers.reduce(function(mapping, config) {
23
- mapping[config.gathererID] = config;
24
- return mapping;
25
- }, {});
26
-
27
- var btConfig = self.agent.configManager.getConfigValue('dataGathererBTConfig.btConfig');
28
- self.btIDtoGathererIDs = !btConfig ? [] : btConfig.reduce(function(mapping, config) {
29
- mapping[config.btID] = config.gathererIDs;
30
- return mapping;
31
- }, {});
32
- });
33
- };
34
-
35
- DataCollectors.prototype.collectHttpData = function(transaction, req) {
36
- var btID = transaction.registrationId,
37
- collectors = this.getDataCollectorsFor(btID),
38
- analyticsData = transaction.httpRequestAnalyticsData = { url: req.url && parseUrl(req.url).pathname },
39
- snapshotData = transaction.httpRequestSnapshotData = { url: req.url && parseUrl(req.url).pathname };
40
-
41
- function addData(config, type, name, value) {
42
- if (config.enabledForAnalytics) {
43
- analyticsData[type] = analyticsData[type] || [];
44
- analyticsData[type].push({ name: name, value: value });
45
- }
46
- if (config.enabledForApm) {
47
- snapshotData[type] = snapshotData[type] || [];
48
- snapshotData[type].push({ name: name, value: value });
49
- }
50
- }
51
-
52
- if (collectors) {
53
- collectors.forEach(function(collector) {
54
- var config;
55
-
56
- if (!collector) return;
57
- if (collector.type !== 'HTTP') return;
58
-
59
- config = collector.httpDataGathererConfig;
60
- if (!(config.enabledForApm || config.enabledForAnalytics)) return;
61
-
62
- if (config.cookieNames) {
63
- var cookies = parseCookies(req);
64
- config.cookieNames.forEach(function(name) {
65
- var value = cookies[name];
66
- if (value) addData(config, 'cookies', name, value);
67
- }, this);
68
- }
69
-
70
- if (config.headers) {
71
- config.headers.forEach(function(name) {
72
- var value = req.headers[name.toLowerCase()];
73
- if (value) addData(config, 'headers', name, value);
74
- }, this);
75
- }
76
-
77
- if (config.requestParams) {
78
- var url = parseUrl(req.url, true),
79
- params = url.query;
80
- config.requestParams.forEach(function(param) {
81
- var value = params[param.name];
82
- if (value) addData(config, 'httpParams', param.name, value);
83
- }, this);
84
- }
85
- }, this);
86
- }
87
- };
88
-
89
- DataCollectors.prototype.getDataCollectorsFor = function(btID) {
90
- var gathererIDs = this.btIDtoGathererIDs[btID];
91
-
92
- return gathererIDs && gathererIDs.map(function(id) {
93
- return this.gatherersByID[id];
94
- }, this);
95
- };
@@ -1,66 +0,0 @@
1
- /*
2
- * Copyright (c) AppDynamics, Inc., and its affiliates
3
- * 2016
4
- * All Rights Reserved
5
- * THIS IS UNPUBLISHED PROPRIETARY CODE OF APPDYNAMICS, INC.
6
- * The copyright notice above does not evidence any actual or intended publication of such source code
7
- */
8
-
9
- 'use strict';
10
- var txRules = require('./transaction-rules').TransactionRules;
11
-
12
- function SepRules(agent) {
13
- this.agent = agent;
14
- this.sepIncludeRules = undefined;
15
- this.sepExcludeRules = undefined;
16
- }
17
-
18
- exports.SepRules = SepRules;
19
-
20
- SepRules.prototype.init = function() {
21
- var self = this;
22
-
23
- self.sepRules = [];
24
- self.sepIncludeRules = [];
25
- self.sepExcludeRules = [];
26
-
27
- self.agent.on('configUpdated', function() {
28
- self.sepRules = self.agent.configManager.getConfigValue('sepConfig.customDefinitions');
29
- self.sepIncludeRules = [];
30
- self.sepExcludeRules = [];
31
- if (self.sepRules && self.sepRules.length) {
32
- self.sepRules.forEach(function (rule) {
33
- // An excluded rule has id 1, and included one has id 0
34
- // Is excluded sep rule
35
- if (rule.id === 1) {
36
- self.sepExcludeRules.push(rule);
37
- } else {
38
- // Is include sep rule
39
- self.sepIncludeRules.push(rule);
40
- }
41
- });
42
-
43
- self.sepIncludeRules = self.sepIncludeRules.sort(function(r1, r2) { return r2.priority - r1.priority; });
44
- self.sepExcludeRules = self.sepExcludeRules.sort(function(r1, r2) { return r2.priority - r1.priority; });
45
- }
46
- });
47
- };
48
-
49
- SepRules.prototype.isExcludeSepRuleMatch = function(req) {
50
- return reqRuleMatch(req, this.sepExcludeRules, this.agent.stringMatcher);
51
- };
52
-
53
- SepRules.prototype.isIncludedSepRuleMatch = function(req) {
54
- return reqRuleMatch(req, this.sepIncludeRules, this.agent.stringMatcher);
55
- };
56
-
57
- function reqRuleMatch(req, rules, stringMatcher) {
58
- var matchResult;
59
- if (!rules || !rules.length) { return; }
60
- for (var i = 0; i < rules.length; i++) {
61
- matchResult = txRules.matchesRule(req, rules[i].condition.http, stringMatcher);
62
- if (matchResult) {
63
- return rules[i].btName;
64
- }
65
- }
66
- }