newrelic 9.7.3 → 9.7.5

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/NEWS.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### v9.7.5 (2023-01-03)
2
+
3
+ * Added a check to the code level metrics utility to ensure filePath was set before adding the `code.*` attributes.
4
+
5
+ * Updated to latest version of `@newrelic/test-utilities`
6
+
7
+ * Fixed issue where listing of dependencies and packages from symlinked nested directories created an infinite loop which caused the agent to never connect.
8
+
9
+ ### v9.7.4 (2022-12-15)
10
+
11
+ * Fixed system info gathering to prevent unhandled promise rejection when an error occurs reading `/proc` information.
12
+
1
13
  ### v9.7.3 (2022-12-12)
2
14
 
3
15
  * Added support for Code Level Metrics on API methods: `startSegment`, `startBackgroundTransaction`, and `startWebTransaction`.
@@ -1771,7 +1771,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1771
1771
 
1772
1772
  ### @newrelic/test-utilities
1773
1773
 
1774
- This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v7.1.1](https://github.com/newrelic/node-test-utilities/tree/v7.1.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v7.1.1/LICENSE):
1774
+ This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v7.2.0](https://github.com/newrelic/node-test-utilities/tree/v7.2.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v7.2.0/LICENSE):
1775
1775
 
1776
1776
  ```
1777
1777
  Apache License
@@ -139,7 +139,9 @@ async function listDependencies(root, children = [], visited = Object.create(nul
139
139
  // Make sure we haven't been to this directory before.
140
140
  if (visited[realCandidate]) {
141
141
  logger.trace('Not revisiting %s (from %s)', realCandidate, candidate)
142
+ return
142
143
  }
144
+
143
145
  visited[realCandidate] = true
144
146
 
145
147
  // Load the packages and dependencies for this directory.
@@ -214,7 +214,7 @@ module.exports._getProcessorStats = async function getProcessorStats() {
214
214
 
215
215
  return processorStats
216
216
  } else if (platform.match(/linux/i)) {
217
- const data = await readProc('/proc/cpuinfo')
217
+ const data = await getProcInfo('/proc/cpuinfo')
218
218
 
219
219
  return parseCpuInfo(data)
220
220
  }
@@ -237,7 +237,7 @@ module.exports._getMemoryStats = async function getMemoryStats() {
237
237
  const memory = await getSysctlValue(['hw.realmem'])
238
238
  return parseInt(memory, 10) / (1024 * 1024)
239
239
  } else if (platform.match(/linux/i)) {
240
- const data = await readProc('/proc/meminfo')
240
+ const data = await getProcInfo('/proc/meminfo')
241
241
  return parseMemInfo(data)
242
242
  }
243
243
 
@@ -254,7 +254,7 @@ async function getKernelVersion() {
254
254
  if (platform.match(/darwin/i) || platform.match(/bsd/i)) {
255
255
  return await getSysctlValue(['kern.version'])
256
256
  } else if (platform.match(/linux/i)) {
257
- return await readProc('/proc/version')
257
+ return await getProcInfo('/proc/version')
258
258
  }
259
259
 
260
260
  logger.debug('Unknown platform: %s; could not read kernel version', platform)
@@ -294,3 +294,18 @@ async function getSysctlValue(names = []) {
294
294
 
295
295
  return returnValue
296
296
  }
297
+
298
+ /**
299
+ * Helper method for getting /proc/* file information in Linux environments
300
+ *
301
+ * @param {string} procPath - the proc file to read
302
+ * @returns {*} null if the lookup fails, otherwise the proc file information
303
+ */
304
+ async function getProcInfo(procPath) {
305
+ try {
306
+ return await readProc(procPath)
307
+ } catch (err) {
308
+ // swallow the error if reading fails, logging handled in readProc()
309
+ return null
310
+ }
311
+ }
@@ -56,7 +56,7 @@ clmUtils.addCLMAttributes = function addCLMAttributes(fn, segment) {
56
56
  const { lineNumber, method, file: filePath, column } = funcInfo(fn)
57
57
  const fnName = setFunctionName(method)
58
58
 
59
- if (isValidLength(fnName, 255) && isValidLength(filePath, 255)) {
59
+ if (isValidLength(fnName, 255) && filePath && isValidLength(filePath, 255)) {
60
60
  segment.addAttribute('code.filepath', filePath)
61
61
  segment.addAttribute('code.function', fnName)
62
62
  // both line numbers and columns start at 0 in v8, add 1 to reflect js code
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "9.7.3",
3
+ "version": "9.7.5",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -200,7 +200,7 @@
200
200
  "@newrelic/eslint-config": "^0.2.0",
201
201
  "@newrelic/newrelic-oss-cli": "^0.1.2",
202
202
  "@newrelic/proxy": "^2.0.0",
203
- "@newrelic/test-utilities": "^7.1.1",
203
+ "@newrelic/test-utilities": "^7.2.0",
204
204
  "@octokit/rest": "^18.0.15",
205
205
  "@slack/bolt": "^3.7.0",
206
206
  "ajv": "^6.12.6",