newrelic 9.6.0 → 9.7.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 +4 -0
- package/api.js +2 -0
- package/bin/test-naming-rules.js +1 -1
- package/esm-loader.mjs +1 -3
- package/lib/adaptive-sampler.js +1 -2
- package/lib/agent.js +2 -0
- package/lib/aggregators/event-aggregator.js +2 -2
- package/lib/attributes.js +2 -4
- package/lib/collector/api.js +20 -12
- package/lib/collector/facts.js +1 -3
- package/lib/collector/parse-response.js +3 -1
- package/lib/collector/remote-method.js +8 -9
- package/lib/config/attribute-filter.js +14 -16
- package/lib/config/default.js +17 -0
- package/lib/config/harvest-config-validator.js +3 -5
- package/lib/config/index.js +7 -4
- package/lib/environment.js +6 -5
- package/lib/errors/error-collector.js +6 -3
- package/lib/errors/helper.js +10 -18
- package/lib/errors/index.js +12 -6
- package/lib/grpc/connection.js +12 -5
- package/lib/header-attributes.js +4 -2
- package/lib/header-processing.js +2 -2
- package/lib/instrumentation/@hapi/hapi.js +2 -0
- package/lib/instrumentation/@node-redis/client.js +2 -0
- package/lib/instrumentation/amqplib.js +2 -0
- package/lib/instrumentation/core/async_hooks.js +2 -0
- package/lib/instrumentation/core/globals.js +11 -8
- package/lib/instrumentation/core/http-outbound.js +14 -12
- package/lib/instrumentation/core/http.js +10 -8
- package/lib/instrumentation/core/timers.js +2 -0
- package/lib/instrumentation/fastify.js +1 -3
- package/lib/instrumentation/grpc-js/grpc.js +14 -3
- package/lib/instrumentation/memcached.js +5 -0
- package/lib/instrumentation/mongodb/common.js +3 -0
- package/lib/instrumentation/mongodb/v2-mongo.js +6 -3
- package/lib/instrumentation/mongodb.js +1 -1
- package/lib/instrumentation/nr-winston-transport.js +3 -4
- package/lib/instrumentation/promise.js +7 -4
- package/lib/instrumentation/redis.js +2 -0
- package/lib/instrumentation/undici.js +2 -0
- package/lib/metrics/mapper.js +2 -3
- package/lib/metrics/metric-aggregator.js +1 -3
- package/lib/metrics/names.js +19 -15
- package/lib/metrics/normalizer/rule.js +6 -7
- package/lib/metrics/normalizer/tx_segment.js +3 -2
- package/lib/metrics/normalizer.js +5 -3
- package/lib/parse-proc-cpuinfo.js +11 -6
- package/lib/serverless/api-gateway.js +3 -4
- package/lib/serverless/aws-lambda.js +3 -3
- package/lib/shim/conglomerate-shim.js +2 -3
- package/lib/shim/datastore-shim.js +22 -104
- package/lib/shim/index.js +7 -0
- package/lib/shim/message-shim.js +2 -0
- package/lib/shim/promise-shim.js +48 -42
- package/lib/shim/shim.js +7 -7
- package/lib/shim/webframework-shim.js +2 -0
- package/lib/spans/map-to-streaming-type.js +0 -2
- package/lib/spans/span-context.js +2 -0
- package/lib/spans/span-event-aggregator.js +2 -2
- package/lib/spans/span-event.js +2 -2
- package/lib/spans/span-streamer.js +4 -0
- package/lib/spans/streaming-span-event-aggregator.js +2 -4
- package/lib/spans/streaming-span-event.js +3 -2
- package/lib/system-info.js +3 -5
- package/lib/timer.js +8 -6
- package/lib/transaction/dt-payload.js +4 -3
- package/lib/transaction/handle.js +12 -2
- package/lib/transaction/index.js +19 -18
- package/lib/transaction/name-state.js +17 -2
- package/lib/transaction/trace/aggregator.js +4 -12
- package/lib/transaction/trace/index.js +7 -5
- package/lib/transaction/trace/segment.js +6 -11
- package/lib/transaction/tracecontext.js +10 -6
- package/lib/transaction/tracer/index.js +23 -25
- package/lib/transaction/transaction-event-aggregator.js +1 -3
- package/lib/util/attribute-types.js +1 -2
- package/lib/util/byte-limit.js +1 -3
- package/lib/util/cat.js +16 -13
- package/lib/util/codec.js +0 -2
- package/lib/util/copy.js +1 -2
- package/lib/util/deep-equal.js +7 -0
- package/lib/util/flatten.js +4 -6
- package/lib/util/hashes.js +1 -3
- package/lib/util/process-version.js +2 -3
- package/lib/util/properties.js +2 -5
- package/lib/util/stream-sink.js +2 -0
- package/lib/util/urltils.js +4 -10
- package/newrelic.js +1 -1
- package/package.json +2 -1
package/lib/util/cat.js
CHANGED
|
@@ -32,9 +32,11 @@ const MATCH_CAT_APP_DATA_HEADER = new RegExp(
|
|
|
32
32
|
/**
|
|
33
33
|
* Decodes the CAT id and transaction headers from incoming request
|
|
34
34
|
*
|
|
35
|
-
* @param {
|
|
35
|
+
* @param {object} headers incoming headers
|
|
36
|
+
* @param id
|
|
37
|
+
* @param transactionId
|
|
36
38
|
* @param {string} encKey config.encoding_key used to decode CAT headers
|
|
37
|
-
* @param {
|
|
39
|
+
* @param {object} { externalId, externalTransaction }
|
|
38
40
|
*/
|
|
39
41
|
cat.parseCatData = function parseCatData(id, transactionId, encKey) {
|
|
40
42
|
if (!encKey) {
|
|
@@ -106,11 +108,11 @@ cat.assignCatToTransaction = function assignCatToTransaction(
|
|
|
106
108
|
* Encodes the data to be set on the CAT app data header
|
|
107
109
|
* for incoming requests
|
|
108
110
|
*
|
|
109
|
-
* @param {
|
|
111
|
+
* @param {object} config agent config
|
|
110
112
|
* @param {Transaction} transaction
|
|
111
113
|
* @param {string} contentLength
|
|
112
|
-
* @param {
|
|
113
|
-
* @
|
|
114
|
+
* @param {boolean} useMqHeaders flag to return proper headers for MQ compliance
|
|
115
|
+
* @returns {object} { key, data} to add as header
|
|
114
116
|
*/
|
|
115
117
|
cat.encodeAppData = function encodeAppData(config, transaction, contentLength, useMqHeaders) {
|
|
116
118
|
let appData = null
|
|
@@ -144,10 +146,10 @@ cat.encodeAppData = function encodeAppData(config, transaction, contentLength, u
|
|
|
144
146
|
/**
|
|
145
147
|
* Adds CAT headers to outbound request.
|
|
146
148
|
*
|
|
147
|
-
* @param {
|
|
149
|
+
* @param {object} config agent config
|
|
148
150
|
* @param {Transaction} transaction
|
|
149
|
-
* @param {
|
|
150
|
-
* @param {
|
|
151
|
+
* @param {object} headers object that contains headers the agent is adding to client request
|
|
152
|
+
* @param {boolean} useMqHeaders flag to return proper headers for MQ compliance
|
|
151
153
|
*/
|
|
152
154
|
cat.addCatHeaders = function addCatHeaders(config, transaction, headers, useMqHeaders) {
|
|
153
155
|
if (!config.encoding_key) {
|
|
@@ -189,8 +191,8 @@ cat.addCatHeaders = function addCatHeaders(config, transaction, headers, useMqHe
|
|
|
189
191
|
* Find the CAT id, transaction, app data headers
|
|
190
192
|
* from the headers of either HTTP or MQ request
|
|
191
193
|
*
|
|
192
|
-
* @param {
|
|
193
|
-
* @
|
|
194
|
+
* @param {object} headers
|
|
195
|
+
* @returns {object} { id, transactionId, appData }
|
|
194
196
|
*/
|
|
195
197
|
cat.extractCatHeaders = function extractCatHeaders(headers) {
|
|
196
198
|
// Hunt down the CAT headers.
|
|
@@ -218,9 +220,10 @@ cat.extractCatHeaders = function extractCatHeaders(headers) {
|
|
|
218
220
|
* Extracts the account Id from CAT data and verifies if it is
|
|
219
221
|
* a trusted account id
|
|
220
222
|
*
|
|
221
|
-
* @param {
|
|
223
|
+
* @param {object} CAT data
|
|
224
|
+
* @param data
|
|
222
225
|
* @param {Array} trustedAccounts from config
|
|
223
|
-
* @
|
|
226
|
+
* @returns {boolean}
|
|
224
227
|
*/
|
|
225
228
|
cat.isTrustedAccountId = function isTrustedAccountId(data, trustedAccounts) {
|
|
226
229
|
const accountId = parseInt(data.split('#')[0], 10)
|
|
@@ -235,7 +238,7 @@ cat.isTrustedAccountId = function isTrustedAccountId(data, trustedAccounts) {
|
|
|
235
238
|
* Decodes the CAT App Data header and extracts the downstream
|
|
236
239
|
* CAT id, transaction id
|
|
237
240
|
*
|
|
238
|
-
* @param {
|
|
241
|
+
* @param {object} config agent config
|
|
239
242
|
* @param {string} obfAppData encoded app data to parse and use
|
|
240
243
|
* @param {Array} decoded app data header
|
|
241
244
|
*/
|
package/lib/util/codec.js
CHANGED
|
@@ -16,7 +16,6 @@ module.exports = {
|
|
|
16
16
|
*
|
|
17
17
|
* @param {object} data
|
|
18
18
|
* The data to encode.
|
|
19
|
-
*
|
|
20
19
|
* @param {Function} callback
|
|
21
20
|
* The callback to take the results. The first parameter is any errors from
|
|
22
21
|
* encoding, and the second parameter is the encoded data object.
|
|
@@ -43,7 +42,6 @@ module.exports = {
|
|
|
43
42
|
*
|
|
44
43
|
* @param {object} encoded
|
|
45
44
|
* The data to decode.
|
|
46
|
-
*
|
|
47
45
|
* @param {Function} callback
|
|
48
46
|
* The callback to take the results. The first parameter is any errors from
|
|
49
47
|
* decoding, and the second parameter is the decoded data object.
|
package/lib/util/copy.js
CHANGED
|
@@ -14,8 +14,7 @@ exports.shallow = shallowCopy
|
|
|
14
14
|
*
|
|
15
15
|
* @param {object} source - The object to copy the properties from.
|
|
16
16
|
* @param {object} [dest={}] - The object to copy the properties to.
|
|
17
|
-
*
|
|
18
|
-
* @return {object} The destination object.
|
|
17
|
+
* @returns {object} The destination object.
|
|
19
18
|
*/
|
|
20
19
|
function shallowCopy(source, dest) {
|
|
21
20
|
dest = dest || Object.create(null)
|
package/lib/util/deep-equal.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 35] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
+
|
|
8
10
|
function isArguments(object) {
|
|
9
11
|
return Object.prototype.toString.call(object) === '[object Arguments]'
|
|
10
12
|
}
|
|
@@ -64,6 +66,11 @@ function slice(args) {
|
|
|
64
66
|
* object.
|
|
65
67
|
* o Users of this function are cool with mutually recursive data structures
|
|
66
68
|
* that are otherwise identical being treated as the same.
|
|
69
|
+
*
|
|
70
|
+
* @param a
|
|
71
|
+
* @param b
|
|
72
|
+
* @param ca
|
|
73
|
+
* @param cb
|
|
67
74
|
*/
|
|
68
75
|
function deeper(a, b, ca, cb) {
|
|
69
76
|
if (a === b) {
|
package/lib/util/flatten.js
CHANGED
|
@@ -14,12 +14,11 @@ exports.keys = flatKeys
|
|
|
14
14
|
* Ex: {a: 5, b: {c: true, d: 7}} -> {a: 5, 'b.c': true, 'b.d': 7}
|
|
15
15
|
*
|
|
16
16
|
* @private
|
|
17
|
-
*
|
|
18
17
|
* @param {object} result Object to place key-value pairs into, normally called with `{}`.
|
|
19
18
|
* @param {string} prefix Prefix for keys, normally called with `''`.
|
|
19
|
+
* @param seen
|
|
20
20
|
* @param {object} obj Object to be flattened.
|
|
21
|
-
*
|
|
22
|
-
* @return {object} Object with flattened key-value pairs
|
|
21
|
+
* @returns {object} Object with flattened key-value pairs
|
|
23
22
|
*/
|
|
24
23
|
function flatten(result, prefix, obj, seen) {
|
|
25
24
|
seen = seen || []
|
|
@@ -44,12 +43,11 @@ function flatten(result, prefix, obj, seen) {
|
|
|
44
43
|
* Retrieves all the keys that would exist in the flattened version of the object.
|
|
45
44
|
*
|
|
46
45
|
* @private
|
|
47
|
-
*
|
|
48
46
|
* @param {object} obj - The object to get the flat keys of.
|
|
49
47
|
* @param {string} prefix - A prefix for the keys, usually `''`.
|
|
48
|
+
* @param arrayIdxs
|
|
50
49
|
* @param {bool} arrayIdx - Flag indicating if array indexes should be iterated.
|
|
51
|
-
*
|
|
52
|
-
* @return {array.<string>} An array of keys names.
|
|
50
|
+
* @returns {Array.<string>} An array of keys names.
|
|
53
51
|
*/
|
|
54
52
|
function flatKeys(obj, prefix, arrayIdxs) {
|
|
55
53
|
const keys = []
|
package/lib/util/hashes.js
CHANGED
|
@@ -41,9 +41,7 @@ function calculatePathHash(appName, pathName, referingPathHash) {
|
|
|
41
41
|
const result = (rotated ^ hash) >>> 0
|
|
42
42
|
|
|
43
43
|
// This is a trick to pad it out to 8 chars regardless of length.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return retval
|
|
44
|
+
return ('00000000' + result.toString(16)).substr(-8)
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
function getHash(appName, txName) {
|
|
@@ -17,8 +17,7 @@ exports.prerelease = prerelease
|
|
|
17
17
|
* Safely checks if the process version satisfies the given semver range.
|
|
18
18
|
*
|
|
19
19
|
* @param {string} check - The semantic version range to check.
|
|
20
|
-
*
|
|
21
|
-
* @return {bool} True if the process version satisfies the given version, false
|
|
20
|
+
* @returns {bool} True if the process version satisfies the given version, false
|
|
22
21
|
* otherwise.
|
|
23
22
|
*/
|
|
24
23
|
function satisfies(check) {
|
|
@@ -33,7 +32,7 @@ function satisfies(check) {
|
|
|
33
32
|
/**
|
|
34
33
|
* Safely checks if the process version is a pre-release version.
|
|
35
34
|
*
|
|
36
|
-
* @
|
|
35
|
+
* @returns {bool} True if the process version is pre-release, false otherwise.
|
|
37
36
|
*/
|
|
38
37
|
function prerelease() {
|
|
39
38
|
try {
|
package/lib/util/properties.js
CHANGED
|
@@ -16,11 +16,9 @@ const hasOwnProperty = Object.hasOwnProperty
|
|
|
16
16
|
* property, thus avoiding the potential `undefined is not a function` error.
|
|
17
17
|
*
|
|
18
18
|
* @private
|
|
19
|
-
*
|
|
20
19
|
* @param {*} obj - The item to check for the property on.
|
|
21
20
|
* @param {string} key - The name of the property to look for.
|
|
22
|
-
*
|
|
23
|
-
* @return {bool} True if the given object has its own property with the given
|
|
21
|
+
* @returns {bool} True if the given object has its own property with the given
|
|
24
22
|
* key.
|
|
25
23
|
*/
|
|
26
24
|
exports.hasOwn = function hasOwn(obj, key) {
|
|
@@ -31,8 +29,7 @@ exports.hasOwn = function hasOwn(obj, key) {
|
|
|
31
29
|
* Checks if a given object is empty.
|
|
32
30
|
*
|
|
33
31
|
* @param {*} obj - The object to check for properties on.
|
|
34
|
-
*
|
|
35
|
-
* @return {bool} True if the object has no keys of its own.
|
|
32
|
+
* @returns {bool} True if the object has no keys of its own.
|
|
36
33
|
*/
|
|
37
34
|
exports.isEmpty = function isEmpty(obj) {
|
|
38
35
|
// Use this case for null prototyped objects.
|
package/lib/util/stream-sink.js
CHANGED
|
@@ -12,6 +12,8 @@ const util = require('util')
|
|
|
12
12
|
* Pipe a readable stream into this sink that fulfills the Writable Stream
|
|
13
13
|
* contract and the callback will be fired when the stream has been completely
|
|
14
14
|
* read.
|
|
15
|
+
*
|
|
16
|
+
* @param callback
|
|
15
17
|
*/
|
|
16
18
|
function StreamSink(callback) {
|
|
17
19
|
EventEmitter.call(this)
|
package/lib/util/urltils.js
CHANGED
|
@@ -25,7 +25,7 @@ module.exports = {
|
|
|
25
25
|
/**
|
|
26
26
|
* Dictionary whose keys are all synonyms for localhost.
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
28
|
+
* @constant
|
|
29
29
|
*/
|
|
30
30
|
LOCALHOST_NAMES: LOCALHOST_NAMES,
|
|
31
31
|
|
|
@@ -33,8 +33,7 @@ module.exports = {
|
|
|
33
33
|
* Checks if the given name is in the dictionary of localhost names.
|
|
34
34
|
*
|
|
35
35
|
* @param {string} host - The hostname to lookup.
|
|
36
|
-
*
|
|
37
|
-
* @return {bool} - True if the given hostname is a synonym for localhost.
|
|
36
|
+
* @returns {bool} - True if the given hostname is a synonym for localhost.
|
|
38
37
|
*/
|
|
39
38
|
isLocalhost: function isLocahost(host) {
|
|
40
39
|
return LOCALHOST_NAMES[host] != null
|
|
@@ -47,7 +46,6 @@ module.exports = {
|
|
|
47
46
|
*
|
|
48
47
|
* @param {Config} config The configuration containing the error list.
|
|
49
48
|
* @param {string} code The HTTP status code to check.
|
|
50
|
-
*
|
|
51
49
|
* @returns {bool} Whether the status code should be ignored.
|
|
52
50
|
*/
|
|
53
51
|
isError: function isError(config, code) {
|
|
@@ -59,7 +57,6 @@ module.exports = {
|
|
|
59
57
|
*
|
|
60
58
|
* @param {Config} config The configuration containing the error list.
|
|
61
59
|
* @param {string} code The HTTP status code to check.
|
|
62
|
-
*
|
|
63
60
|
* @returns {bool} Whether the status code should be ignored.
|
|
64
61
|
*/
|
|
65
62
|
isIgnoredError: function isIgnoredError(config, code) {
|
|
@@ -71,9 +68,7 @@ module.exports = {
|
|
|
71
68
|
*
|
|
72
69
|
* @param {Config} config The configuration containing the error list.
|
|
73
70
|
* @param {string} code The HTTP status code to check.
|
|
74
|
-
*
|
|
75
71
|
* @returns {bool} Whether the status code is expected.
|
|
76
|
-
*
|
|
77
72
|
*/
|
|
78
73
|
isExpectedError: function isExpectedError(config, code) {
|
|
79
74
|
return isExpectedStatusCodeForErrors(config, code)
|
|
@@ -88,7 +83,7 @@ module.exports = {
|
|
|
88
83
|
* 3. Remove trailing slash.
|
|
89
84
|
*
|
|
90
85
|
* @param {string} requestURL The URL fragment to be scrubbed.
|
|
91
|
-
* @
|
|
86
|
+
* @returns {string} The cleaned URL.
|
|
92
87
|
*/
|
|
93
88
|
scrub: function scrub(requestURL) {
|
|
94
89
|
if (typeof requestURL === 'string') {
|
|
@@ -153,8 +148,7 @@ module.exports = {
|
|
|
153
148
|
* only a single parse of the given URL.
|
|
154
149
|
*
|
|
155
150
|
* @param {string} requestURL - The URL to scrub and extra parameters from.
|
|
156
|
-
*
|
|
157
|
-
* @return {object} An object containing the scrubbed url at `.path` and the
|
|
151
|
+
* @returns {object} An object containing the scrubbed url at `.path` and the
|
|
158
152
|
* parsed parameters at `.parameters`.
|
|
159
153
|
*/
|
|
160
154
|
scrubAndParseParameters: function scrubAndParseParameters(requestURL) {
|
package/newrelic.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.0",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -213,6 +213,7 @@
|
|
|
213
213
|
"eslint-plugin-jsdoc": "^39.3.6",
|
|
214
214
|
"eslint-plugin-node": "^11.1.0",
|
|
215
215
|
"eslint-plugin-prettier": "^3.4.0",
|
|
216
|
+
"eslint-plugin-sonarjs": "^0.15.0",
|
|
216
217
|
"express": "*",
|
|
217
218
|
"glob": "^7.1.2",
|
|
218
219
|
"got": "^11.8.5",
|