appdynamics 22.5.0 → 22.9.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/appdynamics_span_exporter.js +43 -0
- package/lib/core/opentelemetry-tracer.js +15 -11
- package/lib/libagent/libagent-connector.js +40 -2
- package/lib/probes/http-exit-probe.js +10 -2
- package/lib/probes/mongodb-probe.js +3 -0
- package/lib/profiler/profiler.js +7 -1
- package/lib/secure_app/secure_app.js +67 -32
- package/package.json +7 -6
- package/packageBck.json +7 -6
package/appdynamics_version.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const core_1 = require("@opentelemetry/core");
|
|
3
|
+
|
|
4
|
+
class AppdynamicsSpanExporter {
|
|
5
|
+
constructor(logger) {
|
|
6
|
+
this.logger = logger;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export(spans, resultCallback) {
|
|
10
|
+
return this._sendSpans(spans, resultCallback);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
shutdown() {
|
|
14
|
+
this._sendSpans([]);
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_exportInfo(span) {
|
|
19
|
+
return {
|
|
20
|
+
traceId: span.spanContext().traceId,
|
|
21
|
+
parentId: span.parentSpanId,
|
|
22
|
+
name: span.name,
|
|
23
|
+
id: span.spanContext().spanId,
|
|
24
|
+
kind: span.kind,
|
|
25
|
+
timestamp: core_1.hrTimeToMicroseconds(span.startTime),
|
|
26
|
+
duration: core_1.hrTimeToMicroseconds(span.duration),
|
|
27
|
+
attributes: span.attributes,
|
|
28
|
+
status: span.status,
|
|
29
|
+
events: span.events,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_sendSpans(spans, done) {
|
|
34
|
+
for (const span of spans) {
|
|
35
|
+
this.logger.trace("Exporting span : " + JSON.stringify(this._exportInfo(span)));
|
|
36
|
+
}
|
|
37
|
+
if (done) {
|
|
38
|
+
return done({ code: core_1.ExportResultCode.SUCCESS });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports.AppdynamicsSpanExporter = AppdynamicsSpanExporter;
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
const opentelemetry_api = require('@opentelemetry/api');
|
|
4
4
|
const { ROOT_CONTEXT } = require('@opentelemetry/api');
|
|
5
|
-
const { BatchSpanProcessor,
|
|
5
|
+
const { BatchSpanProcessor, BasicTracerProvider } = require('@opentelemetry/sdk-trace-base');
|
|
6
6
|
const { OTLPTraceExporter } = require("@opentelemetry/exporter-trace-otlp-proto");
|
|
7
7
|
const { AsyncHooksContextManager, AsyncLocalStorageContextManager } = require("@opentelemetry/context-async-hooks");
|
|
8
8
|
const { ParentBasedSampler, AlwaysOnSampler, TraceIdRatioBasedSampler } = require("@opentelemetry/core");
|
|
9
9
|
const { Resource } = require('@opentelemetry/resources');
|
|
10
10
|
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
|
|
11
|
+
const AppdynamicsSpanExporter = require('./appdynamics_span_exporter').AppdynamicsSpanExporter;
|
|
11
12
|
const url = require('url');
|
|
12
13
|
|
|
13
14
|
module.exports = TracerProvider;
|
|
14
15
|
|
|
15
16
|
function TracerProvider(logger) {
|
|
16
17
|
this.host = 'localhost';
|
|
17
|
-
this.port = '
|
|
18
|
+
this.port = '4318';
|
|
19
|
+
this.url = `http://${this.host}:${this.port}/v1/traces`;
|
|
18
20
|
this.ot_api = opentelemetry_api;
|
|
19
21
|
this.ROOT_CONTEXT = ROOT_CONTEXT;
|
|
20
22
|
this.logger = logger;
|
|
@@ -42,17 +44,19 @@ TracerProvider.prototype.register = function(config) {
|
|
|
42
44
|
|
|
43
45
|
// default collector configuration, can be overridden from agent config
|
|
44
46
|
const collectorOptions = {
|
|
47
|
+
url: this.url,
|
|
45
48
|
attributes: {'service.name': config.tierName,
|
|
46
49
|
'service.namespace': config.applicationName}
|
|
47
50
|
};
|
|
48
51
|
|
|
49
52
|
// batch export config, empty by default
|
|
50
|
-
const
|
|
53
|
+
const batchProcessorConfig = {};
|
|
51
54
|
|
|
52
55
|
if (config.openTelemetry) {
|
|
53
56
|
if (config.openTelemetry.collector) {
|
|
54
57
|
Object.assign(collectorOptions, config.openTelemetry.collector);
|
|
55
58
|
this.url = collectorOptions.url;
|
|
59
|
+
this.logger.debug('Exporter using config ' + JSON.stringify(collectorOptions));
|
|
56
60
|
try {
|
|
57
61
|
var urlObj = url.parse(this.url);
|
|
58
62
|
this.host = urlObj.hostname;
|
|
@@ -64,25 +68,25 @@ TracerProvider.prototype.register = function(config) {
|
|
|
64
68
|
}
|
|
65
69
|
if(config.openTelemetry.exporter) {
|
|
66
70
|
if(config.openTelemetry.exporter.maxExportBatchSize) {
|
|
67
|
-
|
|
71
|
+
batchProcessorConfig.maxExportBatchSize = config.openTelemetry.exporter.maxExportBatchSize;
|
|
68
72
|
}
|
|
69
73
|
if(config.openTelemetry.exporter.maxQueueSize) {
|
|
70
|
-
|
|
74
|
+
batchProcessorConfig.maxQueueSize = config.openTelemetry.exporter.maxQueueSize;
|
|
71
75
|
}
|
|
72
76
|
if(config.openTelemetry.exporter.exportTimeoutMillis) {
|
|
73
|
-
|
|
77
|
+
batchProcessorConfig.exportTimeoutMillis = config.openTelemetry.exporter.exportTimeoutMillis;
|
|
74
78
|
}
|
|
75
79
|
if(config.openTelemetry.exporter.maxExportBatchSize) {
|
|
76
|
-
|
|
80
|
+
batchProcessorConfig.maxExportBatchSize = config.openTelemetry.exporter.maxExportBatchSize;
|
|
77
81
|
}
|
|
78
82
|
}
|
|
83
|
+
this.logger.debug('Batch Processor config ' + JSON.stringify(batchProcessorConfig));
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
const exporter = new OTLPTraceExporter(collectorOptions);
|
|
82
|
-
provider.addSpanProcessor(new BatchSpanProcessor(exporter,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
87
|
+
provider.addSpanProcessor(new BatchSpanProcessor(exporter, batchProcessorConfig));
|
|
88
|
+
const appdExporter = new AppdynamicsSpanExporter(this.logger, batchProcessorConfig);
|
|
89
|
+
provider.addSpanProcessor(new BatchSpanProcessor(appdExporter, batchProcessorConfig));
|
|
86
90
|
|
|
87
91
|
const majorVersion = parseInt(process.versions.node.split('.')[0]);
|
|
88
92
|
const minorVersion = parseInt(process.versions.node.split('.')[1]);
|
|
@@ -163,6 +163,10 @@ LibagentConnector.prototype.startBusinessTransaction = function (entryPointType,
|
|
|
163
163
|
LibagentConnector.prototype.stopBusinessTransaction = function (transaction) {
|
|
164
164
|
var self = this;
|
|
165
165
|
|
|
166
|
+
if(!self.agent.profiler.isValidThreadId(transaction.threadId)) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
166
170
|
if (transaction.error) {
|
|
167
171
|
var name = self.protobufModel.extractErrorName(transaction.error);
|
|
168
172
|
if (!name) {
|
|
@@ -203,6 +207,9 @@ LibagentConnector.prototype.stopBusinessTransaction = function (transaction) {
|
|
|
203
207
|
|
|
204
208
|
LibagentConnector.prototype.startExitCall = function (transaction, exitCall) {
|
|
205
209
|
var self = this;
|
|
210
|
+
if(!self.agent.profiler.isValidThreadId(exitCall.threadId)) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
206
213
|
|
|
207
214
|
var propertiesArray = [];
|
|
208
215
|
for (var propName in exitCall.properties) {
|
|
@@ -248,7 +255,10 @@ LibagentConnector.prototype.startExitCall = function (transaction, exitCall) {
|
|
|
248
255
|
|
|
249
256
|
LibagentConnector.prototype.disableResolutionForExitCall = function (exitCall) {
|
|
250
257
|
var self = this;
|
|
251
|
-
|
|
258
|
+
|
|
259
|
+
if(!self.agent.profiler.isValidThreadId(exitCall.threadId)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
252
262
|
if (exitCall.exitCallGuid !== undefined) {
|
|
253
263
|
self.libagent.disableResolutionForExitCall(exitCall.exitCallGuid);
|
|
254
264
|
}
|
|
@@ -256,6 +266,9 @@ LibagentConnector.prototype.disableResolutionForExitCall = function (exitCall) {
|
|
|
256
266
|
|
|
257
267
|
LibagentConnector.prototype.getCorrelationHeader = function (exitCall) {
|
|
258
268
|
var self = this;
|
|
269
|
+
if(!self.agent.profiler.isValidThreadId(exitCall.threadId)) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
259
272
|
|
|
260
273
|
if (exitCall.exitCallGuid !== undefined) {
|
|
261
274
|
return self.libagent.getCorrelationHeader(exitCall.exitCallGuid);
|
|
@@ -264,6 +277,9 @@ LibagentConnector.prototype.getCorrelationHeader = function (exitCall) {
|
|
|
264
277
|
|
|
265
278
|
LibagentConnector.prototype.stopExitCall = function (exitCall, error) {
|
|
266
279
|
var self = this;
|
|
280
|
+
if(!self.agent.profiler.isValidThreadId(exitCall.threadId)) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
267
283
|
|
|
268
284
|
if (exitCall.exitCallGuid == undefined) {
|
|
269
285
|
return;
|
|
@@ -310,12 +326,20 @@ LibagentConnector.prototype.sendInstanceTrackerInfo = function (instanceCounts)
|
|
|
310
326
|
|
|
311
327
|
LibagentConnector.prototype.isSnapshotRequired = function (transaction) {
|
|
312
328
|
var self = this;
|
|
329
|
+
if(!self.agent.profiler.isValidThreadId(transaction.threadId)) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
|
|
313
333
|
return self.libagent.isSnapshotRequired(transaction.btGuid);
|
|
314
334
|
};
|
|
315
335
|
|
|
316
336
|
LibagentConnector.prototype.sendTransactionSnapshot = function (transaction, transactionSnapshot) {
|
|
317
337
|
var self = this;
|
|
318
338
|
|
|
339
|
+
if(!self.agent.profiler.isValidThreadId(transaction.threadId)) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
319
343
|
// fixup exit calls: set all required fields so that the protobuf message remains valid
|
|
320
344
|
if (transactionSnapshot.snapshot.exitCalls) {
|
|
321
345
|
transactionSnapshot.snapshot.exitCalls.forEach(function (item) {
|
|
@@ -418,6 +442,9 @@ LibagentConnector.prototype.getBusinessTransactionId = function (txnGuid) {
|
|
|
418
442
|
LibagentConnector.prototype.setHttpParamsInTransactionSnapshot = function (transaction) {
|
|
419
443
|
var self = this;
|
|
420
444
|
// url, methis and statusCode should be present for all http requests
|
|
445
|
+
if(!self.agent.profiler.isValidThreadId(transaction.threadId)) {
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
421
448
|
if (transaction.url && transaction.method && transaction.statusCode) {
|
|
422
449
|
return self.libagent.setHttpParamsInTransactionSnapshot(
|
|
423
450
|
transaction.btGuid, transaction.url, transaction.method, transaction.statusCode);
|
|
@@ -426,11 +453,17 @@ LibagentConnector.prototype.setHttpParamsInTransactionSnapshot = function (trans
|
|
|
426
453
|
|
|
427
454
|
LibagentConnector.prototype.addHttpDataToTransactionSnapshot = function (transaction, request) {
|
|
428
455
|
var self = this;
|
|
456
|
+
if(!self.agent.profiler.isValidThreadId(transaction.threadId)) {
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
429
459
|
return self.libagent.addHttpDataToTransactionSnapshot(transaction.btGuid, request);
|
|
430
460
|
};
|
|
431
461
|
|
|
432
462
|
LibagentConnector.prototype.setSnapshotRequired = function (transaction) {
|
|
433
463
|
var self = this;
|
|
464
|
+
if(!self.agent.profiler.isValidThreadId(transaction)) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
434
467
|
self.libagent.setSnapshotRequired(transaction.btGuid);
|
|
435
468
|
};
|
|
436
469
|
|
|
@@ -535,7 +568,7 @@ LibagentConnector.prototype.initializeTimers = function () {
|
|
|
535
568
|
|
|
536
569
|
LibagentConnector.prototype.getEumCookieFields = function (transaction, shortForm) {
|
|
537
570
|
var self = this;
|
|
538
|
-
if (!transaction.ignore)
|
|
571
|
+
if (self.agent.profiler.isValidThreadId(transaction.threadId) && !transaction.ignore)
|
|
539
572
|
return self.libagent.getEumCookieFields(transaction.btGuid, shortForm);
|
|
540
573
|
else
|
|
541
574
|
return {};
|
|
@@ -545,6 +578,11 @@ LibagentConnector.prototype.setupEum = function (agent) {
|
|
|
545
578
|
var libAgentConnector = this;
|
|
546
579
|
agent.eum.eumCookie.prototype.setFieldValues = function () {
|
|
547
580
|
var self = this;
|
|
581
|
+
|
|
582
|
+
if(!agent.profiler.isValidThreadId(self.transaction.threadId)) {
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
|
|
548
586
|
var shortForm = self.keyForm == 'short';
|
|
549
587
|
var fields = libAgentConnector.getEumCookieFields(self.transaction, shortForm);
|
|
550
588
|
if (fields) {
|
|
@@ -70,6 +70,7 @@ HttpExitProbe.prototype.attach = function (obj, moduleName) {
|
|
|
70
70
|
var isRepeatForHttps = false;
|
|
71
71
|
|
|
72
72
|
var [input, options] = args;
|
|
73
|
+
|
|
73
74
|
if (typeof(input) != 'string' && !(input instanceof url.URL)) {
|
|
74
75
|
options = input;
|
|
75
76
|
input = null;
|
|
@@ -78,6 +79,13 @@ HttpExitProbe.prototype.attach = function (obj, moduleName) {
|
|
|
78
79
|
args[1] = options;
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
if(typeof(options) == 'function') {
|
|
83
|
+
args[2] = options;
|
|
84
|
+
options = {};
|
|
85
|
+
args[1] = options;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
81
89
|
if (moduleName === 'https') {
|
|
82
90
|
options.__appdIsHttps = true;
|
|
83
91
|
}
|
|
@@ -204,11 +212,12 @@ HttpExitProbe.prototype.attach = function (obj, moduleName) {
|
|
|
204
212
|
},
|
|
205
213
|
function (obj, args, ret, locals) {
|
|
206
214
|
var [input, options] = args;
|
|
215
|
+
|
|
207
216
|
if (typeof(input) != 'string' && !(input instanceof url.URL)) {
|
|
208
217
|
options = input;
|
|
209
218
|
input = null;
|
|
210
219
|
}
|
|
211
|
-
|
|
220
|
+
|
|
212
221
|
options = options || {};
|
|
213
222
|
if (!options.appdIgnore && (moduleName != 'http' || (moduleName === 'http' && !options.__appdIsHttps))) {
|
|
214
223
|
if (locals.parentSpan) {
|
|
@@ -261,7 +270,6 @@ HttpExitProbe.prototype.attach = function (obj, moduleName) {
|
|
|
261
270
|
httpParser = socket.parser;
|
|
262
271
|
var kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
|
|
263
272
|
httpParserMethod = kOnHeadersComplete ? kOnHeadersComplete : 'onHeadersComplete';
|
|
264
|
-
|
|
265
273
|
var socketCloseHandler = function () {
|
|
266
274
|
socket.removeListener('close', socketCloseHandler);
|
|
267
275
|
if (socket.__appdynamicsCleanup) {
|
|
@@ -99,6 +99,8 @@ MongodbProbe.prototype.attach = function (obj) {
|
|
|
99
99
|
var cid = event.connectionId;
|
|
100
100
|
if (typeof (cid) === 'string')
|
|
101
101
|
serverPool = [cid];
|
|
102
|
+
else if (typeof (cid) === 'number')
|
|
103
|
+
serverPool = [event.address];
|
|
102
104
|
else
|
|
103
105
|
serverPool = [cid.host + ':' + cid.port];
|
|
104
106
|
}
|
|
@@ -146,6 +148,7 @@ MongodbProbe.prototype.attach = function (obj) {
|
|
|
146
148
|
});
|
|
147
149
|
|
|
148
150
|
supportedCommands.forEach(function (command) {
|
|
151
|
+
proxy.before(obj.Collection.prototype, command, withAPMBeforeHandler);
|
|
149
152
|
proxy.before(obj.Server.prototype, command, withAPMBeforeHandler);
|
|
150
153
|
proxy.before(obj.ReplSet.prototype, command, withAPMBeforeHandler);
|
|
151
154
|
});
|
package/lib/profiler/profiler.js
CHANGED
|
@@ -179,6 +179,11 @@ Profiler.prototype.endTransaction = function (time, transaction) {
|
|
|
179
179
|
self._endTransaction(time, transaction);
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
+
Profiler.prototype.isValidThreadId = function(threadId) {
|
|
183
|
+
var self = this;
|
|
184
|
+
return (threadId && self.transactions[threadId]);
|
|
185
|
+
};
|
|
186
|
+
|
|
182
187
|
Profiler.prototype._endTransaction = function (time, transaction) {
|
|
183
188
|
var self = this;
|
|
184
189
|
|
|
@@ -228,7 +233,8 @@ Profiler.prototype.__getNextSequenceInfo = function (transaction) {
|
|
|
228
233
|
};
|
|
229
234
|
|
|
230
235
|
Profiler.prototype.createExitCall = function (time, exitCallInfo) {
|
|
231
|
-
|
|
236
|
+
var self = this;
|
|
237
|
+
return self.agent.backendConnector.createExitCall(time, exitCallInfo);
|
|
232
238
|
};
|
|
233
239
|
|
|
234
240
|
Profiler.prototype.addExitCall = function (time, exitCall, error) {
|
|
@@ -12,6 +12,8 @@ const REGISTER_PATH = "/argento-agent/v1/management";
|
|
|
12
12
|
|
|
13
13
|
const MIN_TIMER = 60 * 1000;
|
|
14
14
|
const DAY_TIMER = 24 * 60 * 60 * 1000;
|
|
15
|
+
const RETRY_THRESHOLD = 2;
|
|
16
|
+
const TIMEOUT = 1000;
|
|
15
17
|
|
|
16
18
|
exports.SecureApp = SecureApp;
|
|
17
19
|
function SecureApp() {
|
|
@@ -36,18 +38,56 @@ SecureApp.prototype.init = function(agent) {
|
|
|
36
38
|
self.agent.logger.debug('Secure App module initialized');
|
|
37
39
|
};
|
|
38
40
|
|
|
41
|
+
SecureApp.prototype._sendRequestWithRetry = function(options, data, cb)
|
|
42
|
+
{
|
|
43
|
+
var self = this;
|
|
44
|
+
options.currentRetryAttempt = 0;
|
|
45
|
+
self._sendRequest(options, data, cb);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
SecureApp.prototype._retryRequest = function(options, data, cb)
|
|
49
|
+
{
|
|
50
|
+
var self = this;
|
|
51
|
+
if (options.currentRetryAttempt === RETRY_THRESHOLD) {
|
|
52
|
+
return cb(null, new Error('Retry Threshold Reached'));
|
|
53
|
+
}
|
|
54
|
+
options.currentRetryAttempt++;
|
|
55
|
+
self.agent.logger.trace('SecureApp._retryRequest: Retry attempt ' + options.currentRetryAttempt + ' ' + options.path);
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
self._sendRequest(options, data, cb);
|
|
58
|
+
}, TIMEOUT);
|
|
59
|
+
};
|
|
60
|
+
|
|
39
61
|
SecureApp.prototype._sendRequest = function(options, data, cb) {
|
|
40
62
|
var self = this;
|
|
41
63
|
self.agent.logger.trace('SecureApp._sendRequest: ' + options.path + " Data: " + ((options.headers['Content-Type'] != 'application/json') ?
|
|
42
64
|
data.length.toString() : JSON.stringify(data).length.toString()));
|
|
43
65
|
|
|
44
66
|
var request = self.httpModule.request(options, function(response) {
|
|
45
|
-
|
|
67
|
+
const chunks = [];
|
|
68
|
+
response.on('data', data_chunk => chunks.push(data_chunk));
|
|
69
|
+
response.on('end', () => {
|
|
70
|
+
var statusCode = response.statusCode | 0;
|
|
71
|
+
// don't retry on http 413 (payload too large)
|
|
72
|
+
if(statusCode == 413) {
|
|
73
|
+
self.agent.logger.warn('Secure App Http Request failed ' + ' statusCode ' + statusCode);
|
|
74
|
+
return cb(null, new Error('Http Payload too large'));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (statusCode != 200 || response.is_error) {
|
|
78
|
+
self.agent.logger.info('Secure App Http Request failed ' + ' statusCode ' + statusCode + ' is_error ' + response.is_error);
|
|
79
|
+
return self._retryRequest(options, data, cb);
|
|
80
|
+
}
|
|
81
|
+
let body = Buffer.concat(chunks);
|
|
82
|
+
cb(body, null);
|
|
83
|
+
});
|
|
46
84
|
});
|
|
47
85
|
|
|
48
86
|
request.on('error', function(error) {
|
|
49
87
|
self.agent.logger.info('Secure app http request error : ' + error);
|
|
88
|
+
return self._retryRequest(options, data, cb);
|
|
50
89
|
});
|
|
90
|
+
|
|
51
91
|
request.end(data);
|
|
52
92
|
};
|
|
53
93
|
|
|
@@ -58,7 +98,7 @@ SecureApp.prototype._requestHeaders = function(requestOptions) {
|
|
|
58
98
|
requestOptions.headers['appdynamics-agent-applicationName'] = self.agent.opts.applicationName;
|
|
59
99
|
requestOptions.headers['appdynamics-agent-tierName'] = self.agent.opts.tierName;
|
|
60
100
|
requestOptions.headers['appdynamics-agent-nodeName'] = self.agent.opts.nodeName;
|
|
61
|
-
requestOptions.headers['appdynamics-agent-accountName'] = 'singularity-agent@' + self.agent.opts.accountName;
|
|
101
|
+
requestOptions.headers['appdynamics-agent-accountName'] = 'singularity-agent@' + self.agent.opts.accountName;
|
|
62
102
|
if (self.uuid) {
|
|
63
103
|
requestOptions.headers['appdynamics-agent-nodeUUID'] = self.uuid;
|
|
64
104
|
}
|
|
@@ -99,7 +139,7 @@ SecureApp.prototype._requestOptions = function(path, length, type) {
|
|
|
99
139
|
userName: self.agent.opts.proxyUser,
|
|
100
140
|
password: ""
|
|
101
141
|
};
|
|
102
|
-
|
|
142
|
+
|
|
103
143
|
if (self.agent.opts.proxyPasswordFile) {
|
|
104
144
|
var fs = require('fs');
|
|
105
145
|
proxy.password = (fs.readFileSync(self.agent.opts.proxyPasswordFile, 'utf-8')).trim();
|
|
@@ -150,25 +190,23 @@ SecureApp.prototype.authenticate = function(grantType) {
|
|
|
150
190
|
var postData = "password=" + self.agent.opts.accountAccessKey +
|
|
151
191
|
"&username=" + 'singularity-agent@' + self.agent.opts.accountName +
|
|
152
192
|
"&grant_type=" + grantType;
|
|
153
|
-
|
|
193
|
+
|
|
154
194
|
if(grantType == 'refresh_token') {
|
|
155
195
|
postData += '&refresh_token=' + self.refreshToken;
|
|
156
196
|
}
|
|
157
197
|
|
|
158
198
|
var requestOptions = self._requestOptions(AUTH_PATH, postData.length.toString(),
|
|
159
199
|
"application/x-www-form-urlencoded; charset=utf-8");
|
|
160
|
-
|
|
161
|
-
self.
|
|
162
|
-
|
|
163
|
-
if (statusCode != 200 || response.is_error) {
|
|
200
|
+
|
|
201
|
+
self._sendRequestWithRetry(requestOptions, postData, function(body, error) {
|
|
202
|
+
if (error != null) {
|
|
164
203
|
self.agent.logger.info('Secure App authentication failed');
|
|
204
|
+
self.accessToken = null;
|
|
205
|
+
self.refreshToken = null;
|
|
165
206
|
return;
|
|
166
207
|
}
|
|
167
208
|
|
|
168
|
-
|
|
169
|
-
response.on('data', data => chunks.push(data));
|
|
170
|
-
response.on('end', () => {
|
|
171
|
-
let body = Buffer.concat(chunks);
|
|
209
|
+
try {
|
|
172
210
|
body = JSON.parse(body);
|
|
173
211
|
if (!self.accessToken) {
|
|
174
212
|
self.regTimerId = new MessageSender(self.agent, 10 * 1000, MIN_TIMER, function () {
|
|
@@ -180,21 +218,25 @@ SecureApp.prototype.authenticate = function(grantType) {
|
|
|
180
218
|
self.refreshToken = body.refresh_token;
|
|
181
219
|
|
|
182
220
|
self.agent.logger.debug('Secure App module authenticated');
|
|
183
|
-
})
|
|
221
|
+
} catch(err) {
|
|
222
|
+
self.accessToken = null;
|
|
223
|
+
self.refreshToken = null;
|
|
224
|
+
self.agent.logger.warn('Failed to parse Secure app authentication response ' + err);
|
|
225
|
+
}
|
|
184
226
|
});
|
|
185
227
|
};
|
|
186
228
|
|
|
187
229
|
SecureApp.prototype.authToken = function() {
|
|
188
230
|
var self = this;
|
|
189
231
|
if(!self.accessToken) {
|
|
190
|
-
self.authenticate("password");
|
|
232
|
+
self.authenticate("password");
|
|
191
233
|
} else {
|
|
192
234
|
self.authenticate("refresh_token");
|
|
193
235
|
}
|
|
194
236
|
};
|
|
195
237
|
|
|
196
238
|
SecureApp.prototype.register = function() {
|
|
197
|
-
var self = this;
|
|
239
|
+
var self = this;
|
|
198
240
|
var postData = JSON.stringify({
|
|
199
241
|
"message_type": 0,
|
|
200
242
|
"app": self.agent.opts.applicationName,
|
|
@@ -215,21 +257,20 @@ SecureApp.prototype.register = function() {
|
|
|
215
257
|
var requestOptions = self._requestOptions(REGISTER_PATH, postData.length.toString(), "application/json");
|
|
216
258
|
self._requestHeaders(requestOptions);
|
|
217
259
|
|
|
218
|
-
self.
|
|
219
|
-
|
|
220
|
-
if (statusCode != 200 || response.is_error) {
|
|
260
|
+
self._sendRequestWithRetry(requestOptions, postData, function(body, error) {
|
|
261
|
+
if (error != null) {
|
|
221
262
|
self.agent.logger.info('Secure App module registeration failed');
|
|
222
263
|
return;
|
|
223
264
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
response.on('end', () => {
|
|
227
|
-
let body = Buffer.concat(chunks);
|
|
265
|
+
|
|
266
|
+
try {
|
|
228
267
|
body = JSON.parse(body);
|
|
229
268
|
self.uuid = body.node_uuid;
|
|
230
269
|
self._initializeTimers();
|
|
231
270
|
self.agent.logger.debug('Secure App module registered');
|
|
232
|
-
})
|
|
271
|
+
} catch(err) {
|
|
272
|
+
self.agent.logger.warn('Failed to parse Secure app registration response ' + err);
|
|
273
|
+
}
|
|
233
274
|
});
|
|
234
275
|
};
|
|
235
276
|
|
|
@@ -251,18 +292,12 @@ SecureApp.prototype.sendVulnerabilityEvent = function() {
|
|
|
251
292
|
var requestOptions = self._requestOptions(EVENT_PATH, postData.length.toString(), "application/json");
|
|
252
293
|
self._requestHeaders(requestOptions);
|
|
253
294
|
|
|
254
|
-
self.
|
|
255
|
-
|
|
256
|
-
if (statusCode != 200 || response.is_error) {
|
|
295
|
+
self._sendRequestWithRetry(requestOptions, postData, function(body, error) {
|
|
296
|
+
if (error != null) {
|
|
257
297
|
self.agent.logger.info('Secure App module vulnerability event failed');
|
|
258
298
|
return;
|
|
259
299
|
}
|
|
260
|
-
|
|
261
|
-
const chunks = [];
|
|
262
|
-
response.on('data', data => chunks.push(data));
|
|
263
|
-
response.on('end', () => {
|
|
264
|
-
self.agent.logger.info('Secure App module vulnerability event sent fragment');
|
|
265
|
-
});
|
|
300
|
+
self.agent.logger.info('Secure App module vulnerability event sent fragment');
|
|
266
301
|
});
|
|
267
302
|
});
|
|
268
303
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appdynamics",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.9.0",
|
|
4
4
|
"description": "Performance Profiler and Monitor",
|
|
5
5
|
"author": "AppDynamics, Inc.",
|
|
6
6
|
"homepage": "https://www.appdynamics.com",
|
|
@@ -45,12 +45,13 @@
|
|
|
45
45
|
"https-proxy-agent": "^5.0.0",
|
|
46
46
|
"uuid": "^8.3.2",
|
|
47
47
|
"y18n": "^5.0.8",
|
|
48
|
-
"appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/22.
|
|
49
|
-
"appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/22.
|
|
50
|
-
"appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/22.
|
|
48
|
+
"appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/22.9.0.0/appdynamics-libagent-napi-node.tgz",
|
|
49
|
+
"appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/22.9.0.0/appdynamics-native-node.tgz",
|
|
50
|
+
"appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/22.9.0.0/appdynamics-protobuf-node.tgz"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
|
-
"node": ">=12 <=
|
|
53
|
+
"node": ">=12 <=v17.*"
|
|
54
54
|
},
|
|
55
|
-
"engine-strict": true
|
|
55
|
+
"engine-strict": true,
|
|
56
|
+
"bundleDependencies": []
|
|
56
57
|
}
|
package/packageBck.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appdynamics",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.9.0",
|
|
4
4
|
"description": "Performance Profiler and Monitor",
|
|
5
5
|
"author": "AppDynamics, Inc.",
|
|
6
6
|
"homepage": "https://www.appdynamics.com",
|
|
@@ -45,12 +45,13 @@
|
|
|
45
45
|
"https-proxy-agent": "^5.0.0",
|
|
46
46
|
"uuid": "^8.3.2",
|
|
47
47
|
"y18n": "^5.0.8",
|
|
48
|
-
"appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/22.
|
|
49
|
-
"appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/22.
|
|
50
|
-
"appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/22.
|
|
48
|
+
"appdynamics-libagent-napi": "https://cdn.appdynamics.com/packages/nodejs/22.9.0.0/appdynamics-libagent-napi-node.tgz",
|
|
49
|
+
"appdynamics-native": "https://cdn.appdynamics.com/packages/nodejs/22.9.0.0/appdynamics-native-node.tgz",
|
|
50
|
+
"appdynamics-protobuf": "https://cdn.appdynamics.com/packages/nodejs/22.9.0.0/appdynamics-protobuf-node.tgz"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
|
-
"node": ">=12 <=
|
|
53
|
+
"node": ">=12 <=v17.*"
|
|
54
54
|
},
|
|
55
|
-
"engine-strict": true
|
|
55
|
+
"engine-strict": true,
|
|
56
|
+
"bundleDependencies": []
|
|
56
57
|
}
|