@instana/shared-metrics 4.6.2 → 4.6.3
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/CHANGELOG.md +6 -0
- package/package.json +3 -3
- package/src/dependencies.js +6 -5
- package/src/description.js +9 -13
- package/src/directDependencies.js +5 -4
- package/src/gc.js +26 -24
- package/src/healthchecks.js +5 -4
- package/src/index.js +51 -22
- package/src/keywords.js +10 -12
- package/src/libuv.js +21 -19
- package/src/name.js +8 -14
- package/src/util/DependencyDistanceCalculator.js +10 -9
- package/src/util/index.js +12 -8
- package/src/util/nativeModuleRetry.js +12 -12
- package/src/version.js +10 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.6.3](https://github.com/instana/nodejs/compare/v4.6.2...v4.6.3) (2025-03-05)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- reduced noise for dependency calculation debug logs ([#1589](https://github.com/instana/nodejs/issues/1589)) ([1aeaa94](https://github.com/instana/nodejs/commit/1aeaa94ad1431b5f7807d0e3d93384b585c97d5d))
|
|
11
|
+
|
|
6
12
|
## [4.6.2](https://github.com/instana/nodejs/compare/v4.6.1...v4.6.2) (2025-02-24)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instana/shared-metrics",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.3",
|
|
4
4
|
"description": "Internal metrics plug-in package for Node.js monitoring with Instana",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Bastian Krol",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"license": "MIT",
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@instana/core": "4.6.
|
|
62
|
+
"@instana/core": "4.6.3",
|
|
63
63
|
"detect-libc": "^2.0.2",
|
|
64
64
|
"event-loop-lag": "^1.4.0",
|
|
65
65
|
"semver": "^7.5.4",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"event-loop-stats": "1.4.1",
|
|
75
75
|
"gcstats.js": "1.0.0"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "7dc62e64ec6015db2184484fa6142a3eb0c552e0"
|
|
78
78
|
}
|
package/src/dependencies.js
CHANGED
|
@@ -8,16 +8,17 @@
|
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const { util, uninstrumentedFs: fs } = require('@instana/core');
|
|
10
10
|
|
|
11
|
-
let logger = require('@instana/core').logger.getLogger('metrics');
|
|
12
|
-
|
|
13
11
|
const CountDownLatch = require('./util/CountDownLatch');
|
|
14
12
|
const { DependencyDistanceCalculator, MAX_DEPTH } = require('./util/DependencyDistanceCalculator');
|
|
15
13
|
|
|
14
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
15
|
+
let logger;
|
|
16
|
+
|
|
16
17
|
/**
|
|
17
|
-
* @param {import('@instana/core/src/
|
|
18
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
18
19
|
*/
|
|
19
|
-
exports.
|
|
20
|
-
logger =
|
|
20
|
+
exports.init = function init(config) {
|
|
21
|
+
logger = config.logger;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
/** @type {number} */
|
package/src/description.js
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
const { applicationUnderMonitoring } = require('@instana/core').util;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
11
|
+
let logger;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* @param {import('@instana/core/src/
|
|
14
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
14
15
|
*/
|
|
15
|
-
exports.
|
|
16
|
-
logger =
|
|
16
|
+
exports.init = function init(config) {
|
|
17
|
+
logger = config.logger;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
exports.payloadPrefix = 'description';
|
|
@@ -24,19 +25,14 @@ const MAX_ATTEMPTS = 20;
|
|
|
24
25
|
const DELAY = 1000;
|
|
25
26
|
let attempts = 0;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
29
|
-
*/
|
|
30
|
-
exports.activate = function activate(config) {
|
|
28
|
+
exports.activate = function activate() {
|
|
31
29
|
attempts++;
|
|
32
|
-
|
|
30
|
+
|
|
31
|
+
applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule((err, packageJson) => {
|
|
33
32
|
if (err) {
|
|
34
33
|
return logger.warn(`Failed to determine main package json. Reason: ${err?.message} ${err?.stack}`);
|
|
35
34
|
} else if (!packageJson && attempts < MAX_ATTEMPTS) {
|
|
36
|
-
setTimeout(()
|
|
37
|
-
exports.activate(config);
|
|
38
|
-
}, DELAY).unref();
|
|
39
|
-
|
|
35
|
+
setTimeout(exports.activate, DELAY).unref();
|
|
40
36
|
return;
|
|
41
37
|
} else if (!packageJson) {
|
|
42
38
|
// final attempt failed, ignore silently
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
const { util, uninstrumentedFs: fs } = require('@instana/core');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
11
|
+
let logger;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* @param {import('@instana/core/src/
|
|
14
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
14
15
|
*/
|
|
15
|
-
exports.
|
|
16
|
-
logger =
|
|
16
|
+
exports.init = function init(config) {
|
|
17
|
+
logger = config.logger;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
exports.payloadPrefix = 'directDependencies';
|
package/src/gc.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const path = require('path');
|
|
9
|
-
|
|
10
9
|
const slidingWindow = require('@instana/core').util.slidingWindow;
|
|
10
|
+
const nativeModuleRetry = require('./util/nativeModuleRetry');
|
|
11
11
|
|
|
12
12
|
const windowOpts = { duration: 1000 };
|
|
13
13
|
const minorGcWindow = slidingWindow.create(windowOpts);
|
|
@@ -41,6 +41,31 @@ exports.currentPayload = {
|
|
|
41
41
|
statsSupported: false
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
exports.init = function init() {
|
|
45
|
+
const nativeModuleLoader = nativeModuleRetry.loadNativeAddOn({
|
|
46
|
+
nativeModuleName: 'gcstats.js',
|
|
47
|
+
moduleRoot: path.join(__dirname, '..'),
|
|
48
|
+
message:
|
|
49
|
+
'Could not load gcstats.js. You will not be able to see GC information in Instana for this application. This ' +
|
|
50
|
+
'typically occurs when native addons could not be built during module installation (npm install/yarn) or when ' +
|
|
51
|
+
'npm install --no-optional or yarn --ignore-optional have been used to install dependencies. See the ' +
|
|
52
|
+
'instructions to learn more about the requirements of the collector: ' +
|
|
53
|
+
'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation#native-add-ons'
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
nativeModuleLoader.once('loaded', gcStats_ => {
|
|
57
|
+
gcStats = gcStats_;
|
|
58
|
+
exports.currentPayload.statsSupported = true;
|
|
59
|
+
if (activateHasBeenCalled) {
|
|
60
|
+
actuallyActivate();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
nativeModuleLoader.once('failed', () => {
|
|
65
|
+
exports.currentPayload.statsSupported = false;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
44
69
|
exports.activate = function activate() {
|
|
45
70
|
activateHasBeenCalled = true;
|
|
46
71
|
if (gcStats) {
|
|
@@ -48,32 +73,9 @@ exports.activate = function activate() {
|
|
|
48
73
|
}
|
|
49
74
|
};
|
|
50
75
|
|
|
51
|
-
const nativeModuleLoader = require('./util/nativeModuleRetry')({
|
|
52
|
-
nativeModuleName: 'gcstats.js',
|
|
53
|
-
moduleRoot: path.join(__dirname, '..'),
|
|
54
|
-
message:
|
|
55
|
-
'Could not load gcstats.js. You will not be able to see GC information in Instana for this application. This ' +
|
|
56
|
-
'typically occurs when native addons could not be built during module installation (npm install/yarn) or when ' +
|
|
57
|
-
'npm install --no-optional or yarn --ignore-optional have been used to install dependencies. See the ' +
|
|
58
|
-
'instructions to learn more about the requirements of the collector: ' +
|
|
59
|
-
'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation#native-add-ons'
|
|
60
|
-
});
|
|
61
|
-
|
|
62
76
|
/** @type {NodeJS.Timeout} */
|
|
63
77
|
let senseIntervalHandle;
|
|
64
78
|
|
|
65
|
-
nativeModuleLoader.once('loaded', gcStats_ => {
|
|
66
|
-
gcStats = gcStats_;
|
|
67
|
-
exports.currentPayload.statsSupported = true;
|
|
68
|
-
if (activateHasBeenCalled) {
|
|
69
|
-
actuallyActivate();
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
nativeModuleLoader.once('failed', () => {
|
|
74
|
-
exports.currentPayload.statsSupported = false;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
79
|
function actuallyActivate() {
|
|
78
80
|
if (hasBeenActivated) {
|
|
79
81
|
return;
|
package/src/healthchecks.js
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
const { hook } = require('@instana/core').util;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
11
|
+
let logger;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* @param {import('@instana/core/src/
|
|
14
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
14
15
|
*/
|
|
15
|
-
exports.
|
|
16
|
-
logger =
|
|
16
|
+
exports.init = function init(config) {
|
|
17
|
+
logger = config.logger;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
/** @type {number} */
|
package/src/index.js
CHANGED
|
@@ -5,39 +5,66 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
+
const activeHandles = require('./activeHandles');
|
|
9
|
+
const activeRequests = require('./activeRequests');
|
|
10
|
+
const args = require('./args');
|
|
11
|
+
const dependencies = require('./dependencies');
|
|
12
|
+
const directDependencies = require('./directDependencies');
|
|
13
|
+
const description = require('./description');
|
|
14
|
+
const execArgs = require('./execArgs');
|
|
15
|
+
const gc = require('./gc');
|
|
16
|
+
const healthchecks = require('./healthchecks');
|
|
17
|
+
const heapSpaces = require('./heapSpaces');
|
|
18
|
+
const http = require('./http');
|
|
19
|
+
const keywords = require('./keywords');
|
|
20
|
+
const libuv = require('./libuv');
|
|
21
|
+
const memory = require('./memory');
|
|
22
|
+
const name = require('./name');
|
|
23
|
+
const version = require('./version');
|
|
24
|
+
const util = require('./util');
|
|
25
|
+
|
|
8
26
|
/** @type {Array.<import('@instana/core/src/metrics').InstanaMetricsModule>} */
|
|
9
27
|
const allMetrics = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
activeHandles,
|
|
29
|
+
activeRequests,
|
|
30
|
+
args,
|
|
31
|
+
dependencies,
|
|
32
|
+
directDependencies,
|
|
33
|
+
description,
|
|
34
|
+
execArgs,
|
|
35
|
+
gc,
|
|
36
|
+
healthchecks,
|
|
37
|
+
heapSpaces,
|
|
38
|
+
http,
|
|
39
|
+
keywords,
|
|
40
|
+
libuv,
|
|
41
|
+
memory,
|
|
42
|
+
name,
|
|
43
|
+
version
|
|
26
44
|
];
|
|
27
45
|
|
|
28
|
-
const util = require('./util');
|
|
29
|
-
|
|
30
46
|
/**
|
|
31
|
-
* @param {import('@instana/core/src/
|
|
47
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
32
48
|
*/
|
|
33
|
-
const
|
|
34
|
-
util.
|
|
49
|
+
const init = function (config) {
|
|
50
|
+
util.init(config);
|
|
51
|
+
dependencies.init(config);
|
|
52
|
+
description.init(config);
|
|
53
|
+
directDependencies.init(config);
|
|
54
|
+
healthchecks.init(config);
|
|
55
|
+
keywords.init(config);
|
|
56
|
+
name.init(config);
|
|
57
|
+
version.init(config);
|
|
58
|
+
name.init(config);
|
|
59
|
+
gc.init();
|
|
60
|
+
libuv.init();
|
|
35
61
|
};
|
|
36
62
|
|
|
37
63
|
/**
|
|
38
64
|
* @typedef {Object} InstanaSharedMetrics
|
|
39
65
|
* @property {Array.<import('@instana/core/src/metrics').InstanaMetricsModule>} allMetrics
|
|
40
66
|
* @property {import('./util')} util
|
|
67
|
+
* @property {(config: import('@instana/core/src/util/normalizeConfig').InstanaConfig) => void} init
|
|
41
68
|
* @property {(logger: import('@instana/core/src/core').GenericLogger) => void} setLogger
|
|
42
69
|
*/
|
|
43
70
|
|
|
@@ -45,5 +72,7 @@ const setLogger = function (logger) {
|
|
|
45
72
|
module.exports = {
|
|
46
73
|
allMetrics,
|
|
47
74
|
util,
|
|
48
|
-
|
|
75
|
+
init,
|
|
76
|
+
// TODO: Remove in next major release
|
|
77
|
+
setLogger: () => {}
|
|
49
78
|
};
|
package/src/keywords.js
CHANGED
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
const { applicationUnderMonitoring } = require('@instana/core').util;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
11
|
+
let logger;
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
|
-
* @param {import('@instana/core/src/
|
|
14
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
13
15
|
*/
|
|
14
|
-
exports.
|
|
15
|
-
logger =
|
|
16
|
+
exports.init = function init(config) {
|
|
17
|
+
logger = config.logger;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
exports.payloadPrefix = 'keywords';
|
|
@@ -24,18 +26,14 @@ const MAX_ATTEMPTS = 20;
|
|
|
24
26
|
const DELAY = 1000;
|
|
25
27
|
let attempts = 0;
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
29
|
-
*/
|
|
30
|
-
exports.activate = function activate(config) {
|
|
29
|
+
exports.activate = function activate() {
|
|
31
30
|
attempts++;
|
|
32
|
-
|
|
31
|
+
|
|
32
|
+
applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule((err, packageJson) => {
|
|
33
33
|
if (err) {
|
|
34
34
|
return logger.warn(`Failed to determine main package json. Reason: ${err?.message} ${err?.stack}`);
|
|
35
35
|
} else if (!packageJson && attempts < MAX_ATTEMPTS) {
|
|
36
|
-
setTimeout(()
|
|
37
|
-
exports.activate(config);
|
|
38
|
-
}, DELAY).unref();
|
|
36
|
+
setTimeout(exports.activate, DELAY).unref();
|
|
39
37
|
|
|
40
38
|
return;
|
|
41
39
|
} else if (!packageJson) {
|
package/src/libuv.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const path = require('path');
|
|
9
|
-
|
|
9
|
+
const nativeModuleRetry = require('./util/nativeModuleRetry');
|
|
10
10
|
const lag = require('event-loop-lag')(1000);
|
|
11
11
|
|
|
12
12
|
/** @type {*} */
|
|
@@ -14,24 +14,26 @@ let eventLoopStats;
|
|
|
14
14
|
|
|
15
15
|
exports.payloadPrefix = 'libuv';
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
exports.init = function init() {
|
|
18
|
+
const nativeModuleLoader = nativeModuleRetry.loadNativeAddOn({
|
|
19
|
+
nativeModuleName: 'event-loop-stats',
|
|
20
|
+
moduleRoot: path.join(__dirname, '..'),
|
|
21
|
+
message:
|
|
22
|
+
'Could not load event-loop-stats. You will only see limited event loop information in Instana for this ' +
|
|
23
|
+
'application. This typically occurs when native addons could not be built during module installation ' +
|
|
24
|
+
'(npm install/yarn) or when npm install --no-optional or yarn --ignore-optional have been used to install ' +
|
|
25
|
+
'dependencies. See the instructions to learn more about the requirements of the collector: ' +
|
|
26
|
+
'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation#native-add-ons'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
nativeModuleLoader.once('loaded', eventLoopStats_ => {
|
|
30
|
+
eventLoopStats = eventLoopStats_;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
nativeModuleLoader.once('failed', () => {
|
|
34
|
+
exports.currentPayload.statsSupported = false;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
35
37
|
|
|
36
38
|
Object.defineProperty(exports, 'currentPayload', {
|
|
37
39
|
get: function () {
|
package/src/name.js
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
const { applicationUnderMonitoring } = require('@instana/core').util;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
11
|
+
let logger;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* @param {import('@instana/core/src/
|
|
14
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
14
15
|
*/
|
|
15
|
-
exports.
|
|
16
|
-
logger =
|
|
16
|
+
exports.init = function init(config) {
|
|
17
|
+
logger = config.logger;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
exports.payloadPrefix = 'name';
|
|
@@ -24,22 +25,15 @@ exports.MAX_ATTEMPTS = 60;
|
|
|
24
25
|
exports.DELAY = 1000;
|
|
25
26
|
let attempts = 0;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
29
|
-
*/
|
|
30
|
-
exports.activate = function activate(config) {
|
|
28
|
+
exports.activate = function activate() {
|
|
31
29
|
attempts++;
|
|
32
30
|
|
|
33
|
-
applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule(
|
|
31
|
+
applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule((err, packageJson) => {
|
|
34
32
|
if (err) {
|
|
35
33
|
return logger.warn(`Failed to determine main package json. Reason: ${err?.message} ${err?.stack}`);
|
|
36
34
|
} else if (!packageJson && attempts < exports.MAX_ATTEMPTS) {
|
|
37
35
|
logger.debug('Main package.json could not be found. Will try again later.');
|
|
38
|
-
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
exports.activate(config);
|
|
41
|
-
}, exports.DELAY).unref();
|
|
42
|
-
|
|
36
|
+
setTimeout(exports.activate, exports.DELAY).unref();
|
|
43
37
|
return;
|
|
44
38
|
} else if (!packageJson) {
|
|
45
39
|
if (require.main) {
|
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const assert = require('assert');
|
|
9
|
-
const {
|
|
9
|
+
const { uninstrumentedFs: fs } = require('@instana/core');
|
|
10
10
|
const path = require('path');
|
|
11
11
|
|
|
12
12
|
const CountDownLatch = require('./CountDownLatch');
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
15
|
+
let logger;
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
* @param {import('@instana/core/src/
|
|
18
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
18
19
|
*/
|
|
19
|
-
const
|
|
20
|
-
logger =
|
|
20
|
+
const init = config => {
|
|
21
|
+
logger = config.logger;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
class DependencyDistanceCalculator {
|
|
@@ -174,7 +175,7 @@ class DependencyDistanceCalculator {
|
|
|
174
175
|
mainModulePath = require.resolve(dependency);
|
|
175
176
|
} catch (requireResolveErr) {
|
|
176
177
|
// ignore
|
|
177
|
-
logger.
|
|
178
|
+
logger.trace(
|
|
178
179
|
`Ignoring failure to resolve the path to dependency ${dependency} for dependency distance calculation.`
|
|
179
180
|
);
|
|
180
181
|
}
|
|
@@ -183,7 +184,7 @@ class DependencyDistanceCalculator {
|
|
|
183
184
|
// Could not find the package.json for this dependency so we cannot analyze it further, which means we are done
|
|
184
185
|
// with it.
|
|
185
186
|
localCountDownLatchForThisNode.countDown();
|
|
186
|
-
logger.
|
|
187
|
+
logger.trace(`Ignoring ${dependency} for dependency distance calculation, could not find main module path.`);
|
|
187
188
|
return;
|
|
188
189
|
}
|
|
189
190
|
|
|
@@ -269,8 +270,8 @@ function searchInParentDir(dir, onParentDir, callback) {
|
|
|
269
270
|
}
|
|
270
271
|
|
|
271
272
|
module.exports = {
|
|
273
|
+
init,
|
|
272
274
|
DependencyDistanceCalculator,
|
|
273
275
|
MAX_DEPTH: 15,
|
|
274
|
-
__moduleRefExportedForTest: module
|
|
275
|
-
setLogger
|
|
276
|
+
__moduleRefExportedForTest: module
|
|
276
277
|
};
|
package/src/util/index.js
CHANGED
|
@@ -6,14 +6,18 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const nativeModuleRetry = require('./nativeModuleRetry');
|
|
9
|
-
const
|
|
9
|
+
const dependencyDistanceCalculator = require('./DependencyDistanceCalculator');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
13
|
+
*/
|
|
14
|
+
const init = config => {
|
|
15
|
+
nativeModuleRetry.init(config);
|
|
16
|
+
dependencyDistanceCalculator.init(config);
|
|
17
|
+
};
|
|
18
|
+
|
|
10
19
|
module.exports = {
|
|
20
|
+
init,
|
|
11
21
|
nativeModuleRetry,
|
|
12
|
-
|
|
13
|
-
* @param {import('@instana/core/src/core').GenericLogger} logger
|
|
14
|
-
*/
|
|
15
|
-
setLogger: function setLogger(logger) {
|
|
16
|
-
nativeModuleRetry.setLogger(logger);
|
|
17
|
-
setLoggerForDependencyDistanceCalculator(logger);
|
|
18
|
-
}
|
|
22
|
+
dependencyDistanceCalculator
|
|
19
23
|
};
|
|
@@ -5,15 +5,23 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
const {
|
|
9
|
-
let logger = Logger.getLogger('shared-metrics/native-module-retry');
|
|
10
|
-
|
|
8
|
+
const { uninstrumentedFs: fs } = require('@instana/core');
|
|
11
9
|
const EventEmitter = require('events');
|
|
12
10
|
const os = require('os');
|
|
13
11
|
const tar = require('tar');
|
|
14
12
|
const path = require('path');
|
|
15
13
|
const detectLibc = require('detect-libc');
|
|
16
14
|
|
|
15
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
16
|
+
let logger;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
20
|
+
*/
|
|
21
|
+
exports.init = function init(config) {
|
|
22
|
+
logger = config.logger;
|
|
23
|
+
};
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* @typedef {Object} InstanaSharedMetricsOptions
|
|
19
27
|
* @property {string} [nativeModuleName]
|
|
@@ -289,14 +297,6 @@ function createNativeModulePath(opts) {
|
|
|
289
297
|
return true;
|
|
290
298
|
}
|
|
291
299
|
|
|
292
|
-
loadNativeAddOn.setLogger = setLogger;
|
|
293
300
|
loadNativeAddOn.selfNodeModulesPath = '';
|
|
294
301
|
|
|
295
|
-
|
|
296
|
-
* @param {import('@instana/core/src/core').GenericLogger} _logger
|
|
297
|
-
*/
|
|
298
|
-
function setLogger(_logger) {
|
|
299
|
-
logger = _logger;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
module.exports = loadNativeAddOn;
|
|
302
|
+
exports.loadNativeAddOn = loadNativeAddOn;
|
package/src/version.js
CHANGED
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
const { applicationUnderMonitoring } = require('@instana/core').util;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** @type {import('@instana/core/src/core').GenericLogger} */
|
|
11
|
+
let logger;
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
|
-
* @param {import('@instana/core/src/
|
|
14
|
+
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
13
15
|
*/
|
|
14
|
-
exports.
|
|
15
|
-
logger =
|
|
16
|
+
exports.init = function init(config) {
|
|
17
|
+
logger = config.logger;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
exports.payloadPrefix = 'version';
|
|
@@ -23,18 +25,14 @@ const MAX_ATTEMPTS = 20;
|
|
|
23
25
|
const DELAY = 1000;
|
|
24
26
|
let attempts = 0;
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
* @param {import('@instana/core/src/util/normalizeConfig').InstanaConfig} config
|
|
28
|
-
*/
|
|
29
|
-
exports.activate = function activate(config) {
|
|
28
|
+
exports.activate = function activate() {
|
|
30
29
|
attempts++;
|
|
31
|
-
|
|
30
|
+
|
|
31
|
+
applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule((err, packageJson) => {
|
|
32
32
|
if (err) {
|
|
33
33
|
return logger.warn(`Failed to determine main package json. Reason: ${err?.message} ${err?.stack}`);
|
|
34
34
|
} else if (!packageJson && attempts < MAX_ATTEMPTS) {
|
|
35
|
-
setTimeout(()
|
|
36
|
-
exports.activate(config);
|
|
37
|
-
}, DELAY).unref();
|
|
35
|
+
setTimeout(exports.activate, DELAY).unref();
|
|
38
36
|
|
|
39
37
|
return;
|
|
40
38
|
} else if (!packageJson) {
|