newrelic 7.4.0 → 7.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 +24 -0
- package/lib/config/index.js +21 -20
- package/lib/instrumentation/core/async_hooks.js +4 -0
- package/lib/instrumentation/core/http-outbound.js +2 -3
- package/lib/instrumentation/core/http.js +1 -2
- package/lib/instrumentation/fastify.js +1 -1
- package/lib/shim/shim.js +0 -19
- package/lib/util/cat.js +3 -4
- package/package.json +4 -3
package/NEWS.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
### v7.5.0 (2021-06-01)
|
|
2
|
+
|
|
3
|
+
* Added default support for config files with a 'cjs' extension (`newrelic.cjs`) in addition to `newrelic.js`.
|
|
4
|
+
|
|
5
|
+
Thank you to @Maddemacher for the contribution!
|
|
6
|
+
|
|
7
|
+
* Added ability to specify a custom config file name with the `NEW_RELIC_CONFIG_FILENAME` environment variable.
|
|
8
|
+
|
|
9
|
+
Thank you to @Maddemacher for the contribution!
|
|
10
|
+
|
|
11
|
+
* Fixed issue when using the 'new_promise_tracking' feature flag where segment mapping may not get cleaned up for promises which never resolve but have all references removed (and thus get cleaned up by GC).
|
|
12
|
+
|
|
13
|
+
Adds segment cleanup on 'destroy' when using 'new_promise_tracking' feature flag in addition to the existing 'promiseResolve' hook. Unfortunately, preventing leaks for this edge-case does come with additional overhead due to adding another hook. Memory gains from feature flag usage should still be worth the trade-off and reduced garbage collection may offset perf/CPU impacts or event still result in net gain, depending on the application.
|
|
14
|
+
|
|
15
|
+
* Bumped `@newrelic/test-utilities` to ^5.1.0.
|
|
16
|
+
|
|
17
|
+
* Replaced deprecated `util.isArray` with `Array.isArray`.
|
|
18
|
+
|
|
19
|
+
* Removed unused `listenerCount` method on `Shim`.
|
|
20
|
+
|
|
21
|
+
* Properly bootstraped husky as a `prepare` script.
|
|
22
|
+
|
|
23
|
+
* Removed commented-out console log from fastify instrumentation.
|
|
24
|
+
|
|
1
25
|
### v7.4.0 (2021-05-11)
|
|
2
26
|
|
|
3
27
|
* Updated third party notices and manifest for husky and lint-staged.
|
package/lib/config/index.js
CHANGED
|
@@ -32,14 +32,6 @@ const DEFAULT_MAX_PAYLOAD_SIZE_IN_BYTES = 1000000
|
|
|
32
32
|
const DEFAULT_CONFIG_PATH = require.resolve('./default')
|
|
33
33
|
const SPAN_EVENT_LIMIT = 1000
|
|
34
34
|
const BASE_CONFIG_PATH = require.resolve('../../newrelic')
|
|
35
|
-
const DEFAULT_FILENAME = 'newrelic.js'
|
|
36
|
-
const CONFIG_FILE_LOCATIONS = [
|
|
37
|
-
process.env.NEW_RELIC_HOME,
|
|
38
|
-
process.cwd(),
|
|
39
|
-
process.env.HOME,
|
|
40
|
-
path.join(__dirname, '../../../..') // above node_modules
|
|
41
|
-
]
|
|
42
|
-
|
|
43
35
|
const HAS_ARBITRARY_KEYS = new Set([
|
|
44
36
|
'ignore_messages',
|
|
45
37
|
'expected_messages',
|
|
@@ -54,9 +46,22 @@ const exists = fs.existsSync || path.existsSync
|
|
|
54
46
|
let logger = null // Lazy-loaded in `initialize`.
|
|
55
47
|
let _configInstance = null
|
|
56
48
|
|
|
49
|
+
const getConfigFileNames = () => [
|
|
50
|
+
process.env.NEW_RELIC_CONFIG_FILENAME,
|
|
51
|
+
'newrelic.js',
|
|
52
|
+
'newrelic.cjs'
|
|
53
|
+
].filter(Boolean)
|
|
54
|
+
|
|
55
|
+
const getConfigFileLocations = () => [
|
|
56
|
+
process.env.NEW_RELIC_HOME,
|
|
57
|
+
process.cwd(),
|
|
58
|
+
process.env.HOME,
|
|
59
|
+
path.join(__dirname, '../../../..') // above node_modules
|
|
60
|
+
].filter(Boolean)
|
|
61
|
+
|
|
57
62
|
// the REPL has no main module
|
|
58
63
|
if (process.mainModule && process.mainModule.filename) {
|
|
59
|
-
|
|
64
|
+
getConfigFileLocations().splice(2, 0, path.dirname(process.mainModule.filename))
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
function isTruthular(setting) {
|
|
@@ -89,19 +94,15 @@ function fromObjectList(setting) {
|
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
function _findConfigFile() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for (var i = 0; i < CONFIG_FILE_LOCATIONS.length; i++) {
|
|
97
|
-
candidate = CONFIG_FILE_LOCATIONS[i]
|
|
98
|
-
if (!candidate) continue
|
|
97
|
+
const configFileCandidates = getConfigFileLocations().reduce((files, configPath) => {
|
|
98
|
+
const configFiles = getConfigFileNames().map(filename =>
|
|
99
|
+
path.join(path.resolve(configPath), filename)
|
|
100
|
+
)
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
return files.concat(configFiles)
|
|
103
|
+
}, [])
|
|
102
104
|
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
+
return configFileCandidates.find(exists)
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
function Config(config) {
|
|
@@ -191,6 +191,10 @@ function getPromiseResolveStyleHooks(segmentMap, agent, shim) {
|
|
|
191
191
|
if (hookSegment === null) {
|
|
192
192
|
shim.setActiveSegment(hookSegment)
|
|
193
193
|
}
|
|
194
|
+
},
|
|
195
|
+
destroy: function destroyHandler(id) {
|
|
196
|
+
// Clean up any unresolved promises that have been destroyed.
|
|
197
|
+
segmentMap.delete(id)
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
|
|
@@ -10,7 +10,6 @@ var urltils = require('../../util/urltils')
|
|
|
10
10
|
var hashes = require('../../util/hashes')
|
|
11
11
|
var logger = require('../../logger').child({component: 'outbound'})
|
|
12
12
|
var shimmer = require('../../shimmer')
|
|
13
|
-
var util = require('util')
|
|
14
13
|
var url = require('url')
|
|
15
14
|
var copy = require('../../util/copy')
|
|
16
15
|
|
|
@@ -110,7 +109,7 @@ module.exports = function instrumentOutbound(agent, opts, makeRequest) {
|
|
|
110
109
|
logger.trace('CAT disabled, not adding headers!')
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
if (
|
|
112
|
+
if (Array.isArray(opts.headers)) {
|
|
114
113
|
opts.headers = opts.headers.slice()
|
|
115
114
|
Array.prototype.push.apply(
|
|
116
115
|
opts.headers,
|
|
@@ -203,7 +202,7 @@ function handleResponse(segment, hostname, req, res) {
|
|
|
203
202
|
// Add response attributes for spans
|
|
204
203
|
segment.addSpanAttribute('http.statusCode', res.statusCode)
|
|
205
204
|
segment.addSpanAttribute('http.statusText', res.statusMessage)
|
|
206
|
-
|
|
205
|
+
|
|
207
206
|
// If CAT is enabled, grab those headers!
|
|
208
207
|
const agent = segment.transaction.agent
|
|
209
208
|
if (
|
|
@@ -11,7 +11,6 @@ const recordWeb = require('../../metrics/recorders/http')
|
|
|
11
11
|
const hashes = require('../../util/hashes')
|
|
12
12
|
const cat = require('../../util/cat')
|
|
13
13
|
const instrumentOutbound = require('./http-outbound')
|
|
14
|
-
const util = require('util')
|
|
15
14
|
const url = require('url')
|
|
16
15
|
const urltils = require('../../util/urltils')
|
|
17
16
|
const properties = require('../../util/properties')
|
|
@@ -606,7 +605,7 @@ function parseSyntheticsHeader(header, encKey, trustedIds) {
|
|
|
606
605
|
return
|
|
607
606
|
}
|
|
608
607
|
|
|
609
|
-
if (!
|
|
608
|
+
if (!Array.isArray(synthData)) {
|
|
610
609
|
logger.trace(
|
|
611
610
|
'Synthetics data is not an array: %s (%s)',
|
|
612
611
|
synthData,
|
package/lib/shim/shim.js
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
const arity = require('../util/arity')
|
|
9
9
|
const constants = require('./constants')
|
|
10
|
-
const events = require('events')
|
|
11
10
|
const hasOwnProperty = require('../util/properties').hasOwn
|
|
12
11
|
const logger = require('../logger').child({component: 'Shim'})
|
|
13
12
|
const path = require('path')
|
|
@@ -127,7 +126,6 @@ Shim.prototype.isNull = isNull
|
|
|
127
126
|
Shim.prototype.toArray = toArray
|
|
128
127
|
Shim.prototype.argsToArray = argsToArray
|
|
129
128
|
Shim.prototype.normalizeIndex = normalizeIndex
|
|
130
|
-
Shim.prototype.listenerCount = listenerCount
|
|
131
129
|
Shim.prototype.once = once
|
|
132
130
|
|
|
133
131
|
Shim.prototype.setInternalProperty = setInternalProperty
|
|
@@ -1695,23 +1693,6 @@ function normalizeIndex(arrayLength, idx) {
|
|
|
1695
1693
|
return (idx < 0 || idx >= arrayLength) ? null : idx
|
|
1696
1694
|
}
|
|
1697
1695
|
|
|
1698
|
-
/**
|
|
1699
|
-
* Retrieves the number of listeners for the given event.
|
|
1700
|
-
*
|
|
1701
|
-
* @memberof Shim.prototype
|
|
1702
|
-
*
|
|
1703
|
-
* @param {object} emitter - The emitter to count the listeners on.
|
|
1704
|
-
* @param {string} event - The event to count.
|
|
1705
|
-
*
|
|
1706
|
-
* @return {number} The number of listeners on the given event for this emitter.
|
|
1707
|
-
*/
|
|
1708
|
-
function listenerCount(emitter, evnt) {
|
|
1709
|
-
if (events.EventEmitter.listenerCount) {
|
|
1710
|
-
return events.EventEmitter.listenerCount(emitter, evnt)
|
|
1711
|
-
}
|
|
1712
|
-
return emitter.listeners(evnt).length
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
1696
|
/**
|
|
1716
1697
|
* Wraps a function such that it will only be executed once.
|
|
1717
1698
|
*
|
package/lib/util/cat.js
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var logger = require('../logger').child({component: 'cat'})
|
|
8
|
+
const hashes = require('./hashes')
|
|
9
|
+
const logger = require('../logger').child({component: 'cat'})
|
|
11
10
|
|
|
12
11
|
module.exports.handleCatHeaders = handleCatHeaders
|
|
13
12
|
module.exports.parsedHeadersToTrans = parsedHeadersToTrans
|
|
@@ -43,7 +42,7 @@ function parsedHeadersToTrans(parsedCatId, externalTrans, transaction) {
|
|
|
43
42
|
transaction.incomingCatId = parsedCatId
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
if (
|
|
45
|
+
if (Array.isArray(externalTrans)) {
|
|
47
46
|
transaction.referringTransactionGuid = externalTrans[0]
|
|
48
47
|
if (typeof externalTrans[2] === 'string') {
|
|
49
48
|
transaction.tripId = externalTrans[2]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.0",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -137,7 +137,8 @@
|
|
|
137
137
|
"update-cross-agent-tests": "./bin/update-cats.sh",
|
|
138
138
|
"versioned-tests": "./bin/run-versioned-tests.sh",
|
|
139
139
|
"update-changelog-version": "node ./bin/update-changelog-version",
|
|
140
|
-
"versioned": "npm run prepare-test && time ./bin/run-versioned-tests.sh"
|
|
140
|
+
"versioned": "npm run prepare-test && time ./bin/run-versioned-tests.sh",
|
|
141
|
+
"prepare": "husky install"
|
|
141
142
|
},
|
|
142
143
|
"bin": {
|
|
143
144
|
"newrelic-naming-rules": "./bin/test-naming-rules.js"
|
|
@@ -161,7 +162,7 @@
|
|
|
161
162
|
},
|
|
162
163
|
"devDependencies": {
|
|
163
164
|
"@newrelic/proxy": "^2.0.0",
|
|
164
|
-
"@newrelic/test-utilities": "^5.
|
|
165
|
+
"@newrelic/test-utilities": "^5.1.0",
|
|
165
166
|
"@octokit/rest": "^18.0.15",
|
|
166
167
|
"JSV": "~4.0.2",
|
|
167
168
|
"architect": "*",
|