@instana/shared-metrics 1.131.0 → 1.132.2
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": "@instana/shared-metrics",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.132.2",
|
|
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": "1.
|
|
62
|
+
"@instana/core": "1.132.2",
|
|
63
63
|
"detect-libc": "^1.0.3",
|
|
64
64
|
"event-loop-lag": "^1.4.0",
|
|
65
65
|
"recursive-copy": "^2.0.13",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"gcstats.js": "1.0.0",
|
|
79
79
|
"node-gyp": "^7.1.2"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "05a4a392340c90788ed075cc205e5b5858ebb815"
|
|
82
82
|
}
|
|
@@ -57,6 +57,9 @@ class DependencyDistanceCalculator {
|
|
|
57
57
|
// Do not descend deeper than maxDepth nesting levels.
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
+
if (typeof packageJsonPath !== 'string') {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
60
63
|
|
|
61
64
|
// For each package.json that we find in the dependency tree, we initially increase the global count down latch
|
|
62
65
|
// by 3, that is, one for each type of dependencies (normal, optional, peer). Once we have in turn queued all
|
|
@@ -66,39 +69,52 @@ class DependencyDistanceCalculator {
|
|
|
66
69
|
this.globalCountDownLatchAllPackages.countUp(3);
|
|
67
70
|
|
|
68
71
|
// Read the associated package.json and parse it.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
try {
|
|
73
|
+
fs.readFile(packageJsonPath, { encoding: 'utf8' }, (err, contents) => {
|
|
74
|
+
if (err) {
|
|
75
|
+
logger.debug(
|
|
76
|
+
'Failed to calculate transitive distances for some dependencies, could not read package.json file at ' +
|
|
77
|
+
'%s: %s.',
|
|
78
|
+
packageJsonPath,
|
|
79
|
+
err.message
|
|
80
|
+
);
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
// If we cannot parse the package.json or if it does not exist, we need to decrement by 3 immediately because
|
|
83
|
+
// we increment the latch by 3 for each node (see above).
|
|
84
|
+
this.globalCountDownLatchAllPackages.countDown(3);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
82
87
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
let parsedPackageJson;
|
|
89
|
+
try {
|
|
90
|
+
parsedPackageJson = JSON.parse(contents);
|
|
91
|
+
} catch (parseErr) {
|
|
92
|
+
logger.debug(
|
|
93
|
+
'Failed to calculate transitive distances for some dependencies, could not parse package.json file at ' +
|
|
94
|
+
'%s: %s',
|
|
95
|
+
packageJsonPath,
|
|
96
|
+
parseErr.message
|
|
97
|
+
);
|
|
98
|
+
this.globalCountDownLatchAllPackages.countDown(3);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
95
101
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
// Each call to _calculateDistancesForOneType is guaranteed to decrease the global count down latch by exactly
|
|
103
|
+
// one, to offset the increment of 3 that we did for this node in the dependency tree initially.
|
|
104
|
+
this._calculateDistancesForOneType(parsedPackageJson.dependencies, distance);
|
|
105
|
+
this._calculateDistancesForOneType(parsedPackageJson.peerDependencies, distance);
|
|
106
|
+
this._calculateDistancesForOneType(parsedPackageJson.optionalDependencies, distance);
|
|
107
|
+
});
|
|
108
|
+
} catch (fsReadFileErr) {
|
|
109
|
+
// This catch-block is for synchronous errors from fs.readFile, which can also happen in addition to the callback
|
|
110
|
+
// being called with an error.
|
|
111
|
+
logger.debug(
|
|
112
|
+
'Failed to calculate transitive distances for some dependencies, synchronous error from fs.readFile for %s:',
|
|
113
|
+
packageJsonPath,
|
|
114
|
+
fsReadFileErr
|
|
115
|
+
);
|
|
116
|
+
this.globalCountDownLatchAllPackages.countDown(3);
|
|
117
|
+
}
|
|
102
118
|
}
|
|
103
119
|
|
|
104
120
|
/**
|
|
@@ -186,6 +202,14 @@ class DependencyDistanceCalculator {
|
|
|
186
202
|
);
|
|
187
203
|
return;
|
|
188
204
|
}
|
|
205
|
+
if (typeof packageJsonPath !== 'string') {
|
|
206
|
+
localCountDownLatchForThisNode.countDown();
|
|
207
|
+
logger.debug(
|
|
208
|
+
`Ignoring failure to find the package.json file for dependency ${dependency} for dependency distance ` +
|
|
209
|
+
`calculation (package.json path is ${packageJsonPath}/${typeof packageJsonPath}).`
|
|
210
|
+
);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
189
213
|
|
|
190
214
|
// Recurse one level deeper and queue the next package.json path for analysis.
|
|
191
215
|
this._calculateDistances(packageJsonPath, distance + 1);
|
|
@@ -205,23 +229,30 @@ class DependencyDistanceCalculator {
|
|
|
205
229
|
* @param {string} dir
|
|
206
230
|
* @param {(err: Error, packageJsonPath: string) => void} callback
|
|
207
231
|
*/
|
|
232
|
+
|
|
208
233
|
function findPackageJsonFor(dir, callback) {
|
|
209
234
|
const pathToCheck = path.join(dir, 'package.json');
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (err
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
235
|
+
try {
|
|
236
|
+
fs.stat(pathToCheck, (err, stats) => {
|
|
237
|
+
if (err) {
|
|
238
|
+
if (err.code === 'ENOENT') {
|
|
239
|
+
return searchInParentDir(dir, findPackageJsonFor, callback);
|
|
240
|
+
} else {
|
|
241
|
+
return process.nextTick(callback, err, null);
|
|
242
|
+
}
|
|
216
243
|
}
|
|
217
|
-
}
|
|
218
244
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
245
|
+
if (stats.isFile()) {
|
|
246
|
+
return process.nextTick(callback, null, pathToCheck);
|
|
247
|
+
} else {
|
|
248
|
+
return searchInParentDir(dir, findPackageJsonFor, callback);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
} catch (fsStatErr) {
|
|
252
|
+
// This catch-block is for synchronous errors from fs.stat, which can also happen in addition to the callback being
|
|
253
|
+
// called with an error. The error will be logged in _handleTransitiveDependency.
|
|
254
|
+
return process.nextTick(callback, fsStatErr, null);
|
|
255
|
+
}
|
|
225
256
|
}
|
|
226
257
|
|
|
227
258
|
/**
|