newrelic 11.2.0 → 11.3.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 +76 -44
- package/index.js +24 -19
- package/lib/config/default.js +20 -0
- package/lib/config/merge-server-config.js +3 -5
- package/lib/instrumentation/@elastic/elasticsearch.js +14 -4
- package/lib/util/objects.js +27 -0
- package/package.json +1 -1
package/NEWS.md
CHANGED
|
@@ -1,47 +1,78 @@
|
|
|
1
|
-
### v11.
|
|
2
|
-
|
|
3
|
-
#### Features
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
#### Bug
|
|
8
|
-
|
|
9
|
-
* Updated
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
### v11.3.0 (2023-10-23)
|
|
2
|
+
|
|
3
|
+
#### Features
|
|
4
|
+
|
|
5
|
+
* Updated agent initialization to allow running in worker threads when config.worker_threads.enabled is true ([#1817](https://github.com/newrelic/node-newrelic/pull/1817)) ([a39f0ef](https://github.com/newrelic/node-newrelic/commit/a39f0ef5ac670d03ab407b24e5aeccd8d5e8c680))
|
|
6
|
+
|
|
7
|
+
#### Bug fixes
|
|
8
|
+
|
|
9
|
+
* Updated Elasticsearch instrumentation to register on v7.13.0+ only ([#1816](https://github.com/newrelic/node-newrelic/pull/1816)) ([6437671](https://github.com/newrelic/node-newrelic/commit/6437671b921cd6bd73ed31180b0d62f62cc229a2))
|
|
10
|
+
|
|
11
|
+
#### Miscellaneous chores
|
|
12
|
+
|
|
13
|
+
* **dev-deps:** Bumped @babel/traverse ([#1818](https://github.com/newrelic/node-newrelic/pull/1818)) ([d3c8d04](https://github.com/newrelic/node-newrelic/commit/d3c8d04b74b7a84846609b744e3b4922136dbdd6))
|
|
14
|
+
* Updated release note headers to follow standard sentence caps ([#1806](https://github.com/newrelic/node-newrelic/pull/1806)) ([91d3600](https://github.com/newrelic/node-newrelic/commit/91d36009e0496af823cfbc3a4bdb2b32a97ba8c5))
|
|
15
|
+
|
|
16
|
+
#### Tests
|
|
17
|
+
|
|
18
|
+
* Updated the grpc versioned tests utils to dynamically bind ports to avoid conflicts between cjs and esm tests ([#1820](https://github.com/newrelic/node-newrelic/pull/1820)) ([95ac917](https://github.com/newrelic/node-newrelic/commit/95ac917da92575e178d8026bdc0badb08ba6fb83))
|
|
19
|
+
|
|
20
|
+
#### Continuous integration
|
|
21
|
+
|
|
22
|
+
* Disabled fail-fast on testing jobs to make sure all versions are run before getting canceled because of a flappy test ([#1819](https://github.com/newrelic/node-newrelic/pull/1819)) ([0928ee3](https://github.com/newrelic/node-newrelic/commit/0928ee3db82533e2386ad2bf4b87074b4f15f33b))
|
|
23
|
+
* Updated CI workflow to use larger runners on versioned tests but only when running against the main branch ([#1812](https://github.com/newrelic/node-newrelic/pull/1812)) ([01eaa14](https://github.com/newrelic/node-newrelic/commit/01eaa14c76a32966f6af8475e6ba6d4e00b03513))
|
|
24
|
+
* Updated post release script to update the nodejs_agent_version only on staging and us prod, eu will get it via replication now ([#1811](https://github.com/newrelic/node-newrelic/pull/1811)) ([317a00a](https://github.com/newrelic/node-newrelic/commit/317a00a9c160b52b053cb1f9f55292551c4c3428))
|
|
25
|
+
|
|
26
|
+
### v11.2.1 (2023-10-12)
|
|
27
|
+
|
|
28
|
+
#### Bug fixes
|
|
29
|
+
|
|
30
|
+
* Updated initialization to return the api on start up to the security agent properly ([#1807](https://github.com/newrelic/node-newrelic/pull/1807)) ([99e5792](https://github.com/newrelic/node-newrelic/commit/99e5792024263a61751b73976ed707ed51815388))
|
|
31
|
+
|
|
32
|
+
### v11.2.0 (2023-10-11)
|
|
33
|
+
|
|
34
|
+
#### Features
|
|
35
|
+
|
|
36
|
+
* Added instrumentation for ElasticSearch ([#1785](https://github.com/newrelic/node-newrelic/pull/1785)) ([a748b84](https://github.com/newrelic/node-newrelic/commit/a748b84c6a706ed0cea2e07c9fae8807a82dbc95))
|
|
37
|
+
|
|
38
|
+
#### Bug Fixes
|
|
39
|
+
|
|
40
|
+
* Updated agent to create a stub api when running in a worker thread to avoid Next.js early return errors ([#1800](https://github.com/newrelic/node-newrelic/pull/1800)) ([636e8f0](https://github.com/newrelic/node-newrelic/commit/636e8f068a2ec2f989e28f6646f844b951ee636d))
|
|
41
|
+
* Updated shimmer to allow registering instrumentation for different versions of the same module ([#1799](https://github.com/newrelic/node-newrelic/pull/1799)) ([30f0b16](https://github.com/newrelic/node-newrelic/commit/30f0b16e13e9621c86481c5d5409a799dbbb8d57))
|
|
42
|
+
|
|
43
|
+
#### Miscellaneous Chores
|
|
44
|
+
|
|
45
|
+
* **deps:** Updated @newrelic/security-agent to v0.3.0 ([#1786](https://github.com/newrelic/node-newrelic/pull/1786)) ([9ca78ae](https://github.com/newrelic/node-newrelic/commit/9ca78aede72ddecd3eb8271d349ad35cc4ce05f9))
|
|
46
|
+
* Separated running versioned tests between local and external ([#1792](https://github.com/newrelic/node-newrelic/pull/1792)) ([6ffe2f6](https://github.com/newrelic/node-newrelic/commit/6ffe2f6e16c769c3fb8de767e9336992b1cca797))
|
|
47
|
+
* **dev-deps** Updated get-func-name to fix CVE ([#1790](https://github.com/newrelic/node-newrelic/pull/1790)) ([f378c77](https://github.com/newrelic/node-newrelic/commit/f378c77eb09fcd3453850a1d177faea41422f637))
|
|
48
|
+
|
|
49
|
+
#### Tests
|
|
50
|
+
|
|
51
|
+
* Updated elasticsearch container to ignore highwatermark to function on a constrained environment ([#1803](https://github.com/newrelic/node-newrelic/pull/1803)) ([8380e9d](https://github.com/newrelic/node-newrelic/commit/8380e9d527f3ffc61d1f3e32199e81ed25837185))
|
|
52
|
+
* Updated invalid json pino test as this was fixed in 8.15.1 of the pino library. ([#1782](https://github.com/newrelic/node-newrelic/pull/1782)) ([3e65fdc](https://github.com/newrelic/node-newrelic/commit/3e65fdcc68999e09d9ef3c341ff7c1159b65ab37))
|
|
53
|
+
|
|
54
|
+
#### Continuous Integration
|
|
55
|
+
|
|
56
|
+
* Added steps to zip up container logs on versioned test failure ([#1804](https://github.com/newrelic/node-newrelic/pull/1804)) ([0a54729](https://github.com/newrelic/node-newrelic/commit/0a54729f1d8187bb50508659716ec55349e9ee31))
|
|
57
|
+
|
|
58
|
+
### v11.1.0 (2023-09-07)
|
|
59
|
+
|
|
60
|
+
#### Features
|
|
61
|
+
|
|
62
|
+
* Added instrumentation for fetch. ([#1776](https://github.com/newrelic/node-newrelic/pull/1776)) ([980b4dc](https://github.com/newrelic/node-newrelic/commit/980b4dc31d085cafc45961a157f76cb73768741a))
|
|
63
|
+
* Removed undici feature flag. This will now instrument undici by default. ([#1772](https://github.com/newrelic/node-newrelic/pull/1772)) ([683b254](https://github.com/newrelic/node-newrelic/commit/683b254c1c4686527a37e628f80eed9fcc03cb37))
|
|
64
|
+
* Updated undici instrumentation to create segment on request create instead of after connection and opening socket to more accurately record time it takes to make an undici request. ([#1770](https://github.com/newrelic/node-newrelic/pull/1770)) ([3f494f8](https://github.com/newrelic/node-newrelic/commit/3f494f8ad8dd1350fbe034e9c4a582a40228bc45))
|
|
65
|
+
|
|
66
|
+
#### Performance Improvements
|
|
67
|
+
|
|
68
|
+
* **Trace:** optimise getTotalTimeDurationInMillis function to push to an array instead of concat arrays. ([#1774](https://github.com/newrelic/node-newrelic/pull/1774)) ([6ecde97](https://github.com/newrelic/node-newrelic/commit/6ecde97a5efeef4d816b2e82ba762f2130914658))
|
|
69
|
+
* Thanks @infinity-naveen for your contribution 🎉
|
|
70
|
+
|
|
71
|
+
#### Miscellaneous Chores
|
|
72
|
+
|
|
73
|
+
* Updated Next.js plugin versioned tests to use main now that require-in-the-middle fixes have been merged. ([#1768](https://github.com/newrelic/node-newrelic/pull/1768)) ([6a72d1f](https://github.com/newrelic/node-newrelic/commit/6a72d1fb452ea2655c35d7cd008fa78935821ab8))
|
|
74
|
+
* Upgraded `@newrelic/test-utilities` and removed unused shimmer.patchModule and shimmer.unpatchModule ([#1769](https://github.com/newrelic/node-newrelic/pull/1769)) ([96620ef](https://github.com/newrelic/node-newrelic/commit/96620efa725f0f548b683825cb3cefff270fb252))
|
|
75
|
+
|
|
45
76
|
### v11.0.0 (2023-08-28)
|
|
46
77
|
|
|
47
78
|
#### ⚠ BREAKING CHANGES
|
|
@@ -53,6 +84,7 @@
|
|
|
53
84
|
* Updated agent to use require-in-the-middle to register CommonJS instrumentation. You can no longer use an onResolved hook to register custom instrumentation.
|
|
54
85
|
* Updated the default context manager to be AsyncLocalContextManager.
|
|
55
86
|
* Renamed `shim.handleCATHeaders` to `shim.handleMqTracingHeaders`.
|
|
87
|
+
* Updated agent to only run in the main thread. This is because running in a worker thread does not completely function out of the box. This will reduce the overhead for customers that are naively trying to load this into worker threads.
|
|
56
88
|
|
|
57
89
|
#### Features
|
|
58
90
|
|
package/index.js
CHANGED
|
@@ -20,28 +20,23 @@ const NAMES = require('./lib/metrics/names')
|
|
|
20
20
|
const isESMSupported = psemver.satisfies('>=16.2.0')
|
|
21
21
|
|
|
22
22
|
const pkgJSON = require('./package.json')
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
logger.info(
|
|
24
|
+
'Using New Relic for Node.js. Agent version: %s; Node version: %s.',
|
|
25
|
+
pkgJSON.version,
|
|
26
|
+
process.version
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
if (require.cache.__NR_cache) {
|
|
30
|
+
logger.warn(
|
|
31
|
+
'Attempting to load a second copy of newrelic from %s, using cache instead',
|
|
32
|
+
__dirname
|
|
28
33
|
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
logger.warn(
|
|
32
|
-
'Attempting to load a second copy of newrelic from %s, using cache instead',
|
|
33
|
-
__dirname
|
|
34
|
-
)
|
|
35
|
-
if (require.cache.__NR_cache.agent) {
|
|
36
|
-
require.cache.__NR_cache.agent.recordSupportability('Agent/DoubleLoad')
|
|
37
|
-
}
|
|
38
|
-
module.exports = require.cache.__NR_cache
|
|
39
|
-
} else {
|
|
40
|
-
initialize()
|
|
34
|
+
if (require.cache.__NR_cache.agent) {
|
|
35
|
+
require.cache.__NR_cache.agent.recordSupportability('Agent/DoubleLoad')
|
|
41
36
|
}
|
|
37
|
+
module.exports = require.cache.__NR_cache
|
|
42
38
|
} else {
|
|
43
|
-
|
|
44
|
-
initApi({ apiPath: './stub_api' })
|
|
39
|
+
initialize()
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
function initApi({ agent, apiPath }) {
|
|
@@ -49,6 +44,7 @@ function initApi({ agent, apiPath }) {
|
|
|
49
44
|
|
|
50
45
|
const api = new API(agent)
|
|
51
46
|
require.cache.__NR_cache = module.exports = api
|
|
47
|
+
return api
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
function initialize() {
|
|
@@ -96,7 +92,16 @@ function initialize() {
|
|
|
96
92
|
logger.info('No configuration detected. Not starting.')
|
|
97
93
|
} else if (!config.agent_enabled) {
|
|
98
94
|
logger.info('Module disabled in configuration. Not starting.')
|
|
95
|
+
} else if (!config.worker_threads.enabled && !isMainThread) {
|
|
96
|
+
logger.warn(
|
|
97
|
+
'New Relic for Node.js in worker_threads is not officially supported. Not starting! To bypass this, set `config.worker_threads.enabled` to true in configuration.'
|
|
98
|
+
)
|
|
99
99
|
} else {
|
|
100
|
+
if (!isMainThread && config.worker_threads.enabled) {
|
|
101
|
+
logger.warn(
|
|
102
|
+
'Attempting to load agent in worker thread. This is not officially supported. Use at your own risk.'
|
|
103
|
+
)
|
|
104
|
+
}
|
|
100
105
|
agent = createAgent(config)
|
|
101
106
|
addStartupSupportabilities(agent)
|
|
102
107
|
}
|
package/lib/config/default.js
CHANGED
|
@@ -1320,11 +1320,31 @@ defaultConfig.definition = () => ({
|
|
|
1320
1320
|
}
|
|
1321
1321
|
},
|
|
1322
1322
|
|
|
1323
|
+
/**
|
|
1324
|
+
* When enabled, it will use `process.env.DYNO`
|
|
1325
|
+
* to set the hostname of the running application
|
|
1326
|
+
*/
|
|
1323
1327
|
heroku: {
|
|
1324
1328
|
use_dyno_names: {
|
|
1325
1329
|
default: true,
|
|
1326
1330
|
formatter: boolean
|
|
1327
1331
|
}
|
|
1332
|
+
},
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* When enabled, it will allow loading of the agent
|
|
1336
|
+
* in worker threads.
|
|
1337
|
+
*
|
|
1338
|
+
* In 11.0.0 we added code to prevent loading in worker threads
|
|
1339
|
+
* to cut down on unnecessary overhead of the agent. We have found
|
|
1340
|
+
* in testing that traces and spans were useless unless work was
|
|
1341
|
+
* completely self contained in the worker thread.
|
|
1342
|
+
*/
|
|
1343
|
+
worker_threads: {
|
|
1344
|
+
enabled: {
|
|
1345
|
+
formatter: boolean,
|
|
1346
|
+
default: false
|
|
1347
|
+
}
|
|
1328
1348
|
}
|
|
1329
1349
|
})
|
|
1330
1350
|
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
const { isSimpleObject } = require('../util/objects')
|
|
9
|
+
|
|
8
10
|
class MergeServerConfig {
|
|
9
11
|
// eslint-disable-next-line max-params
|
|
10
12
|
updateNestedIfChanged(config, remote, local, remoteKey, localKey, logger) {
|
|
@@ -21,7 +23,7 @@ class MergeServerConfig {
|
|
|
21
23
|
// value is an array, a simple object, or anything else
|
|
22
24
|
if (Array.isArray(value) && Array.isArray(local[localKey])) {
|
|
23
25
|
this.updateArray(value, local, localKey)
|
|
24
|
-
} else if (
|
|
26
|
+
} else if (isSimpleObject(value) && isSimpleObject(local[localKey])) {
|
|
25
27
|
this.updateObject(value, local, localKey)
|
|
26
28
|
} else {
|
|
27
29
|
local[localKey] = value
|
|
@@ -54,10 +56,6 @@ class MergeServerConfig {
|
|
|
54
56
|
}
|
|
55
57
|
})
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
isSimpleObject(thing) {
|
|
59
|
-
return 'object' === typeof thing && thing !== null
|
|
60
|
-
}
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
module.exports = MergeServerConfig
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
|
+
const semver = require('semver')
|
|
7
8
|
const logger = require('../../logger').child({ component: 'ElasticSearch' })
|
|
9
|
+
const { isNotEmpty } = require('../../util/objects')
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Instruments the `@elastic/elasticsearch` module. This function is
|
|
@@ -17,6 +19,15 @@ const logger = require('../../logger').child({ component: 'ElasticSearch' })
|
|
|
17
19
|
* @returns {void}
|
|
18
20
|
*/
|
|
19
21
|
module.exports = function initialize(_agent, elastic, _moduleName, shim) {
|
|
22
|
+
const pkgVersion = shim.require('./package.json').version
|
|
23
|
+
if (semver.lt(pkgVersion, '7.13.0')) {
|
|
24
|
+
shim &&
|
|
25
|
+
shim.logger.debug(
|
|
26
|
+
`ElasticSearch support is for versions 7.13.0 and above. Not instrumenting ${pkgVersion}.`
|
|
27
|
+
)
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
shim.setDatastore(shim.ELASTICSEARCH)
|
|
21
32
|
shim.setParser(queryParser)
|
|
22
33
|
|
|
@@ -46,18 +57,17 @@ module.exports = function initialize(_agent, elastic, _moduleName, shim) {
|
|
|
46
57
|
*/
|
|
47
58
|
function queryParser(params) {
|
|
48
59
|
params = JSON.parse(params)
|
|
49
|
-
|
|
50
60
|
const { collection, operation } = parsePath(params.path, params.method)
|
|
51
61
|
|
|
52
62
|
// the substance of the query may be in querystring or in body.
|
|
53
63
|
let queryParam = {}
|
|
54
|
-
if (
|
|
64
|
+
if (isNotEmpty(params.querystring)) {
|
|
55
65
|
queryParam = params.querystring
|
|
56
66
|
}
|
|
57
67
|
// let body or bulkBody override querystring, as some requests have both
|
|
58
|
-
if (
|
|
68
|
+
if (isNotEmpty(params.body)) {
|
|
59
69
|
queryParam = params.body
|
|
60
|
-
} else if (
|
|
70
|
+
} else if (isNotEmpty(params.bulkBody)) {
|
|
61
71
|
queryParam = params.bulkBody
|
|
62
72
|
}
|
|
63
73
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict'
|
|
7
|
+
exports = module.exports = { isSimpleObject, isNotEmpty }
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Convenience function to test if a value is a non-null object
|
|
11
|
+
*
|
|
12
|
+
* @param {object} thing Value to be tested
|
|
13
|
+
* @returns {boolean} whether or not the value is an object and not null
|
|
14
|
+
*/
|
|
15
|
+
function isSimpleObject(thing) {
|
|
16
|
+
return 'object' === typeof thing && thing !== null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Convenience function to test if an object is not empty
|
|
21
|
+
*
|
|
22
|
+
* @param {object} thing Value to be tested
|
|
23
|
+
* @returns {boolean} true if the value is an object, not null, and has keys
|
|
24
|
+
*/
|
|
25
|
+
function isNotEmpty(thing) {
|
|
26
|
+
return isSimpleObject(thing) && Object.keys(thing).length > 0
|
|
27
|
+
}
|