@ikonintegration/ikapi 3.1.25 → 3.1.28
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikonintegration/ikapi",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.28",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "main.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@aws-sdk/credential-provider-node": "^3.137.0",
|
|
18
18
|
"@aws-sdk/node-http-handler": "^3.127.0",
|
|
19
19
|
"@aws-sdk/util-dynamodb": "^3.137.0",
|
|
20
|
-
"@ikonintegration/mod-resources-tracker-client": "0.0.
|
|
20
|
+
"@ikonintegration/mod-resources-tracker-client": "0.0.17",
|
|
21
21
|
"abind": "^1.0.5",
|
|
22
22
|
"bluebird": "^3.7.2",
|
|
23
23
|
"email-templates": "^8.0.8",
|
|
@@ -35,7 +35,7 @@ export default class IKProcess {
|
|
|
35
35
|
await this._execute(executionFunc);
|
|
36
36
|
}, this.interval);
|
|
37
37
|
//
|
|
38
|
-
if (this.allowExecutionIdentification && this.tracker) await this.tracker.
|
|
38
|
+
if (this.allowExecutionIdentification && this.tracker) await this.tracker.trackExecAndDrain(true);
|
|
39
39
|
}
|
|
40
40
|
//Executions
|
|
41
41
|
async _execute(executionFunc) {
|
|
@@ -103,7 +103,7 @@ export default class IKTransaction {
|
|
|
103
103
|
await safeExecution();
|
|
104
104
|
await this.logger.flushLogs();
|
|
105
105
|
//Tracker
|
|
106
|
-
if (this.tracker) await this.tracker.
|
|
106
|
+
if (this.tracker) await this.tracker.trackExecAndDrain(true);
|
|
107
107
|
} catch (e) {
|
|
108
108
|
this.logger.error('Exception when flushing logs.');
|
|
109
109
|
this.logger.exception(e);
|
|
@@ -8,6 +8,7 @@ export default class IKExecutionTracker {
|
|
|
8
8
|
constructor(config, context, db) {
|
|
9
9
|
this.context = context;
|
|
10
10
|
this.db = db;
|
|
11
|
+
this.config = config;
|
|
11
12
|
this.startedOn = Date.now();
|
|
12
13
|
if (config) this.client = this._getClient(config);
|
|
13
14
|
this.claimers = {};
|
|
@@ -24,12 +25,14 @@ export default class IKExecutionTracker {
|
|
|
24
25
|
await this.client.drain(this.claimers);
|
|
25
26
|
} catch (e) { console.error(`Error while draining tracker events: ${e}`); }
|
|
26
27
|
}
|
|
27
|
-
async
|
|
28
|
+
async trackExecAndDrain(isAutotracking) {
|
|
28
29
|
try {
|
|
29
30
|
//Check for client and claimers
|
|
30
31
|
if (!this.client || Object.keys(this.claimers).length == 0) return; //disabled
|
|
32
|
+
//Check for config
|
|
33
|
+
if (isAutotracking && this.config.disableAutoTracking) return; //disabled
|
|
31
34
|
//detect execution and log (ECS or lambda)
|
|
32
|
-
this._detectExecutionAndLog();
|
|
35
|
+
this._detectExecutionAndLog(isAutotracking);
|
|
33
36
|
//detect DB and log (DDB only for now)
|
|
34
37
|
this._collectDDBStats();
|
|
35
38
|
//drain stats
|
|
@@ -37,14 +40,14 @@ export default class IKExecutionTracker {
|
|
|
37
40
|
} catch (e) { console.error(`Error while tracking execution: ${e}`); }
|
|
38
41
|
}
|
|
39
42
|
/* private tracker */
|
|
40
|
-
_detectExecutionAndLog() {
|
|
43
|
+
_detectExecutionAndLog(isAutotracking) {
|
|
41
44
|
//Is running on container?
|
|
42
45
|
if (Utils.isHybridlessContainer()) {
|
|
43
46
|
//ECS, get metadata info and log if applicable and succeeded on it
|
|
44
47
|
const context = this._getECSMetadataObject();
|
|
45
48
|
// console.debug('Context', context);
|
|
46
49
|
if (context && context.ContainerInstanceARN) {
|
|
47
|
-
const extraDetails = { startTime: this.startedOn, endTime: Date.now(), taskConfig: { cpu: process.env.CPU, memory: process.env.MEMORY, taskName: context.TaskDefinitionFamily } };
|
|
50
|
+
const extraDetails = { startTime: this.startedOn, endTime: isAutotracking ? Date.now() : -1, taskConfig: { cpu: process.env.CPU, memory: process.env.MEMORY, taskName: context.TaskDefinitionFamily } };
|
|
48
51
|
const event = RTClient.newECSExecutionEvent(context.TaskARN, context.ContainerInstanceARN, extraDetails);
|
|
49
52
|
this.appendEvent(event);
|
|
50
53
|
}
|