appdynamics 21.8.0 → 22.3.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/README.md +1 -1
- package/appdynamics_version.json +2 -2
- package/lib/core/agent.js +21 -44
- package/lib/core/appDProxy.js +12 -12
- package/lib/core/logger.js +27 -79
- package/lib/core/opentelemetry-tracer.js +89 -0
- package/lib/libagent/libagent-connector.js +5 -47
- package/lib/libagent/libagent.js +2 -3
- package/lib/libagent/transaction-sender.js +15 -16
- package/lib/libagent/transactions/transaction-reporter.js +0 -5
- package/lib/{libagent/metrics → metrics}/metric.js +4 -1
- package/lib/metrics/metrics-manager.js +4 -3
- package/lib/probes/apollo-entry-probe.js +69 -0
- package/lib/probes/cluster-probe.js +1 -1
- package/lib/probes/couchbase-probe.js +19 -0
- package/lib/probes/grpc-exit-probe.js +1 -1
- package/lib/probes/http-common.js +97 -0
- package/lib/probes/http-entry-probe.js +42 -122
- package/lib/probes/http-exit-probe.js +112 -48
- package/lib/probes/http-ot-utils.js +117 -0
- package/lib/probes/http-probe.js +14 -7
- package/lib/probes/http2-entry-probe.js +1 -7
- package/lib/probes/http2-exit-probe.js +4 -7
- package/lib/probes/ioredis-probe.js +2 -2
- package/lib/probes/mongodb-probe.js +200 -113
- package/lib/probes/rabbitmq-entry-probe.js +184 -0
- package/lib/probes/rabbitmq-exit-probe.js +108 -0
- package/lib/probes/rabbitmq-probe.js +76 -0
- package/lib/process/process-scanner.js +2 -2
- package/lib/profiler/profiler.js +6 -2
- package/lib/profiler/time-promise.js +0 -3
- package/lib/proxy/protobuf-model.js +0 -264
- package/lib/transactions/correlation.js +1 -20
- package/lib/transactions/eum.js +2 -34
- package/lib/utility.js +20 -1
- package/package.json +15 -13
- package/packageBck.json +15 -13
- package/lib/libproxy/instance-info-sender.js +0 -41
- package/lib/libproxy/libproxy.js +0 -204
- package/lib/libproxy/metric.js +0 -109
- package/lib/libproxy/proxy-launcher.js +0 -308
- package/lib/libproxy/proxy-transport.js +0 -634
- package/lib/libproxy/transaction-reporter.js +0 -168
- package/lib/proxy/backend-config.js +0 -488
- package/lib/transactions/analytics-reporter.js +0 -187
- package/lib/transactions/config-manager.js +0 -87
- package/lib/transactions/correlation-header.js +0 -495
- package/lib/transactions/data-collectors.js +0 -95
- package/lib/transactions/sep-config.js +0 -66
- package/lib/transactions/transaction-naming.js +0 -231
- package/lib/transactions/transaction-registry.js +0 -156
- package/lib/transactions/transaction-rules.js +0 -173
- package/postInstallScript.js +0 -33
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) AppDynamics, Inc., and its affiliates
|
|
3
|
-
2015
|
|
4
|
-
All Rights Reserved
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
var cookies = require('./cookie-util');
|
|
9
|
-
|
|
10
|
-
function TransactionNaming(agent) {
|
|
11
|
-
this.agent = agent;
|
|
12
|
-
|
|
13
|
-
this.namingProps = undefined;
|
|
14
|
-
}
|
|
15
|
-
exports.TransactionNaming = TransactionNaming;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
TransactionNaming.prototype.init = function() {
|
|
19
|
-
var self = this;
|
|
20
|
-
|
|
21
|
-
self.agent.on('configUpdated', function() {
|
|
22
|
-
var props = self.agent.configManager.getConfigValue('txConfig.nodejsWeb.discoveryConfig.namingScheme.properties');
|
|
23
|
-
self.namingProps = self.formatNamingProps(props);
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
TransactionNaming.prototype.formatNamingProps = function(props) {
|
|
28
|
-
props = this.agent.configManager.convertListToMap(props);
|
|
29
|
-
|
|
30
|
-
// Headers are lowercased in Node.js
|
|
31
|
-
if(props['uri-suffix-scheme'] === 'header-value' && props['suffix-key']) {
|
|
32
|
-
props['suffix-key'] = props['suffix-key'].toLowerCase();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return props;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
TransactionNaming.prototype.createHttpTransactionName = function(req, transaction) {
|
|
39
|
-
var matchName = transaction.customMatch && transaction.customMatch.btName
|
|
40
|
-
, namingProps = transaction.customNaming || this.namingProps;
|
|
41
|
-
|
|
42
|
-
return this.createHttpTransactionNameFromNamingScheme(req, namingProps, matchName);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
TransactionNaming.prototype.createHttpTransactionNameFromNamingScheme = function(req, namingProps, btName) {
|
|
46
|
-
var self = this, suffix;
|
|
47
|
-
|
|
48
|
-
var baseName = btName || self.createWithUriSegments(req, namingProps);
|
|
49
|
-
|
|
50
|
-
var uriSuffixScheme = namingProps['uri-suffix-scheme'];
|
|
51
|
-
var suffixKey = namingProps['suffix-key'];
|
|
52
|
-
var delimiter = namingProps['delimiter'];
|
|
53
|
-
delimiter = delimiter ? delimiter : "";
|
|
54
|
-
|
|
55
|
-
if (!uriSuffixScheme)
|
|
56
|
-
return baseName;
|
|
57
|
-
if (uriSuffixScheme !== 'method' && !suffixKey)
|
|
58
|
-
return baseName;
|
|
59
|
-
|
|
60
|
-
switch(uriSuffixScheme) {
|
|
61
|
-
case 'first-n-segments':
|
|
62
|
-
case 'last-n-segments':
|
|
63
|
-
suffix = this.getUriSegments(req.url, uriSuffixScheme, suffixKey);
|
|
64
|
-
baseName = btName ? btName + '.' + suffix : suffix;
|
|
65
|
-
break;
|
|
66
|
-
case 'uri-segment-number':
|
|
67
|
-
suffix = self.transformUriSegments(req, baseName, suffixKey, delimiter);
|
|
68
|
-
baseName = btName ? btName + '.' + suffix : suffix;
|
|
69
|
-
break;
|
|
70
|
-
case 'param-value':
|
|
71
|
-
baseName = self.appendParamValues(req, baseName, suffixKey);
|
|
72
|
-
break;
|
|
73
|
-
case 'header-value':
|
|
74
|
-
baseName = self.appendHeaderValues(req, baseName, suffixKey);
|
|
75
|
-
break;
|
|
76
|
-
case 'cookie-value':
|
|
77
|
-
baseName = self.appendCookieValues(req, baseName, suffixKey);
|
|
78
|
-
break;
|
|
79
|
-
case 'method':
|
|
80
|
-
baseName = self.appendMethod(req, baseName);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return baseName;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
TransactionNaming.prototype.createWithUriSegments = function(req, namingProps) {
|
|
90
|
-
var self = this;
|
|
91
|
-
|
|
92
|
-
var segmentLength = namingProps['segment-length'];
|
|
93
|
-
var uriLength = namingProps['uri-length'] || 'first-n-segments';
|
|
94
|
-
|
|
95
|
-
return self.getUriSegments(req.url, uriLength, segmentLength);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
TransactionNaming.prototype.getUriSegments = function(url, uriLength, segmentLength) {
|
|
99
|
-
var parts = require('url').parse(url || '/');
|
|
100
|
-
var segments = parts.pathname.split('/').splice(1);
|
|
101
|
-
var i;
|
|
102
|
-
|
|
103
|
-
// make sure last slash doesn't cause another empty segment
|
|
104
|
-
if(segments.length > 1 && segments[segments.length - 1] === "") {
|
|
105
|
-
segments.pop();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var name = "";
|
|
109
|
-
segmentLength = segmentLength ? Math.min(segmentLength, segments.length) : segments.length;
|
|
110
|
-
if(uriLength === 'first-n-segments') {
|
|
111
|
-
for(i = 0; i < segmentLength; i++) {
|
|
112
|
-
name += "/" + segments[i];
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else if(uriLength === 'last-n-segments') {
|
|
116
|
-
for(i = segments.length - segmentLength; i < segments.length; i++) {
|
|
117
|
-
name += "/" + segments[i];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return name;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
TransactionNaming.prototype.transformUriSegments = function(req, baseName, suffixKey, delimiter) {
|
|
126
|
-
var parts = require('url').parse(req.url || '/');
|
|
127
|
-
var segments = parts.pathname.split('/').splice(1);
|
|
128
|
-
|
|
129
|
-
// make sure last slash doesn't cause another empty segment
|
|
130
|
-
if(segments.length > 1 && segments[segments.length - 1] === "") {
|
|
131
|
-
segments.pop();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
var setmentNumberArr = suffixKey.replace(/ /g,'').split(',');
|
|
135
|
-
var setmentNumberMap = {};
|
|
136
|
-
setmentNumberArr.forEach(function(segmentNumberStr) {
|
|
137
|
-
var segmentNumber = parseInt(segmentNumberStr);
|
|
138
|
-
if(segmentNumber > 0) {
|
|
139
|
-
setmentNumberMap[segmentNumber] = true;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
var newSegments = [];
|
|
144
|
-
for(var i = 0; i < segments.length; i++) {
|
|
145
|
-
if(setmentNumberMap[i + 1]) {
|
|
146
|
-
newSegments.push(segments[i]);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if(newSegments.length == 0) {
|
|
151
|
-
return baseName;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return newSegments.join(delimiter);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
TransactionNaming.prototype.appendParamValues = function(req, baseName, suffixKey) {
|
|
159
|
-
var paramNames = suffixKey.replace(/ /g,'').split(',');
|
|
160
|
-
|
|
161
|
-
// GET params
|
|
162
|
-
var parts = require('url').parse(req.url || '/', true);
|
|
163
|
-
var paramValues = [];
|
|
164
|
-
paramNames.forEach(function(paramName) {
|
|
165
|
-
var paramValue = parts.query[paramName];
|
|
166
|
-
if(paramValue) {
|
|
167
|
-
paramValues.push(paramValue);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// POST params only available if Express is used
|
|
172
|
-
if(req.body) {
|
|
173
|
-
paramNames.forEach(function(paramName) {
|
|
174
|
-
var paramValue = req.body[paramName];
|
|
175
|
-
if(paramValue) {
|
|
176
|
-
paramValues.push(paramValue);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if(paramValues.length == 0) {
|
|
182
|
-
return baseName;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return baseName + '.' + paramValues.join('.');
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
TransactionNaming.prototype.appendHeaderValues = function(req, baseName, suffixKey) {
|
|
190
|
-
var headerNames = suffixKey.replace(/ /g,'').split(',');
|
|
191
|
-
|
|
192
|
-
var headerValues = [];
|
|
193
|
-
headerNames.forEach(function(headerName) {
|
|
194
|
-
var headerValue = req.headers[headerName.toLowerCase()];
|
|
195
|
-
if(headerValue) {
|
|
196
|
-
headerValues.push(headerValue);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
if(headerValues.length == 0) {
|
|
201
|
-
return baseName;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return baseName + '.' + headerValues.join('.');
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
TransactionNaming.prototype.appendCookieValues = function(req, baseName, suffixKey) {
|
|
209
|
-
var cookieNames = suffixKey.replace(/ /g,'').split(',');
|
|
210
|
-
|
|
211
|
-
var cookieValues = [];
|
|
212
|
-
var cookieMap = cookies.parseCookies(req);
|
|
213
|
-
cookieNames.forEach(function(cookieName) {
|
|
214
|
-
var cookieValue = cookieMap[cookieName];
|
|
215
|
-
if(cookieValue) {
|
|
216
|
-
cookieValues.push(cookieValue);
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
if(cookieValues.length == 0) {
|
|
221
|
-
return baseName;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return baseName + '.' + cookieValues.join('.');
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
TransactionNaming.prototype.appendMethod = function(req, baseName) {
|
|
229
|
-
return baseName + '.' + req.method;
|
|
230
|
-
};
|
|
231
|
-
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) AppDynamics, Inc., and its affiliates
|
|
3
|
-
2015
|
|
4
|
-
All Rights Reserved
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
var backendInfoToString = require('../transactions/exit-call').backendInfoToString;
|
|
9
|
-
|
|
10
|
-
function TransactionRegistry(agent) {
|
|
11
|
-
this.agent = agent;
|
|
12
|
-
|
|
13
|
-
this.registeredBTIndex = undefined;
|
|
14
|
-
this.excludedBTIndex = undefined;
|
|
15
|
-
this.registeredBackendIndex = undefined;
|
|
16
|
-
this.resolvedBackendIds = undefined;
|
|
17
|
-
}
|
|
18
|
-
exports.TransactionRegistry = TransactionRegistry;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
TransactionRegistry.prototype.init = function() {
|
|
22
|
-
var self = this;
|
|
23
|
-
|
|
24
|
-
self.registeredBTIndex = {};
|
|
25
|
-
self.excludedBTIndex = {};
|
|
26
|
-
self.registeredBackendIndex = {};
|
|
27
|
-
self.resolvedBackendIds = {};
|
|
28
|
-
|
|
29
|
-
self.agent.on('configUpdated', function() {
|
|
30
|
-
self.updateRegisteredBTIndex();
|
|
31
|
-
self.updateExcludedBTIndex();
|
|
32
|
-
self.updateRegisteredBackendIndex();
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
TransactionRegistry.prototype.updateRegisteredBTIndex = function() {
|
|
37
|
-
var self = this;
|
|
38
|
-
|
|
39
|
-
self.registeredBTIndex = {};
|
|
40
|
-
|
|
41
|
-
var config = self.agent.configManager.getConfig();
|
|
42
|
-
|
|
43
|
-
if(!config.txInfo || !config.txInfo.registeredBTs) return;
|
|
44
|
-
var registeredBTs = config.txInfo.registeredBTs;
|
|
45
|
-
|
|
46
|
-
registeredBTs.forEach(function(registeredBT) {
|
|
47
|
-
if(!registeredBT.btInfo || !registeredBT.btInfo.internalName || !registeredBT.id) return;
|
|
48
|
-
|
|
49
|
-
self.registeredBTIndex[registeredBT.btInfo.internalName.toString()] = registeredBT;
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
TransactionRegistry.prototype.updateExcludedBTIndex = function() {
|
|
55
|
-
var self = this;
|
|
56
|
-
|
|
57
|
-
self.excludedBTIndex = {};
|
|
58
|
-
|
|
59
|
-
var config = self.agent.configManager.getConfig();
|
|
60
|
-
|
|
61
|
-
if(!config.txInfo || !config.txInfo.blackListedAndExcludedBTs) return;
|
|
62
|
-
var blackListedAndExcludedBTs = config.txInfo.blackListedAndExcludedBTs;
|
|
63
|
-
|
|
64
|
-
blackListedAndExcludedBTs.forEach(function(excludedBT) {
|
|
65
|
-
if(!excludedBT.internalName) return;
|
|
66
|
-
|
|
67
|
-
self.excludedBTIndex[excludedBT.internalName.toString()] = excludedBT;
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
TransactionRegistry.prototype.updateRegisteredBackendIndex = function() {
|
|
72
|
-
var self = this;
|
|
73
|
-
|
|
74
|
-
self.registeredBackendIndex = {};
|
|
75
|
-
|
|
76
|
-
var config = self.agent.configManager.getConfig();
|
|
77
|
-
|
|
78
|
-
if(!config.bckInfo || !config.bckInfo.registeredBackends) return;
|
|
79
|
-
var registeredBackends = config.bckInfo.registeredBackends;
|
|
80
|
-
|
|
81
|
-
registeredBackends.forEach(function(entry) {
|
|
82
|
-
if(
|
|
83
|
-
!entry.registeredBackend.exitPointType ||
|
|
84
|
-
!entry.registeredBackend.backendID ||
|
|
85
|
-
!entry.exitCallInfo.exitPointType ||
|
|
86
|
-
!entry.exitCallInfo.identifyingProperties)
|
|
87
|
-
{
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
var identifyingPropertiesMap = {};
|
|
92
|
-
entry.exitCallInfo.identifyingProperties.forEach(function(prop) {
|
|
93
|
-
if(prop.value == null) return;
|
|
94
|
-
identifyingPropertiesMap[prop.name] = prop.value;
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
var key =
|
|
98
|
-
backendInfoToString(entry.exitCallInfo.exitPointType, entry.exitCallInfo.exitPointSubtype, identifyingPropertiesMap);
|
|
99
|
-
self.agent.logger.debug("registered backendInfo: " + key);
|
|
100
|
-
self.registeredBackendIndex[key] = entry;
|
|
101
|
-
|
|
102
|
-
if(entry.registeredBackend.componentID) {
|
|
103
|
-
self.resolvedBackendIds[entry.registeredBackend.backendID] = entry.registeredBackend.componentID;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
TransactionRegistry.prototype.isExcludedTransaction = function(transaction) {
|
|
110
|
-
var self = this;
|
|
111
|
-
|
|
112
|
-
if(self.excludedBTIndex[transaction.name]) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return false;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
TransactionRegistry.prototype.matchTransaction = function(transaction) {
|
|
121
|
-
var self = this;
|
|
122
|
-
|
|
123
|
-
var registeredBT = self.registeredBTIndex[transaction.name];
|
|
124
|
-
if(registeredBT) {
|
|
125
|
-
transaction.registrationId = registeredBT.id;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
transaction.registrationId = undefined;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (transaction.isAutoDiscovered === undefined) {
|
|
132
|
-
transaction.isAutoDiscovered = true;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
TransactionRegistry.prototype.matchBackendCall = function(exitCall) {
|
|
139
|
-
var self = this;
|
|
140
|
-
|
|
141
|
-
var exitCallId =
|
|
142
|
-
backendInfoToString(exitCall.exitType, exitCall.exitSubType, exitCall.identifyingProperties);
|
|
143
|
-
self.agent.logger.debug("detected backendInfo: " + exitCallId);
|
|
144
|
-
var registeredBackendEntry = self.registeredBackendIndex[exitCallId];
|
|
145
|
-
if(registeredBackendEntry) {
|
|
146
|
-
var registeredBackend = registeredBackendEntry.registeredBackend;
|
|
147
|
-
exitCall.registrationId = registeredBackend.backendID;
|
|
148
|
-
exitCall.componentId = registeredBackend.componentID;
|
|
149
|
-
exitCall.componentIsForeignAppId = !!registeredBackend.componentIsForeignAppID;
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
exitCall.registrationId = undefined;
|
|
154
|
-
exitCall.componentId = undefined;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) AppDynamics, Inc., and its affiliates
|
|
3
|
-
2015
|
|
4
|
-
All Rights Reserved
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
// ------------------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
var cs = require('./cookie-util')
|
|
11
|
-
, url = require('url');
|
|
12
|
-
|
|
13
|
-
// ------------------------------------------------------------------------
|
|
14
|
-
|
|
15
|
-
function TransactionRules(agent) {
|
|
16
|
-
this.agent = agent;
|
|
17
|
-
this.customMatches = undefined;
|
|
18
|
-
this.customExcludes = undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.TransactionRules = TransactionRules;
|
|
22
|
-
|
|
23
|
-
TransactionRules.prototype.init = function() {
|
|
24
|
-
var self = this;
|
|
25
|
-
|
|
26
|
-
self.customMatches = [];
|
|
27
|
-
self.customExcludes = [];
|
|
28
|
-
|
|
29
|
-
self.agent.on('configUpdated', function() {
|
|
30
|
-
var matches = self.agent.configManager.getConfigValue('txConfig.nodejsWeb.customDefinitions')
|
|
31
|
-
, excludes = self.agent.configManager.getConfigValue('txConfig.nodejsWeb.discoveryConfig.excludes')
|
|
32
|
-
, discovery = self.agent.configManager.getConfigValue('txConfig.nodejsWeb.discoveryConfig.enabled');
|
|
33
|
-
|
|
34
|
-
matches = matches || [];
|
|
35
|
-
excludes = excludes || [];
|
|
36
|
-
|
|
37
|
-
// keep matches in priority order
|
|
38
|
-
matches.sort(function(r1, r2) { return r2.priority - r1.priority; });
|
|
39
|
-
|
|
40
|
-
// format custom naming rules
|
|
41
|
-
matches.map(function(customMatch) {
|
|
42
|
-
var http = customMatch.condition.http;
|
|
43
|
-
if (http && Array.isArray(http.properties)) {
|
|
44
|
-
http.properties = self.agent.configManager.convertListToMap(http.properties);
|
|
45
|
-
}
|
|
46
|
-
return http;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// map any header names to lower case
|
|
50
|
-
matches.forEach(headerRuleToLowerCase);
|
|
51
|
-
excludes.forEach(headerRuleToLowerCase);
|
|
52
|
-
|
|
53
|
-
// update matches / excludes
|
|
54
|
-
self.customMatches = matches;
|
|
55
|
-
self.customExcludes = excludes;
|
|
56
|
-
self.discoveryEnabled = !!discovery;
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
TransactionRules.prototype.accept = function(req, transaction) {
|
|
61
|
-
if (this.match(req, transaction)) return true;
|
|
62
|
-
if (this.discoveryEnabled) return !this.exclude(req);
|
|
63
|
-
return false;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
TransactionRules.prototype.match = function(req, transaction) {
|
|
67
|
-
var self = this;
|
|
68
|
-
|
|
69
|
-
if (self.customMatches && self.customMatches.length) {
|
|
70
|
-
for (var i = 0; i < self.customMatches.length; i++) {
|
|
71
|
-
if (TransactionRules.matchesRule(req, self.customMatches[i].condition.http, self.agent.stringMatcher)) {
|
|
72
|
-
self.agent.logger.debug('transaction matched: ' + self.customMatches[i].btName);
|
|
73
|
-
transaction.customNaming = self.customMatches[i].condition.http.properties;
|
|
74
|
-
transaction.customMatch = self.customMatches[i];
|
|
75
|
-
transaction.isAutoDiscovered = false;
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return false;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
TransactionRules.prototype.exclude = function(req) {
|
|
85
|
-
var self = this;
|
|
86
|
-
|
|
87
|
-
for (var i = 0; i < self.customExcludes.length; i++) {
|
|
88
|
-
if (TransactionRules.matchesRule(req, self.customExcludes[i].http, self.agent.stringMatcher)) {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return false;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
TransactionRules.matchesRule = function(req, rule, stringMatcher) {
|
|
97
|
-
var matches = true, uri, host, port, pair;
|
|
98
|
-
|
|
99
|
-
uri = url.parse(req.url).pathname;
|
|
100
|
-
pair = req && req.headers && req.headers.host && req.headers.host.split(':');
|
|
101
|
-
port = pair && pair[1] || (req.connection.localPort && req.connection.localPort.toString());
|
|
102
|
-
host = pair && pair[0] || 'localhost';
|
|
103
|
-
|
|
104
|
-
if ('method' in rule) matches = matches && rule.method == req.method;
|
|
105
|
-
if ('uri' in rule) matches = matches && stringMatcher.matchString(rule.uri, uri);
|
|
106
|
-
if ('host' in rule) matches = matches && stringMatcher.matchString(rule.host, host);
|
|
107
|
-
if (port && 'port' in rule) matches = matches && stringMatcher.matchString(rule.port, port);
|
|
108
|
-
|
|
109
|
-
matches = matches && matchGetPostParams(req, rule, stringMatcher);
|
|
110
|
-
matches = matches && matchCookies(req, rule, stringMatcher);
|
|
111
|
-
matches = matches && matchHeaders(req, rule, stringMatcher);
|
|
112
|
-
|
|
113
|
-
return matches;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// ------------------------------------------------------------------------
|
|
117
|
-
|
|
118
|
-
function headerRuleToLowerCase(rule) {
|
|
119
|
-
var headers = rule && (rule.headers || (rule.condition && rule.condition.http && rule.condition.http.headers));
|
|
120
|
-
if (headers) headers.forEach(function(headerRule) {
|
|
121
|
-
if (headerRule.key && headerRule.key.matchStrings) {
|
|
122
|
-
headerRule.key.matchStrings = headerRule.key.matchStrings.map(function(header) {
|
|
123
|
-
return header.toLowerCase();
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function matchGetPostParams(req, rule, stringMatcher) {
|
|
130
|
-
var getParams = url.parse(req.url || '/', true).query,
|
|
131
|
-
postParams = req.body || {}, // NOTE: requires Express
|
|
132
|
-
paramRules = rule.params || [],
|
|
133
|
-
paramRule;
|
|
134
|
-
|
|
135
|
-
for (var i = 0; i < paramRules.length; i++) {
|
|
136
|
-
paramRule = paramRules[i];
|
|
137
|
-
if (!stringMatcher.matchKeyValue(paramRule, getParams) && !stringMatcher.matchKeyValue(paramRule, postParams)) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function matchCookies(req, rule, stringMatcher) {
|
|
146
|
-
var cookies = cs.parseCookies(req),
|
|
147
|
-
cookieRules = rule.cookies || [],
|
|
148
|
-
cookieRule;
|
|
149
|
-
|
|
150
|
-
for (var i = 0; i < cookieRules.length; i++) {
|
|
151
|
-
cookieRule = cookieRules[i];
|
|
152
|
-
if (!stringMatcher.matchKeyValue(cookieRule, cookies)) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function matchHeaders(req, rule, stringMatcher) {
|
|
161
|
-
var headers = req.headers,
|
|
162
|
-
headerRules = rule.headers || [],
|
|
163
|
-
headerRule;
|
|
164
|
-
|
|
165
|
-
for (var i = 0; i < headerRules.length; i++) {
|
|
166
|
-
headerRule = headerRules[i];
|
|
167
|
-
if (!stringMatcher.matchKeyValue(headerRule, headers)) {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return true;
|
|
173
|
-
}
|
package/postInstallScript.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
var includeJavaProxy = process.env.npm_config_appd_include_java_proxy;
|
|
2
|
-
var globalInstall = process.env.npm_config_global;
|
|
3
|
-
if (includeJavaProxy && includeJavaProxy === "true") {
|
|
4
|
-
var shell = require('shelljs');
|
|
5
|
-
console.log('Install appdynamics-jre and appdynamics-proxy on-demand');
|
|
6
|
-
var baseUrl,
|
|
7
|
-
agentVersion = process.env.npm_package_version + '.0';
|
|
8
|
-
|
|
9
|
-
if (process.env.APPD_STAGE === "true") {
|
|
10
|
-
baseUrl = "https://packages-staging.corp.appdynamics.com";
|
|
11
|
-
} else {
|
|
12
|
-
baseUrl = "https://packages.appdynamics.com";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
var appdynamicsJreDepPath = baseUrl + "/nodejs/" + agentVersion + "/appdynamics-jre.tgz",
|
|
16
|
-
appdynamicsProxyDepPath = baseUrl + "/nodejs/" + agentVersion + "/appdynamics-proxy.tgz";
|
|
17
|
-
|
|
18
|
-
console.log('Computed path for jre dependency ' + appdynamicsJreDepPath);
|
|
19
|
-
console.log('Computed path for proxy dependency ' + appdynamicsProxyDepPath);
|
|
20
|
-
var appdynamicsJreInstallResult = shell.exec("npm install " + appdynamicsJreDepPath + (globalInstall == "true" ? " --global" : ""));
|
|
21
|
-
var appdynamicsProxyInstallResult = shell.exec("npm install " + appdynamicsProxyDepPath + (globalInstall == "true" ? " --global" : ""));
|
|
22
|
-
if (appdynamicsJreInstallResult.code != 0) {
|
|
23
|
-
console.log('Installation of the appdynamics-jre failed');
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
if (appdynamicsProxyInstallResult.code != 0) {
|
|
27
|
-
console.log('Installation of appdynamics-proxy failed');
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
console.log('Install for libagent mode only');
|
|
32
|
-
return;
|
|
33
|
-
}
|