newrelic 11.3.0 → 11.5.0

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,28 @@
1
+ ### v11.5.0 (2023-10-30)
2
+
3
+ #### Miscellaneous chores
4
+
5
+ * **dep:** Updated @newrelic/security-agent to v0.4.0 ([#1837](https://github.com/newrelic/node-newrelic/pull/1837)) ([fb06ac9](https://github.com/newrelic/node-newrelic/commit/fb06ac930269b784fcea6c2b8ea5e54158677ec4))
6
+
7
+ #### Continuous integration
8
+
9
+ * Disable fail-fast on nightly versioned test runs ([#1836](https://github.com/newrelic/node-newrelic/pull/1836)) ([fe1b4fc](https://github.com/newrelic/node-newrelic/commit/fe1b4fc4c00b2e4ea4c7b6fa5a8c1cd6e864145a))
10
+
11
+ ### v11.4.0 (2023-10-25)
12
+
13
+ #### Features
14
+
15
+ * Added support for parsing container ids from docker versions using cgroups v2. ([#1830](https://github.com/newrelic/node-newrelic/pull/1830)) ([9892901](https://github.com/newrelic/node-newrelic/commit/98929013da3e62e2223f94531b8d6f59eecfc35b))
16
+
17
+ #### Miscellaneous chores
18
+
19
+ * [Snyk] Upgraded @grpc/grpc-js from 1.9.2 to 1.9.4. ([#1823](https://github.com/newrelic/node-newrelic/pull/1823)) ([81f9450](https://github.com/newrelic/node-newrelic/commit/81f945033376e4d33651d1e42afc30aea19dbdeb))
20
+ * **deps:** Updated aws-sdk, koa, superagent ([#1831](https://github.com/newrelic/node-newrelic/pull/1831)) ([8b4e963](https://github.com/newrelic/node-newrelic/commit/8b4e963e84d34e4727b9fda3aa630ef119aa3905))
21
+
22
+ #### Tests
23
+
24
+ * Increased timeout for integration tests to avoid random failures. ([#1827](https://github.com/newrelic/node-newrelic/pull/1827)) ([5202048](https://github.com/newrelic/node-newrelic/commit/52020485191868f479092ae4860019acf105b3eb))
25
+
1
26
  ### v11.3.0 (2023-10-23)
2
27
 
3
28
  #### Features
@@ -92,7 +92,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
92
92
 
93
93
  ### @grpc/grpc-js
94
94
 
95
- This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.9.2](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.9.2)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.9.2/LICENSE):
95
+ This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.9.4](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.9.4)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.9.4/LICENSE):
96
96
 
97
97
  ```
98
98
  Apache License
@@ -510,7 +510,7 @@ This product includes source derived from [@grpc/proto-loader](https://github.co
510
510
 
511
511
  ### @newrelic/aws-sdk
512
512
 
513
- This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v7.0.0](https://github.com/newrelic/node-newrelic-aws-sdk/tree/v7.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-aws-sdk/blob/v7.0.0/LICENSE):
513
+ This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v7.0.2](https://github.com/newrelic/node-newrelic-aws-sdk/tree/v7.0.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-aws-sdk/blob/v7.0.2/LICENSE):
514
514
 
515
515
  ```
516
516
  Apache License
@@ -718,7 +718,7 @@ This product includes source derived from [@newrelic/aws-sdk](https://github.com
718
718
 
719
719
  ### @newrelic/koa
720
720
 
721
- This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v8.0.0](https://github.com/newrelic/node-newrelic-koa/tree/v8.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v8.0.0/LICENSE):
721
+ This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v8.0.1](https://github.com/newrelic/node-newrelic-koa/tree/v8.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v8.0.1/LICENSE):
722
722
 
723
723
  ```
724
724
  Apache License
@@ -927,7 +927,7 @@ Apache License
927
927
 
928
928
  ### @newrelic/security-agent
929
929
 
930
- This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v0.3.0](https://github.com/newrelic/csec-node-agent/tree/v0.3.0)), distributed under the [New Relic Pre-Release License](https://github.com/newrelic/csec-node-agent/blob/v0.3.0/LICENSE):
930
+ This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v0.4.0](https://github.com/newrelic/csec-node-agent/tree/v0.4.0)), distributed under the [New Relic Pre-Release License](https://github.com/newrelic/csec-node-agent/blob/v0.4.0/LICENSE):
931
931
 
932
932
  ```
933
933
  ## New Relic Pre-Release Software Notice
@@ -978,7 +978,7 @@ This license terminates when the Pre-Release Software stops being provided by Ne
978
978
 
979
979
  ### @newrelic/superagent
980
980
 
981
- This product includes source derived from [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent) ([v7.0.0](https://github.com/newrelic/node-newrelic-superagent/tree/v7.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-superagent/blob/v7.0.0/LICENSE):
981
+ This product includes source derived from [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent) ([v7.0.1](https://github.com/newrelic/node-newrelic-superagent/tree/v7.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-superagent/blob/v7.0.1/LICENSE):
982
982
 
983
983
  ```
984
984
  Apache License
@@ -10,6 +10,8 @@ const common = require('./common')
10
10
  const NAMES = require('../metrics/names')
11
11
  const os = require('os')
12
12
  let vendorInfo = null
13
+ const CGROUPS_V1_PATH = '/proc/self/cgroup'
14
+ const CGROUPS_V2_PATH = '/proc/self/mountinfo'
13
15
 
14
16
  module.exports.getVendorInfo = fetchDockerVendorInfo
15
17
  module.exports.clearVendorCache = function clearDockerVendorCache() {
@@ -51,6 +53,12 @@ module.exports.getBootId = function getBootId(agent, callback) {
51
53
  }
52
54
  }
53
55
 
56
+ /**
57
+ * Attempt to extract container id from either cgroups v1 or v2 file
58
+ *
59
+ * @param {object} agent NR instance
60
+ * @param {Function} callback function to call when done
61
+ */
54
62
  function fetchDockerVendorInfo(agent, callback) {
55
63
  if (!agent.config.utilization || !agent.config.utilization.detect_docker) {
56
64
  return callback(null, null)
@@ -62,16 +70,56 @@ function fetchDockerVendorInfo(agent, callback) {
62
70
 
63
71
  if (!os.platform().match(/linux/i)) {
64
72
  logger.debug('Platform is not a flavor of linux, omitting docker info')
65
- return callback(null)
73
+ return callback(null, null)
66
74
  }
67
75
 
68
- common.readProc('/proc/self/cgroup', function getCGroup(err, data) {
76
+ // try v2 path first and if null try parsing v1 path
77
+ common.readProc(CGROUPS_V2_PATH, function getV2CGroup(err, data) {
78
+ if (data === null) {
79
+ logger.debug(
80
+ `${CGROUPS_V2_PATH} not found, trying to parse container id from ${CGROUPS_V1_PATH}`
81
+ )
82
+ findCGroupsV1(callback)
83
+ return
84
+ }
85
+
86
+ parseCGroupsV2(data, callback)
87
+ })
88
+ }
89
+
90
+ /**
91
+ * Try extracting container id from a /proc/self/mountinfo
92
+ * e.g. - `528 519 254:1 /docker/containers/84cf3472a20d1bfb4b50e48b6ff50d96dfcd812652d76dd907951e6f98997bce/resolv.conf`
93
+ *
94
+ * @param {string} data file contents
95
+ * @param {Function} callback function to call when done
96
+ */
97
+ function parseCGroupsV2(data, callback) {
98
+ const containerLine = new RegExp('/docker/containers/([0-9a-f]{64})/')
99
+ const line = containerLine.exec(data)
100
+ if (line) {
101
+ callback(null, { id: line[1] })
102
+ } else {
103
+ logger.debug(`Found ${CGROUPS_V2_PATH} but failed to parse Docker container id.`)
104
+ callback(null, null)
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Read /proc/self/cgroup and try to extract the container id from a cpu line
110
+ * e.g. - `4:cpu:/docker/f37a7e4d17017e7bf774656b19ca4360c6cdc4951c86700a464101d0d9ce97ee`
111
+ *
112
+ * @param {Function} callback function to call when done
113
+ */
114
+ function findCGroupsV1(callback) {
115
+ common.readProc(CGROUPS_V1_PATH, function getCGroup(err, data) {
69
116
  if (!data) {
117
+ logger.debug(`${CGROUPS_V1_PATH} not found, exiting parsing containerId.`)
70
118
  return callback(null)
71
119
  }
72
120
 
73
121
  let id = null
74
- findCGroups(data, 'cpu', function forEachCpuGroup(cpuGroup) {
122
+ parseCGroupsV1(data, 'cpu', function forEachCpuGroup(cpuGroup) {
75
123
  const match = /(?:^|[^0-9a-f])([0-9a-f]{64})(?:[^0-9a-f]|$)/.exec(cpuGroup)
76
124
  if (match) {
77
125
  id = match[1]
@@ -91,7 +139,14 @@ function fetchDockerVendorInfo(agent, callback) {
91
139
  })
92
140
  }
93
141
 
94
- function findCGroups(info, cgroup, eachCb) {
142
+ /**
143
+ * Iterate line by line to extract the container id from the cpu stanza
144
+ *
145
+ * @param {string} info contents of file
146
+ * @param {string} cgroup value is cpu
147
+ * @param {Function} eachCb funtion to test if the container id exists
148
+ */
149
+ function parseCGroupsV1(info, cgroup, eachCb) {
95
150
  const target = new RegExp('^\\d+:[^:]*?\\b' + cgroup + '\\b[^:]*:')
96
151
  const lines = info.split('\n')
97
152
  for (let i = 0; i < lines.length; ++i) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "11.3.0",
3
+ "version": "11.5.0",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -146,7 +146,7 @@
146
146
  "bench": "node ./bin/run-bench.js",
147
147
  "docker-env": "./bin/docker-env-vars.sh",
148
148
  "docs": "npm ci && jsdoc -c ./jsdoc-conf.json --private -r .",
149
- "integration": "npm run prepare-test && npm run sub-install && time c8 -o ./coverage/integration tap --test-regex='(\\/|^test\\/integration\\/.*\\.tap\\.js)$' --timeout=300 --no-coverage --reporter classic",
149
+ "integration": "npm run prepare-test && npm run sub-install && time c8 -o ./coverage/integration tap --test-regex='(\\/|^test\\/integration\\/.*\\.tap\\.js)$' --timeout=600 --no-coverage --reporter classic",
150
150
  "prepare-test": "npm run ssl && npm run docker-env",
151
151
  "lint": "eslint ./*.{js,mjs} lib test bin examples",
152
152
  "lint:fix": "eslint --fix, ./*.{js,mjs} lib test bin examples",
@@ -181,12 +181,12 @@
181
181
  "newrelic-naming-rules": "./bin/test-naming-rules.js"
182
182
  },
183
183
  "dependencies": {
184
- "@grpc/grpc-js": "^1.8.10",
184
+ "@grpc/grpc-js": "^1.9.4",
185
185
  "@grpc/proto-loader": "^0.7.5",
186
- "@newrelic/aws-sdk": "^7.0.0",
187
- "@newrelic/koa": "^8.0.0",
188
- "@newrelic/security-agent": "0.3.0",
189
- "@newrelic/superagent": "^7.0.0",
186
+ "@newrelic/aws-sdk": "^7.0.2",
187
+ "@newrelic/koa": "^8.0.1",
188
+ "@newrelic/security-agent": "0.4.0",
189
+ "@newrelic/superagent": "^7.0.1",
190
190
  "@tyriar/fibonacci-heap": "^2.0.7",
191
191
  "concat-stream": "^2.0.0",
192
192
  "https-proxy-agent": "^7.0.1",