newrelic 7.4.0 → 8.0.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 -0
- package/THIRD_PARTY_NOTICES.md +7 -7
- package/index.js +6 -5
- package/lib/config/index.js +24 -31
- package/lib/feature_flags.js +2 -4
- 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/instrumentation/mongodb.js +1 -1
- package/lib/shim/shim.js +0 -19
- package/lib/spans/create-span-event-aggregator.js +23 -70
- package/lib/util/cat.js +3 -4
- package/package.json +19 -17
package/NEWS.md
CHANGED
|
@@ -1,3 +1,79 @@
|
|
|
1
|
+
### v8.0.0 (2021-07-26)
|
|
2
|
+
|
|
3
|
+
* Added official parity support for Node 16.
|
|
4
|
+
|
|
5
|
+
* **BREAKING**: Dropped Node v10.x support. For further information on our support policy,
|
|
6
|
+
see: https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent.
|
|
7
|
+
* Upgraded `@newrelic/superagent` `@newrelic/aws-sdk` `@newrelic/koa` `@newrelic/native-metrics` and `@newrelic/test-utilities` to the latest major versions.
|
|
8
|
+
* Refactored creation of span event aggregator to prevent crash of gRPC when running on invalid Node.js version.
|
|
9
|
+
* Added check for minimum `node` version >= 12.
|
|
10
|
+
* Set package.json engines `node` field >= 12 and `npm` field to >=6.
|
|
11
|
+
* Removed Node v10 from ci workflow and smoke-test version matrix.
|
|
12
|
+
* Removed comments around replacing `temporarilyOverrideTapUncaughtBehavior` test helper function.
|
|
13
|
+
* Removed non-applicable semver checks for versions the agents no longer supports.
|
|
14
|
+
|
|
15
|
+
* **BREAKING**: The agent no-longer includes the New Relic certificate bundle automatically when using the 'certificates' configuration (commonly with proxies). If you find this breaking your current environment, you may leverage a feature-flag to temporarily restore this functionality. Example configuration: feature_flag: { certificate_bundle: true }. In this case, we recommend getting a certificate bundle for your environment such as the one from Mozilla. The New Relic bundle and feature flag will be fully removed in next major release.
|
|
16
|
+
* Defaulted config.feature_flags.certificate_bundle to false.
|
|
17
|
+
|
|
18
|
+
* **BREAKING**: Removed `serverless_mode` as a feature flag.
|
|
19
|
+
|
|
20
|
+
The standard `serverless_mode` configuration still exists.
|
|
21
|
+
|
|
22
|
+
* Added hapi 19 and 20 to versioned tests for Node.js `>=12` and `<16`
|
|
23
|
+
* Added hapi `^20.1.2` to versioned tests for for Node.js `>=16`
|
|
24
|
+
|
|
25
|
+
* Upgraded tap to v15.
|
|
26
|
+
|
|
27
|
+
* Upgraded https-proxy-agent to v5.0.0.
|
|
28
|
+
|
|
29
|
+
* Updated linting to always use latest LTS Node version.
|
|
30
|
+
|
|
31
|
+
* Updated CI and Smoke Test scripts to use setup-node@v2.
|
|
32
|
+
|
|
33
|
+
* Added `no-const-assign` to eslint ruleset.
|
|
34
|
+
|
|
35
|
+
* Pinned mongodb versioned tests to <4.0.0.
|
|
36
|
+
|
|
37
|
+
### v7.5.2 (2021-07-07)
|
|
38
|
+
|
|
39
|
+
* Fixed bug where promise-based cursor methods would not properly measure the duration of execution.
|
|
40
|
+
|
|
41
|
+
### v7.5.1 (2021-06-21)
|
|
42
|
+
|
|
43
|
+
* Fixed loading config from the main module's directory. Thank you @alexpls for the contribution.
|
|
44
|
+
|
|
45
|
+
* Moved all integration tests that required secrets to the smoke folder.
|
|
46
|
+
|
|
47
|
+
* Fixed LASP/CSP tests so they don't skip on runs where secrets are available.
|
|
48
|
+
|
|
49
|
+
* Modified self-signed SSL cert to use 'localhost' instead of 'ssl.lvh.me' for SSL testing.
|
|
50
|
+
|
|
51
|
+
* Removed unnecessary trace observer configuration validation for host and port.
|
|
52
|
+
|
|
53
|
+
### v7.5.0 (2021-06-01)
|
|
54
|
+
|
|
55
|
+
* Added default support for config files with a 'cjs' extension (`newrelic.cjs`) in addition to `newrelic.js`.
|
|
56
|
+
|
|
57
|
+
Thank you to @Maddemacher for the contribution!
|
|
58
|
+
|
|
59
|
+
* Added ability to specify a custom config file name with the `NEW_RELIC_CONFIG_FILENAME` environment variable.
|
|
60
|
+
|
|
61
|
+
Thank you to @Maddemacher for the contribution!
|
|
62
|
+
|
|
63
|
+
* 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).
|
|
64
|
+
|
|
65
|
+
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.
|
|
66
|
+
|
|
67
|
+
* Bumped `@newrelic/test-utilities` to ^5.1.0.
|
|
68
|
+
|
|
69
|
+
* Replaced deprecated `util.isArray` with `Array.isArray`.
|
|
70
|
+
|
|
71
|
+
* Removed unused `listenerCount` method on `Shim`.
|
|
72
|
+
|
|
73
|
+
* Properly bootstraped husky as a `prepare` script.
|
|
74
|
+
|
|
75
|
+
* Removed commented-out console log from fastify instrumentation.
|
|
76
|
+
|
|
1
77
|
### v7.4.0 (2021-05-11)
|
|
2
78
|
|
|
3
79
|
* Updated third party notices and manifest for husky and lint-staged.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -495,7 +495,7 @@ This product includes source derived from [@grpc/proto-loader](https://github.co
|
|
|
495
495
|
|
|
496
496
|
### @newrelic/aws-sdk
|
|
497
497
|
|
|
498
|
-
This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([
|
|
498
|
+
This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v4.0.1](https://github.com/newrelic/node-newrelic-aws-sdk/tree/v4.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-aws-sdk/blob/v4.0.1/LICENSE):
|
|
499
499
|
|
|
500
500
|
```
|
|
501
501
|
Apache License
|
|
@@ -703,7 +703,7 @@ This product includes source derived from [@newrelic/aws-sdk](https://github.com
|
|
|
703
703
|
|
|
704
704
|
### @newrelic/koa
|
|
705
705
|
|
|
706
|
-
This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([
|
|
706
|
+
This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v6.0.1](https://github.com/newrelic/node-newrelic-koa/tree/v6.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v6.0.1/LICENSE):
|
|
707
707
|
|
|
708
708
|
```
|
|
709
709
|
Apache License
|
|
@@ -912,7 +912,7 @@ Apache License
|
|
|
912
912
|
|
|
913
913
|
### @newrelic/superagent
|
|
914
914
|
|
|
915
|
-
This product includes source derived from [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent) ([
|
|
915
|
+
This product includes source derived from [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent) ([v5.0.1](https://github.com/newrelic/node-newrelic-superagent/tree/v5.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-superagent/blob/v5.0.1/LICENSE):
|
|
916
916
|
|
|
917
917
|
```
|
|
918
918
|
Apache License
|
|
@@ -1208,7 +1208,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
1208
1208
|
|
|
1209
1209
|
### https-proxy-agent
|
|
1210
1210
|
|
|
1211
|
-
This product includes source derived from [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) ([
|
|
1211
|
+
This product includes source derived from [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) ([v5.0.0](https://github.com/TooTallNate/node-https-proxy-agent/tree/v5.0.0)), distributed under the [MIT License](https://github.com/TooTallNate/node-https-proxy-agent/blob/v5.0.0/README.md):
|
|
1212
1212
|
|
|
1213
1213
|
```
|
|
1214
1214
|
MIT License
|
|
@@ -1553,7 +1553,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
1553
1553
|
|
|
1554
1554
|
### @newrelic/test-utilities
|
|
1555
1555
|
|
|
1556
|
-
This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([
|
|
1556
|
+
This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v6.0.0](https://github.com/newrelic/node-test-utilities/tree/v6.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v6.0.0/LICENSE):
|
|
1557
1557
|
|
|
1558
1558
|
```
|
|
1559
1559
|
Apache License
|
|
@@ -2066,7 +2066,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
2066
2066
|
|
|
2067
2067
|
### glob
|
|
2068
2068
|
|
|
2069
|
-
This product includes source derived from [glob](https://github.com/isaacs/node-glob) ([v7.1.
|
|
2069
|
+
This product includes source derived from [glob](https://github.com/isaacs/node-glob) ([v7.1.7](https://github.com/isaacs/node-glob/tree/v7.1.7)), distributed under the [ISC License](https://github.com/isaacs/node-glob/blob/v7.1.7/LICENSE):
|
|
2070
2070
|
|
|
2071
2071
|
```
|
|
2072
2072
|
The ISC License
|
|
@@ -3003,7 +3003,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
3003
3003
|
|
|
3004
3004
|
### tap
|
|
3005
3005
|
|
|
3006
|
-
This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([
|
|
3006
|
+
This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v15.0.9](https://github.com/tapjs/node-tap/tree/v15.0.9)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v15.0.9/LICENSE):
|
|
3007
3007
|
|
|
3008
3008
|
```
|
|
3009
3009
|
The ISC License
|
package/index.js
CHANGED
|
@@ -48,16 +48,17 @@ function initialize() {
|
|
|
48
48
|
preAgentTime
|
|
49
49
|
)
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (!psemver.satisfies(pkgJSON.engines.node)) {
|
|
52
|
+
// TODO: Update this message when Node v12 is deprecated.
|
|
53
53
|
message = 'New Relic for Node.js requires a version of Node equal to or\n' +
|
|
54
|
-
|
|
54
|
+
'greater than 12.0.0. Not starting!'
|
|
55
55
|
|
|
56
56
|
logger.error(message)
|
|
57
57
|
throw new Error(message)
|
|
58
|
+
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
// TODO: Update this check when Node v18 support is added
|
|
61
|
+
if (psemver.satisfies('>=17.0.0')) {
|
|
61
62
|
logger.warn(
|
|
62
63
|
'New Relic for Node.js %s has not been tested on Node.js %s. Please ' +
|
|
63
64
|
'update the agent or downgrade your version of Node.js',
|
package/lib/config/index.js
CHANGED
|
@@ -17,7 +17,6 @@ const hashes = require('../util/hashes')
|
|
|
17
17
|
const os = require('os')
|
|
18
18
|
const parseKey = require('../collector/key-parser').parseKey
|
|
19
19
|
const path = require('path')
|
|
20
|
-
const psemver = require('../util/process-version')
|
|
21
20
|
const stringify = require('json-stringify-safe')
|
|
22
21
|
const util = require('util')
|
|
23
22
|
const MergeServerConfig = require('./merge-server-config')
|
|
@@ -32,14 +31,6 @@ const DEFAULT_MAX_PAYLOAD_SIZE_IN_BYTES = 1000000
|
|
|
32
31
|
const DEFAULT_CONFIG_PATH = require.resolve('./default')
|
|
33
32
|
const SPAN_EVENT_LIMIT = 1000
|
|
34
33
|
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
34
|
const HAS_ARBITRARY_KEYS = new Set([
|
|
44
35
|
'ignore_messages',
|
|
45
36
|
'expected_messages',
|
|
@@ -54,10 +45,22 @@ const exists = fs.existsSync || path.existsSync
|
|
|
54
45
|
let logger = null // Lazy-loaded in `initialize`.
|
|
55
46
|
let _configInstance = null
|
|
56
47
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
const getConfigFileNames = () => [
|
|
49
|
+
process.env.NEW_RELIC_CONFIG_FILENAME,
|
|
50
|
+
'newrelic.js',
|
|
51
|
+
'newrelic.cjs'
|
|
52
|
+
].filter(Boolean)
|
|
53
|
+
|
|
54
|
+
const getConfigFileLocations = () => [
|
|
55
|
+
process.env.NEW_RELIC_HOME,
|
|
56
|
+
process.cwd(),
|
|
57
|
+
process.env.HOME,
|
|
58
|
+
path.join(__dirname, '../../../..'), // above node_modules
|
|
59
|
+
// the REPL has no main module
|
|
60
|
+
process.mainModule && process.mainModule.filename
|
|
61
|
+
? path.dirname(process.mainModule.filename)
|
|
62
|
+
: undefined
|
|
63
|
+
].filter(Boolean)
|
|
61
64
|
|
|
62
65
|
function isTruthular(setting) {
|
|
63
66
|
if (setting == null) {
|
|
@@ -89,19 +92,15 @@ function fromObjectList(setting) {
|
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
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
|
|
95
|
+
const configFileCandidates = getConfigFileLocations().reduce((files, configPath) => {
|
|
96
|
+
const configFiles = getConfigFileNames().map(filename =>
|
|
97
|
+
path.join(path.resolve(configPath), filename)
|
|
98
|
+
)
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
return files.concat(configFiles)
|
|
101
|
+
}, [])
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
}
|
|
103
|
+
return configFileCandidates.find(exists)
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
function Config(config) {
|
|
@@ -885,10 +884,7 @@ Config.prototype.logUnknown = function logUnknown(json, key) {
|
|
|
885
884
|
* Return the availability of async_hook for use by the agent.
|
|
886
885
|
*/
|
|
887
886
|
Config.prototype.checkAsyncHookStatus = function checkAsyncHookStatus() {
|
|
888
|
-
return
|
|
889
|
-
this.feature_flag.await_support &&
|
|
890
|
-
(psemver.satisfies('>=8') || psemver.prerelease())
|
|
891
|
-
)
|
|
887
|
+
return this.feature_flag.await_support
|
|
892
888
|
}
|
|
893
889
|
|
|
894
890
|
/**
|
|
@@ -1326,9 +1322,6 @@ Config.prototype._canonicalize = function _canonicalize() {
|
|
|
1326
1322
|
)
|
|
1327
1323
|
}
|
|
1328
1324
|
|
|
1329
|
-
this.serverless_mode.enabled = this.serverless_mode.enabled
|
|
1330
|
-
&& this.feature_flag.serverless_mode
|
|
1331
|
-
|
|
1332
1325
|
if (this.license_key) {
|
|
1333
1326
|
this.license_key = this.license_key.trim()
|
|
1334
1327
|
}
|
package/lib/feature_flags.js
CHANGED
|
@@ -9,13 +9,10 @@
|
|
|
9
9
|
exports.prerelease = {
|
|
10
10
|
express5: false,
|
|
11
11
|
await_support: true,
|
|
12
|
-
serverless_mode: true, // TODO: Move to released & remove code checks next Major.
|
|
13
12
|
promise_segments: false,
|
|
14
13
|
reverse_naming_rules: false,
|
|
15
14
|
fastify_instrumentation: false,
|
|
16
|
-
|
|
17
|
-
// Will eventually set false prior full removal of feature.
|
|
18
|
-
certificate_bundle: true,
|
|
15
|
+
certificate_bundle: false,
|
|
19
16
|
new_promise_tracking: false
|
|
20
17
|
}
|
|
21
18
|
|
|
@@ -28,6 +25,7 @@ exports.released = [
|
|
|
28
25
|
'express_segments',
|
|
29
26
|
'native_metrics',
|
|
30
27
|
'protocol_17',
|
|
28
|
+
'serverless_mode',
|
|
31
29
|
'send_request_uri_attribute',
|
|
32
30
|
'synthetics',
|
|
33
31
|
'dt_format_w3c'
|
|
@@ -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,
|
|
@@ -288,7 +288,7 @@ function makeQueryDescFunc(shim, methodName) {
|
|
|
288
288
|
// segment name does not actually use query string
|
|
289
289
|
// method name is set as query so the query parser has access to the op name
|
|
290
290
|
const parameters = getInstanceAttributeParameters(shim, this)
|
|
291
|
-
return {query: methodName, parameters, callback: shim.LAST}
|
|
291
|
+
return {query: methodName, parameters, promise: true, callback: shim.LAST}
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
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
|
*
|
|
@@ -5,29 +5,32 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
const psemver = require('../util/process-version')
|
|
9
8
|
const logger = require('../logger')
|
|
10
9
|
const SpanEventAggregator = require('./span-event-aggregator')
|
|
11
10
|
const StreamingSpanEventAggregator = require('./streaming-span-event-aggregator')
|
|
12
11
|
|
|
13
12
|
function createSpanEventAggregator(config, collector, metrics) {
|
|
14
|
-
|
|
15
|
-
if (config.infinite_tracing.trace_observer.host) {
|
|
16
|
-
// TODO: ideally this validation and configuration clearing would happen
|
|
17
|
-
// in the config. Since we don't currently have a way to generate
|
|
18
|
-
// support metrics in the config, keeping this related logic together here.
|
|
19
|
-
// If logic happened prior, could merely check for existence of trace_observer.host.
|
|
20
|
-
shouldCreateStreaming = validateInfiniteTracing(config.infinite_tracing.trace_observer)
|
|
13
|
+
const trace_observer = config.infinite_tracing.trace_observer
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
config.infinite_tracing.trace_observer.host = ''
|
|
25
|
-
config.infinite_tracing.trace_observer.port = ''
|
|
26
|
-
}
|
|
27
|
-
}
|
|
15
|
+
if (trace_observer.host) {
|
|
16
|
+
trace_observer.host = trace_observer.host.trim()
|
|
28
17
|
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
if (typeof trace_observer.port !== 'string') {
|
|
19
|
+
trace_observer.port = String(trace_observer.port)
|
|
20
|
+
}
|
|
21
|
+
trace_observer.port = trace_observer.port.trim()
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
return createStreamingAggregator(config, collector, metrics)
|
|
25
|
+
} catch (err) {
|
|
26
|
+
logger.warn(err, 'Failed to create streaming span event aggregator for infinite tracing. ' +
|
|
27
|
+
'Reverting to standard span event aggregator and disabling infinite tracing')
|
|
28
|
+
config.infinite_tracing.trace_observer = {
|
|
29
|
+
host: '',
|
|
30
|
+
port: ''
|
|
31
|
+
}
|
|
32
|
+
return createStandardAggregator(config, collector, metrics)
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
return createStandardAggregator(config, collector, metrics)
|
|
@@ -35,12 +38,10 @@ function createSpanEventAggregator(config, collector, metrics) {
|
|
|
35
38
|
|
|
36
39
|
function createStreamingAggregator(config, collector, metrics) {
|
|
37
40
|
logger.trace('Creating streaming span event aggregator for infinite tracing.')
|
|
38
|
-
|
|
39
|
-
// loading the class here to ensure its behind a feature flag
|
|
40
|
-
// and won't trigger a grpc load in node 8
|
|
41
41
|
const GrpcConnection = require('../grpc/connection')
|
|
42
|
-
const connection = new GrpcConnection(config.infinite_tracing.trace_observer, metrics)
|
|
43
42
|
const SpanStreamer = require('./span-streamer')
|
|
43
|
+
|
|
44
|
+
const connection = new GrpcConnection(config.infinite_tracing.trace_observer, metrics)
|
|
44
45
|
const spanStreamer = new SpanStreamer(
|
|
45
46
|
config.license_key,
|
|
46
47
|
connection,
|
|
@@ -54,9 +55,7 @@ function createStreamingAggregator(config, collector, metrics) {
|
|
|
54
55
|
span_streamer: spanStreamer
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return aggregator
|
|
58
|
+
return new StreamingSpanEventAggregator(opts, collector, metrics)
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
function createStandardAggregator(config, collector, metrics) {
|
|
@@ -67,53 +66,7 @@ function createStandardAggregator(config, collector, metrics) {
|
|
|
67
66
|
limit: config.event_harvest_config.harvest_limits.span_event_data
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
return aggregator
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function validateInfiniteTracing(trace_observer) {
|
|
75
|
-
// TODO: Remove semver check when Node 10 support dropped.
|
|
76
|
-
if (!psemver.satisfies('>=10.10.0')) {
|
|
77
|
-
logger.warn(
|
|
78
|
-
'Infinite tracing disabled: this version of Node is not supported (must be >=10.10.0)'
|
|
79
|
-
)
|
|
80
|
-
return false
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
trace_observer.host = trace_observer.host.trim()
|
|
84
|
-
|
|
85
|
-
if (!validateHostName(trace_observer.host)) {
|
|
86
|
-
logger.warn('Infinite tracing disabled: invalid infinite_tracing.trace_observer.host value')
|
|
87
|
-
|
|
88
|
-
return false
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (typeof trace_observer.port !== 'string') {
|
|
92
|
-
trace_observer.port = String(trace_observer.port)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
trace_observer.port = trace_observer.port.trim()
|
|
96
|
-
|
|
97
|
-
if (!validatePortValue(trace_observer.port)) {
|
|
98
|
-
logger.warn('Infinite tracing disabled: invalid infinite_tracing.trace_observer.port value')
|
|
99
|
-
|
|
100
|
-
return false
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return true
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function validateHostName(host) {
|
|
107
|
-
// Regular expression for validating a hostname
|
|
108
|
-
const hostReg = /(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)/
|
|
109
|
-
|
|
110
|
-
return hostReg.test(host)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function validatePortValue(port) {
|
|
114
|
-
if (port.length === 0) return false
|
|
115
|
-
|
|
116
|
-
return !isNaN(port)
|
|
69
|
+
return new SpanEventAggregator(opts, collector, metrics)
|
|
117
70
|
}
|
|
118
71
|
|
|
119
72
|
module.exports = createSpanEventAggregator
|
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": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
],
|
|
112
112
|
"homepage": "http://github.com/newrelic/node-newrelic",
|
|
113
113
|
"engines": {
|
|
114
|
-
"node": ">=
|
|
115
|
-
"npm": ">=
|
|
114
|
+
"node": ">=12.0.0",
|
|
115
|
+
"npm": ">=6.0.0"
|
|
116
116
|
},
|
|
117
117
|
"directories": {
|
|
118
118
|
"lib": "lib"
|
|
@@ -120,24 +120,26 @@
|
|
|
120
120
|
"scripts": {
|
|
121
121
|
"bench": "node ./bin/run-bench.js",
|
|
122
122
|
"ca-gen": "./bin/update-ca-bundle.sh",
|
|
123
|
-
"clean": "./bin/clean.sh",
|
|
124
123
|
"docker-env": "./bin/docker-env-vars.sh",
|
|
125
124
|
"docs": "npm ci && jsdoc -c ./jsdoc-conf.json --private -r .",
|
|
126
|
-
"integration": "npm run prepare-test && npm run sub-install && time tap
|
|
127
|
-
"prepare-test": "npm
|
|
125
|
+
"integration": "npm run prepare-test && npm run sub-install && time tap test/integration/**/**/*.tap.js --timeout=180 --no-coverage --reporter classic",
|
|
126
|
+
"prepare-test": "npm run ca-gen && npm run ssl && npm run docker-env",
|
|
128
127
|
"lint": "eslint ./*.js lib test bin",
|
|
129
128
|
"public-docs": "npm ci && jsdoc -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/ lib/transaction/handle.js && cp examples/shim/*.png out/",
|
|
130
129
|
"publish-docs": "./bin/publish-docs.sh",
|
|
131
130
|
"services": "./bin/docker-services.sh",
|
|
132
|
-
"smoke": "npm run
|
|
131
|
+
"smoke": "npm run ssl && time tap test/smoke/**/**/*.tap.js --timeout=180 --no-coverage",
|
|
133
132
|
"ssl": "./bin/ssl.sh",
|
|
134
133
|
"sub-install": "node test/bin/install_sub_deps",
|
|
135
134
|
"test": "npm run integration && npm run unit",
|
|
136
|
-
"unit": "rm -f newrelic_agent.log && time tap --test-regex='(\\/|^test\\/unit\\/.*\\.test\\.js)$' --timeout=180 --no-coverage",
|
|
135
|
+
"unit": "rm -f newrelic_agent.log && time tap --test-regex='(\\/|^test\\/unit\\/.*\\.test\\.js)$' --timeout=180 --no-coverage --reporter classic",
|
|
137
136
|
"update-cross-agent-tests": "./bin/update-cats.sh",
|
|
138
137
|
"versioned-tests": "./bin/run-versioned-tests.sh",
|
|
139
138
|
"update-changelog-version": "node ./bin/update-changelog-version",
|
|
140
|
-
"versioned": "npm run
|
|
139
|
+
"versioned": "npm run versioned:npm7",
|
|
140
|
+
"versioned:npm6": "npm run prepare-test && time ./bin/run-versioned-tests.sh",
|
|
141
|
+
"versioned:npm7": "npm run prepare-test && NPM7=1 time ./bin/run-versioned-tests.sh",
|
|
142
|
+
"prepare": "husky install"
|
|
141
143
|
},
|
|
142
144
|
"bin": {
|
|
143
145
|
"newrelic-naming-rules": "./bin/test-naming-rules.js"
|
|
@@ -145,25 +147,24 @@
|
|
|
145
147
|
"dependencies": {
|
|
146
148
|
"@grpc/grpc-js": "^1.2.11",
|
|
147
149
|
"@grpc/proto-loader": "^0.5.6",
|
|
148
|
-
"@newrelic/aws-sdk": "^
|
|
149
|
-
"@newrelic/koa": "^
|
|
150
|
-
"@newrelic/superagent": "^
|
|
150
|
+
"@newrelic/aws-sdk": "^4.0.1",
|
|
151
|
+
"@newrelic/koa": "^6.0.1",
|
|
152
|
+
"@newrelic/superagent": "^5.0.1",
|
|
151
153
|
"@tyriar/fibonacci-heap": "^2.0.7",
|
|
152
154
|
"async": "^3.2.0",
|
|
153
155
|
"concat-stream": "^2.0.0",
|
|
154
|
-
"https-proxy-agent": "^
|
|
156
|
+
"https-proxy-agent": "^5.0.0",
|
|
155
157
|
"json-stringify-safe": "^5.0.0",
|
|
156
158
|
"readable-stream": "^3.6.0",
|
|
157
159
|
"semver": "^5.3.0"
|
|
158
160
|
},
|
|
159
161
|
"optionalDependencies": {
|
|
160
|
-
"@newrelic/native-metrics": "^
|
|
162
|
+
"@newrelic/native-metrics": "^7.0.1"
|
|
161
163
|
},
|
|
162
164
|
"devDependencies": {
|
|
163
165
|
"@newrelic/proxy": "^2.0.0",
|
|
164
|
-
"@newrelic/test-utilities": "^
|
|
166
|
+
"@newrelic/test-utilities": "^6.0.0",
|
|
165
167
|
"@octokit/rest": "^18.0.15",
|
|
166
|
-
"JSV": "~4.0.2",
|
|
167
168
|
"architect": "*",
|
|
168
169
|
"benchmark": "^2.1.4",
|
|
169
170
|
"bluebird": "^3.4.7",
|
|
@@ -178,6 +179,7 @@
|
|
|
178
179
|
"http-errors": "^1.7.3",
|
|
179
180
|
"husky": "^6.0.0",
|
|
180
181
|
"jsdoc": "^3.6.3",
|
|
182
|
+
"JSV": "~4.0.2",
|
|
181
183
|
"lint-staged": "^11.0.0",
|
|
182
184
|
"memcached": ">=0.2.8",
|
|
183
185
|
"minami": "^1.1.1",
|
|
@@ -192,7 +194,7 @@
|
|
|
192
194
|
"rimraf": "^2.6.3",
|
|
193
195
|
"should": "*",
|
|
194
196
|
"sinon": "^4.5.0",
|
|
195
|
-
"tap": "^
|
|
197
|
+
"tap": "^15.0.9",
|
|
196
198
|
"temp": "^0.8.1",
|
|
197
199
|
"through": "^2.3.6",
|
|
198
200
|
"when": "*"
|