@instana/shared-metrics 4.5.1 → 4.5.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 CHANGED
@@ -3,6 +3,18 @@
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.5.3](https://github.com/instana/nodejs/compare/v4.5.2...v4.5.3) (2025-01-14)
7
+
8
+ ### Bug Fixes
9
+
10
+ - resolved more logging objects structure ([#1510](https://github.com/instana/nodejs/issues/1510)) ([bd4c9bb](https://github.com/instana/nodejs/commit/bd4c9bbda2c82aee7f6c59fcca03ac5588566839))
11
+
12
+ ## [4.5.2](https://github.com/instana/nodejs/compare/v4.5.1...v4.5.2) (2025-01-13)
13
+
14
+ ### Bug Fixes
15
+
16
+ - resolved logging objects being undefined or missing ([#1509](https://github.com/instana/nodejs/issues/1509)) ([7715fed](https://github.com/instana/nodejs/commit/7715fed5843716a6e49d79f221efcec33a9a1c9d))
17
+
6
18
  ## [4.5.1](https://github.com/instana/nodejs/compare/v4.5.0...v4.5.1) (2025-01-13)
7
19
 
8
20
  **Note:** Version bump only for package @instana/shared-metrics
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instana/shared-metrics",
3
- "version": "4.5.1",
3
+ "version": "4.5.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.5.1",
62
+ "@instana/core": "4.5.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": "41c09b8fdd23f6cb0df992c7e479d71532ac91b4"
77
+ "gitHead": "cac14d4c9f5efa60edee223d45d6220a79336508"
78
78
  }
@@ -44,7 +44,7 @@ exports.activate = function activate() {
44
44
  const started = Date.now();
45
45
  util.applicationUnderMonitoring.getMainPackageJsonPathStartingAtMainModule((err, mainPackageJsonPath) => {
46
46
  if (err) {
47
- return logger.warn('Failed to determine main package.json. Reason: %s %s ', err.message, err.stack);
47
+ return logger.warn(`Failed to determine main package.json. Reason: ${err?.message}, ${err?.stack}`);
48
48
  } else if (!mainPackageJsonPath && attempts < exports.MAX_ATTEMPTS) {
49
49
  logger.debug(`Main package.json could not be found at ${mainPackageJsonPath}. Will try again later.`);
50
50
  setTimeout(exports.activate, DELAY).unref();
@@ -55,7 +55,7 @@ exports.activate = function activate() {
55
55
  );
56
56
  util.applicationUnderMonitoring.findNodeModulesFolder((errNodeModules, nodeModulesFolder) => {
57
57
  if (errNodeModules) {
58
- return logger.warn('Failed to determine node_modules folder. Reason: %s %s ', err.message, err.stack);
58
+ return logger.warn(`Failed to determine node_modules folder. Reason: ${err?.message}, ${err?.stack}`);
59
59
  } else if (!nodeModulesFolder) {
60
60
  return logger.warn(
61
61
  'Neither the package.json file nor the node_modules folder could be found. Stopping dependency analysis.'
@@ -116,7 +116,7 @@ function addAllDependencies(dependencyDir, started, packageJsonPath) {
116
116
  function addDependenciesFromDir(dependencyDir, callback) {
117
117
  fs.readdir(dependencyDir, (readDirErr, dependencies) => {
118
118
  if (readDirErr || !dependencies) {
119
- logger.warn('Cannot analyse dependencies due to %s', readDirErr.message);
119
+ logger.warn(`Cannot analyse dependencies due to ${readDirErr?.message}`);
120
120
  callback();
121
121
  return;
122
122
  }
@@ -150,7 +150,7 @@ function addDependenciesFromDir(dependencyDir, callback) {
150
150
  fs.stat(fullDirPath, (statErr, stats) => {
151
151
  if (statErr) {
152
152
  countDownLatch.countDown();
153
- logger.warn('Cannot analyse dependency %s due to %s', fullDirPath, statErr.message);
153
+ logger.warn(`Cannot analyse dependency ${fullDirPath} due to ${statErr?.message}`);
154
154
  return;
155
155
  }
156
156
  if (!stats.isDirectory()) {
@@ -185,10 +185,8 @@ function addDependency(dependency, dependencyDirPath, countDownLatch) {
185
185
  } else if (err) {
186
186
  countDownLatch.countDown();
187
187
  logger.info(
188
- 'Failed to identify version of %s dependency due to: %s. This means that you will not be ' +
189
- 'able to see details about this dependency within Instana.',
190
- dependency,
191
- err.message
188
+ `Failed to identify version of ${dependency} dependency due to: ${err?.message}. ` +
189
+ 'This means that you will not be able to see details about this dependency within Instana.'
192
190
  );
193
191
  return;
194
192
  }
@@ -200,10 +198,8 @@ function addDependency(dependency, dependencyDirPath, countDownLatch) {
200
198
  }
201
199
  } catch (parseErr) {
202
200
  return logger.info(
203
- 'Failed to identify version of %s dependency due to: %s. This means that you will not be ' +
204
- 'able to see details about this dependency within Instana.',
205
- dependency,
206
- parseErr.message
201
+ `Failed to identify version of ${dependency} dependency due to: ${parseErr?.message}.
202
+ This means that you will not be able to see details about this dependency within Instana.`
207
203
  );
208
204
  }
209
205
 
@@ -31,7 +31,7 @@ exports.activate = function activate(config) {
31
31
  attempts++;
32
32
  applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule(config, (err, packageJson) => {
33
33
  if (err) {
34
- return logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack);
34
+ return logger.warn(`Failed to determine main package json. Reason: ${err?.message} ${err?.stack}`);
35
35
  } else if (!packageJson && attempts < MAX_ATTEMPTS) {
36
36
  setTimeout(() => {
37
37
  exports.activate(config);
@@ -38,9 +38,8 @@ exports.activate = function activate() {
38
38
  util.applicationUnderMonitoring.getMainPackageJsonPathStartingAtMainModule((err, packageJsonPath) => {
39
39
  if (err) {
40
40
  return logger.info(
41
- 'Failed to determine main package.json for analysis of direct dependencies. Reason: %s %s ',
42
- err.message,
43
- err.stack
41
+ `Failed to determine main package.json for analysis of direct dependencies.
42
+ Reason: ${err?.message} ${err?.stack}`
44
43
  );
45
44
  } else if (!packageJsonPath && attempts < MAX_ATTEMPTS) {
46
45
  setTimeout(exports.activate, DELAY).unref();
@@ -63,7 +62,7 @@ function addDirectDependenciesFromMainPackageJson(packageJsonPath) {
63
62
  const started = Date.now();
64
63
  fs.readFile(packageJsonPath, { encoding: 'utf8' }, (err, contents) => {
65
64
  if (err) {
66
- return logger.debug('Failed to analyze direct dependencies dependency due to: %s.', err.message);
65
+ return logger.debug(`Failed to analyze direct dependencies dependency due to: ${err?.message}`);
67
66
  }
68
67
 
69
68
  try {
@@ -75,7 +74,7 @@ function addDirectDependenciesFromMainPackageJson(packageJsonPath) {
75
74
  logger.debug(`Collection of direct dependencies took ${Date.now() - started} ms.`);
76
75
  } catch (subErr) {
77
76
  logger.debug(`Collection of direct dependencies took ${Date.now() - started} ms.`);
78
- return logger.debug('Failed to parse package.json %s dependency due to: %s', packageJsonPath, subErr.message);
77
+ return logger.debug(`Failed to parse package.json ${packageJsonPath} dependency due to: ${subErr?.message}`);
79
78
  }
80
79
  });
81
80
  }
@@ -79,7 +79,7 @@ function gatherHealthcheckResults() {
79
79
  .catch(function onHealthcheckResultFailure(/** @type {*} */ err) {
80
80
  // @ts-ignore
81
81
  exports.currentPayload = {};
82
- logger.warn('Unexpected error while getting healthcheck results', err);
82
+ logger.warn(`Unexpected error while getting healthcheck results. ${err?.message} ${err?.stack}`);
83
83
  timeoutHandle = setTimeout(gatherHealthcheckResults, timeBetweenHealthcheckCalls);
84
84
  timeoutHandle.unref();
85
85
  });
package/src/keywords.js CHANGED
@@ -31,7 +31,7 @@ exports.activate = function activate(config) {
31
31
  attempts++;
32
32
  applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule(config, (err, packageJson) => {
33
33
  if (err) {
34
- return logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack);
34
+ return logger.warn(`Failed to determine main package json. Reason: ${err?.message} ${err?.stack}`);
35
35
  } else if (!packageJson && attempts < MAX_ATTEMPTS) {
36
36
  setTimeout(() => {
37
37
  exports.activate(config);
package/src/name.js CHANGED
@@ -32,7 +32,7 @@ exports.activate = function activate(config) {
32
32
 
33
33
  applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule(config, (err, packageJson) => {
34
34
  if (err) {
35
- return logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack);
35
+ return logger.warn(`Failed to determine main package json. Reason: ${err?.message} ${err?.stack}`);
36
36
  } else if (!packageJson && attempts < exports.MAX_ATTEMPTS) {
37
37
  logger.debug('Main package.json could not be found. Will try again later.');
38
38
 
@@ -73,10 +73,8 @@ class DependencyDistanceCalculator {
73
73
  fs.readFile(packageJsonPath, { encoding: 'utf8' }, (err, contents) => {
74
74
  if (err) {
75
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
76
+ `Failed to calculate transitive distances for some dependencies, could not read package.json file at
77
+ ${packageJsonPath}: ${err?.message}.`
80
78
  );
81
79
 
82
80
  // If we cannot parse the package.json or if it does not exist, we need to decrement by 3 immediately because
@@ -90,10 +88,8 @@ class DependencyDistanceCalculator {
90
88
  parsedPackageJson = JSON.parse(contents);
91
89
  } catch (parseErr) {
92
90
  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
91
+ `Failed to calculate transitive distances for some dependencies, could not parse package.json file at
92
+ ${packageJsonPath}: ${parseErr?.message}.`
97
93
  );
98
94
  this.globalCountDownLatchAllPackages.countDown(3);
99
95
  return;
@@ -109,9 +105,8 @@ class DependencyDistanceCalculator {
109
105
  // This catch-block is for synchronous errors from fs.readFile, which can also happen in addition to the callback
110
106
  // being called with an error.
111
107
  logger.debug(
112
- 'Failed to calculate transitive distances for some dependencies, synchronous error from fs.readFile for %s:',
113
- packageJsonPath,
114
- fsReadFileErr
108
+ `Failed to calculate transitive distances for some dependencies, synchronous error from fs.readFile for
109
+ ${packageJsonPath}: ${fsReadFileErr?.message}`
115
110
  );
116
111
  this.globalCountDownLatchAllPackages.countDown(3);
117
112
  }
@@ -197,8 +192,7 @@ class DependencyDistanceCalculator {
197
192
  localCountDownLatchForThisNode.countDown();
198
193
  logger.debug(
199
194
  `Ignoring failure to find the package.json file for dependency ${dependency} for dependency distance ` +
200
- 'calculation.',
201
- err
195
+ `calculation. ${err?.message} ${err?.stack}`
202
196
  );
203
197
  return;
204
198
  }
@@ -115,7 +115,9 @@ function attemptRequire(opts, loaderEmitter, mechanism) {
115
115
  logger.debug(`Attempt to load native add-on ${opts.nativeModuleName} ${mechanism} has been successful.`);
116
116
  return true;
117
117
  } catch (e) {
118
- logger.debug(`Attempt to load native add-on ${opts.nativeModuleName} ${mechanism} has failed.`, e);
118
+ logger.debug(
119
+ `Attempt to load native add-on ${opts.nativeModuleName} ${mechanism} has failed. ${e?.message} ${e?.stack}`
120
+ );
119
121
  return false;
120
122
  }
121
123
  }
@@ -167,7 +169,10 @@ function copyPrecompiled(opts, loaderEmitter, callback) {
167
169
  callback(false);
168
170
  return;
169
171
  } else if (statsErr) {
170
- logger.warn(`Looking for a precompiled version for ${opts.nativeModuleName} ${label} failed.`, statsErr);
172
+ logger.warn(
173
+ `Looking for a precompiled version for ${opts.nativeModuleName} ${label} failed.
174
+ ${statsErr?.message} ${statsErr?.stack}`
175
+ );
171
176
  callback(false);
172
177
  return;
173
178
  }
@@ -206,12 +211,16 @@ function copyPrecompiled(opts, loaderEmitter, callback) {
206
211
  callback(true);
207
212
  })
208
213
  .catch(error => {
209
- logger.warn(`Copying the precompiled build for ${opts.nativeModuleName} ${label} failed.`, error);
214
+ logger.warn(
215
+ `Copying the precompiled build for ${opts.nativeModuleName} ${label} failed.
216
+ ${error?.message} ${error?.stack}`
217
+ );
210
218
  callback(false);
211
219
  });
212
220
  })
213
221
  .catch(tarErr => {
214
- logger.warn(`Unpacking the precompiled build for ${opts.nativeModuleName} ${label} failed.`, tarErr);
222
+ logger.warn(`Unpacking the precompiled build for ${opts.nativeModuleName} ${label} failed.
223
+ ${tarErr?.message} ${tarErr?.stack}`);
215
224
  callback(false);
216
225
  });
217
226
  });
@@ -245,7 +254,9 @@ function findNativeModulePath(opts) {
245
254
  opts.nativeModuleParentPath = path.join(opts.nativeModulePath, '..');
246
255
  return true;
247
256
  } catch (e) {
248
- logger.debug(`Could not find location for ${opts.nativeModuleName}. Will create a path for it.`, e);
257
+ logger.debug(
258
+ `Could not find location for ${opts.nativeModuleName}. Will create a path for it. ${e?.message} ${e?.stack}`
259
+ );
249
260
  return createNativeModulePath(opts);
250
261
  }
251
262
  }
package/src/version.js CHANGED
@@ -30,7 +30,7 @@ exports.activate = function activate(config) {
30
30
  attempts++;
31
31
  applicationUnderMonitoring.getMainPackageJsonStartingAtMainModule(config, (err, packageJson) => {
32
32
  if (err) {
33
- return logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack);
33
+ return logger.warn(`Failed to determine main package json. Reason: ${err?.message} ${err?.stack}`);
34
34
  } else if (!packageJson && attempts < MAX_ATTEMPTS) {
35
35
  setTimeout(() => {
36
36
  exports.activate(config);