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/NEWS.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
### v9.7.0 (2022-11-14)
|
|
2
|
+
|
|
3
|
+
* Added new configuration option, `grpc.ignore_status_codes`, which can be used to select nonzero gRPC status codes to ignore and not report as errors.
|
|
4
|
+
|
|
1
5
|
### v9.6.0 (2022-11-09)
|
|
2
6
|
|
|
3
7
|
* Dropped support for `vision`, and instead only instrument `@hapi/vision`.
|
package/api.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 21] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
+
|
|
8
10
|
const util = require('util')
|
|
9
11
|
const logger = require('./lib/logger').child({ component: 'api' })
|
|
10
12
|
const recordWeb = require('./lib/metrics/recorders/http')
|
package/bin/test-naming-rules.js
CHANGED
|
@@ -64,7 +64,7 @@ function run(opts) {
|
|
|
64
64
|
let appliedRules = []
|
|
65
65
|
|
|
66
66
|
// responsible for handling default rules provided by the server
|
|
67
|
-
const defaultNormalizer = loadDefaultNormalizer(config
|
|
67
|
+
const defaultNormalizer = loadDefaultNormalizer(config)
|
|
68
68
|
|
|
69
69
|
// rules defined by user in local configuration file
|
|
70
70
|
const userNormalizer = loadUserNormalizer(config, runtimeRules)
|
package/esm-loader.mjs
CHANGED
|
@@ -197,11 +197,9 @@ async function wrapEsmSource(url, specifier) {
|
|
|
197
197
|
const _wrappedModule = wrapModule(_originalModule, '${specifier}', '${trimmedUrl}')
|
|
198
198
|
${props
|
|
199
199
|
.map((propName) => {
|
|
200
|
-
|
|
200
|
+
return `
|
|
201
201
|
let _${propName} = _wrappedModule.${propName}
|
|
202
202
|
export { _${propName} as ${propName} }`
|
|
203
|
-
|
|
204
|
-
return propertyExportSource
|
|
205
203
|
})
|
|
206
204
|
.join('\n')}
|
|
207
205
|
`
|
package/lib/adaptive-sampler.js
CHANGED
|
@@ -79,8 +79,7 @@ class AdaptiveSampler {
|
|
|
79
79
|
* the number of objects sampled in this window.
|
|
80
80
|
*
|
|
81
81
|
* @param {number} roll - The number to compare against the threshold
|
|
82
|
-
*
|
|
83
|
-
* @return {bool} True if the object should be sampled.
|
|
82
|
+
* @returns {bool} True if the object should be sampled.
|
|
84
83
|
*/
|
|
85
84
|
shouldSample(roll) {
|
|
86
85
|
++this._seen
|
package/lib/agent.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 23] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
+
|
|
8
10
|
const AdaptiveSampler = require('./adaptive-sampler')
|
|
9
11
|
const CollectorAPI = require('./collector/api')
|
|
10
12
|
const ServerlessCollector = require('./collector/serverless')
|
|
@@ -76,7 +76,7 @@ class EventAggregator extends Aggregator {
|
|
|
76
76
|
/**
|
|
77
77
|
* Fetches all the span events aggregated.
|
|
78
78
|
*
|
|
79
|
-
* @
|
|
79
|
+
* @returns {Array.<Event>} An array of span events from the aggregator.
|
|
80
80
|
*/
|
|
81
81
|
getEvents() {
|
|
82
82
|
return this._items.toArray()
|
|
@@ -85,7 +85,7 @@ class EventAggregator extends Aggregator {
|
|
|
85
85
|
/**
|
|
86
86
|
* Resets the contents of the aggregator and all counters.
|
|
87
87
|
*
|
|
88
|
-
* @
|
|
88
|
+
* @returns {PriorityQueue} The old collection of aggregated events.
|
|
89
89
|
*/
|
|
90
90
|
clearEvents() {
|
|
91
91
|
// ???: might be more efficient to clear here and come up with an efficient way to
|
package/lib/attributes.js
CHANGED
|
@@ -22,7 +22,6 @@ class Attributes {
|
|
|
22
22
|
* @param {string} scope
|
|
23
23
|
* The scope of the attributes this will collect. Must be `transaction` or
|
|
24
24
|
* `segment`.
|
|
25
|
-
*
|
|
26
25
|
* @param {number} [limit=Infinity]
|
|
27
26
|
* The maximum number of attributes to retrieve for each destination.
|
|
28
27
|
*/
|
|
@@ -61,7 +60,7 @@ class Attributes {
|
|
|
61
60
|
* attributes allowed, no more than that number will be included in the result.
|
|
62
61
|
*
|
|
63
62
|
* @param {AttributeFilter.DESTINATIONS} dest
|
|
64
|
-
* @
|
|
63
|
+
* @returns {object}
|
|
65
64
|
*/
|
|
66
65
|
get(dest) {
|
|
67
66
|
const attrs = Object.create(null)
|
|
@@ -168,8 +167,7 @@ class Attributes {
|
|
|
168
167
|
* Creates a filter function for the given scope.
|
|
169
168
|
*
|
|
170
169
|
* @param {string} scope - The scope of the filter to make.
|
|
171
|
-
*
|
|
172
|
-
* @return {function} A function that performs attribute filtering for the given
|
|
170
|
+
* @returns {Function} A function that performs attribute filtering for the given
|
|
173
171
|
* scope.
|
|
174
172
|
*/
|
|
175
173
|
function makeFilter(scope) {
|
package/lib/collector/api.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 16] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
+
|
|
8
10
|
const CollectorResponse = require('./response')
|
|
9
11
|
const facts = require('./facts')
|
|
10
12
|
const logger = require('../logger').child({ component: 'collector_api' })
|
|
@@ -89,6 +91,10 @@ function CollectorAPI(agent) {
|
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
CollectorAPI.prototype._throwCallbackError = function _throwCallbackError() {
|
|
95
|
+
throw new TypeError('callback is required')
|
|
96
|
+
}
|
|
97
|
+
|
|
92
98
|
/**
|
|
93
99
|
* Updates all methods except preconnect w/ new host/port pairs sent down from server
|
|
94
100
|
* during preconnect (via redirect_host). Preconnect does not update.
|
|
@@ -107,7 +113,7 @@ CollectorAPI.prototype._updateEndpoints = function _updateEndpoints(endpoint) {
|
|
|
107
113
|
|
|
108
114
|
CollectorAPI.prototype.connect = function connect(callback) {
|
|
109
115
|
if (!callback) {
|
|
110
|
-
|
|
116
|
+
this._throwCallbackError()
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
logger.trace('Starting collector.')
|
|
@@ -376,7 +382,7 @@ CollectorAPI.prototype.reportSettings = function reportSettings(callback) {
|
|
|
376
382
|
*/
|
|
377
383
|
CollectorAPI.prototype.error_data = function errorData(errors, callback) {
|
|
378
384
|
if (!callback) {
|
|
379
|
-
|
|
385
|
+
this._throwCallbackError()
|
|
380
386
|
}
|
|
381
387
|
if (!errors) {
|
|
382
388
|
return callback(new TypeError('must pass errors to send'))
|
|
@@ -387,7 +393,7 @@ CollectorAPI.prototype.error_data = function errorData(errors, callback) {
|
|
|
387
393
|
|
|
388
394
|
CollectorAPI.prototype.error_event_data = function errorEvents(events, callback) {
|
|
389
395
|
if (!callback) {
|
|
390
|
-
|
|
396
|
+
this._throwCallbackError()
|
|
391
397
|
}
|
|
392
398
|
if (!events) {
|
|
393
399
|
return callback(new TypeError('must pass errors to send'))
|
|
@@ -403,7 +409,7 @@ CollectorAPI.prototype.analytic_event_data = transactionEvents
|
|
|
403
409
|
*/
|
|
404
410
|
function transactionEvents(events, callback) {
|
|
405
411
|
if (!callback) {
|
|
406
|
-
|
|
412
|
+
this._throwCallbackError()
|
|
407
413
|
}
|
|
408
414
|
if (!events) {
|
|
409
415
|
return callback(new TypeError('must pass events to send'))
|
|
@@ -414,7 +420,7 @@ function transactionEvents(events, callback) {
|
|
|
414
420
|
|
|
415
421
|
CollectorAPI.prototype.custom_event_data = function customEvents(events, callback) {
|
|
416
422
|
if (!callback) {
|
|
417
|
-
|
|
423
|
+
this._throwCallbackError()
|
|
418
424
|
}
|
|
419
425
|
if (!events) {
|
|
420
426
|
return callback(new TypeError('must pass events to send'))
|
|
@@ -441,7 +447,7 @@ CollectorAPI.prototype.custom_event_data = function customEvents(events, callbac
|
|
|
441
447
|
*/
|
|
442
448
|
CollectorAPI.prototype.metric_data = function metricData(metrics, callback) {
|
|
443
449
|
if (!callback) {
|
|
444
|
-
|
|
450
|
+
this._throwCallbackError()
|
|
445
451
|
}
|
|
446
452
|
if (!metrics) {
|
|
447
453
|
return callback(new TypeError('must pass metrics to send'))
|
|
@@ -464,7 +470,7 @@ CollectorAPI.prototype.metric_data = function metricData(metrics, callback) {
|
|
|
464
470
|
*/
|
|
465
471
|
CollectorAPI.prototype.sql_trace_data = function queryData(queries, callback) {
|
|
466
472
|
if (!callback) {
|
|
467
|
-
|
|
473
|
+
this._throwCallbackError()
|
|
468
474
|
}
|
|
469
475
|
if (!queries) {
|
|
470
476
|
return callback(new TypeError('must pass queries to send'))
|
|
@@ -474,7 +480,7 @@ CollectorAPI.prototype.sql_trace_data = function queryData(queries, callback) {
|
|
|
474
480
|
|
|
475
481
|
CollectorAPI.prototype.span_event_data = function spanEvents(events, callback) {
|
|
476
482
|
if (!callback) {
|
|
477
|
-
|
|
483
|
+
this._throwCallbackError()
|
|
478
484
|
}
|
|
479
485
|
if (!events) {
|
|
480
486
|
return callback(new TypeError('must pass spans to send'))
|
|
@@ -503,7 +509,7 @@ CollectorAPI.prototype.transaction_sample_data = transactionSampleData
|
|
|
503
509
|
*/
|
|
504
510
|
function transactionSampleData(traces, callback) {
|
|
505
511
|
if (!callback) {
|
|
506
|
-
|
|
512
|
+
this._throwCallbackError()
|
|
507
513
|
}
|
|
508
514
|
if (!traces) {
|
|
509
515
|
return callback(new TypeError('must pass traces to send'))
|
|
@@ -527,7 +533,7 @@ function transactionSampleData(traces, callback) {
|
|
|
527
533
|
*/
|
|
528
534
|
CollectorAPI.prototype.log_event_data = function logEventData(logRecords, callback) {
|
|
529
535
|
if (!callback) {
|
|
530
|
-
|
|
536
|
+
this._throwCallbackError()
|
|
531
537
|
}
|
|
532
538
|
if (!logRecords) {
|
|
533
539
|
return callback(new TypeError('must pass logRecords to send'))
|
|
@@ -545,7 +551,7 @@ CollectorAPI.prototype.log_event_data = function logEventData(logRecords, callba
|
|
|
545
551
|
*/
|
|
546
552
|
CollectorAPI.prototype.shutdown = function shutdown(callback) {
|
|
547
553
|
if (!callback) {
|
|
548
|
-
|
|
554
|
+
this._throwCallbackError()
|
|
549
555
|
}
|
|
550
556
|
|
|
551
557
|
logger.info('Shutting down collector.')
|
|
@@ -620,6 +626,7 @@ CollectorAPI.prototype._sendData = function _sendData(method, data, callback) {
|
|
|
620
626
|
|
|
621
627
|
// TODO: log the payload if exists?
|
|
622
628
|
|
|
629
|
+
/*
|
|
623
630
|
if (response.agentRun === AGENT_RUN_BEHAVIOR.SHUTDOWN) {
|
|
624
631
|
// TODO: for now, shut handled in _handleResponseCode for consistency
|
|
625
632
|
// either find way to safely change while side-by-side or move
|
|
@@ -635,7 +642,8 @@ CollectorAPI.prototype._sendData = function _sendData(method, data, callback) {
|
|
|
635
642
|
// })
|
|
636
643
|
|
|
637
644
|
callback(null, { retainData: response.retainData })
|
|
638
|
-
|
|
645
|
+
*/
|
|
646
|
+
if (response.agentRun === AGENT_RUN_BEHAVIOR.RESTART) {
|
|
639
647
|
// TODO: almost seems better to leg aggregator finish (cb) then restart?
|
|
640
648
|
|
|
641
649
|
// TODO: ensure harvesting stopped for all other endpoints. same for shutdown.
|
package/lib/collector/facts.js
CHANGED
|
@@ -142,13 +142,11 @@ function getAllIPAddresses() {
|
|
|
142
142
|
* @param appNames
|
|
143
143
|
*/
|
|
144
144
|
function getIdentifierOverride(appNames) {
|
|
145
|
-
|
|
145
|
+
return [
|
|
146
146
|
'nodejs',
|
|
147
147
|
// NOTE: The concat is necessary to prevent sort from happening in-place.
|
|
148
148
|
appNames.concat([]).sort().join(',')
|
|
149
149
|
].join(':')
|
|
150
|
-
|
|
151
|
-
return identifier
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
/**
|
|
@@ -22,7 +22,9 @@ const logger = require('../logger').child({ component: 'new_relic_response' })
|
|
|
22
22
|
* error, the value returned by the server
|
|
23
23
|
* (if any), and the raw JSON of the
|
|
24
24
|
* server's response.
|
|
25
|
-
*
|
|
25
|
+
* @param name
|
|
26
|
+
* @param response
|
|
27
|
+
* @param callback
|
|
26
28
|
* @returns Function Another callback that is meant to be invoked with
|
|
27
29
|
* any errors from reading the response stream, as
|
|
28
30
|
* well as a string containing the full response.
|
|
@@ -250,12 +250,13 @@ RemoteMethod.prototype._safeRequest = function _safeRequest(options) {
|
|
|
250
250
|
|
|
251
251
|
// If trace level is not explicitly enabled check to see if the audit log is
|
|
252
252
|
// enabled.
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
253
|
+
if (
|
|
254
|
+
logConfig != null &&
|
|
255
|
+
logConfig.level !== 'trace' &&
|
|
256
|
+
auditLog.enabled &&
|
|
257
|
+
(auditLog.endpoints.length === 0 || auditLog.endpoints.indexOf(this.name) > -1)
|
|
258
|
+
) {
|
|
259
|
+
level = 'info'
|
|
259
260
|
}
|
|
260
261
|
|
|
261
262
|
const logBody = Buffer.isBuffer(options.body) ? 'Buffer ' + options.body.length : options.body
|
|
@@ -349,12 +350,10 @@ RemoteMethod.prototype._path = function _path() {
|
|
|
349
350
|
query[RUN_ID_NAME] = this._config.run_id
|
|
350
351
|
}
|
|
351
352
|
|
|
352
|
-
|
|
353
|
+
return url.format({
|
|
353
354
|
pathname: RAW_METHOD_PATH,
|
|
354
355
|
query: query
|
|
355
356
|
})
|
|
356
|
-
|
|
357
|
-
return formatted
|
|
358
357
|
}
|
|
359
358
|
|
|
360
359
|
/**
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 16] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
+
|
|
8
10
|
const NO_MATCH = -Infinity
|
|
9
11
|
const EXACT_MATCH = Infinity
|
|
10
12
|
const DESTINATIONS = {
|
|
@@ -52,7 +54,6 @@ exports.DESTINATIONS = DESTINATIONS
|
|
|
52
54
|
*
|
|
53
55
|
* @class
|
|
54
56
|
* @private
|
|
55
|
-
*
|
|
56
57
|
* @param {Config} config - The configuration object for the agent.
|
|
57
58
|
*/
|
|
58
59
|
function AttributeFilter(config) {
|
|
@@ -87,8 +88,7 @@ function AttributeFilter(config) {
|
|
|
87
88
|
*
|
|
88
89
|
* @param {DESTINATIONS} destinations - The locations the attribute wants to be put.
|
|
89
90
|
* @param {string} key - The name of the attribute to test.
|
|
90
|
-
*
|
|
91
|
-
* @return {DESTINATIONS} The destinations the attribute should be put.
|
|
91
|
+
* @returns {DESTINATIONS} The destinations the attribute should be put.
|
|
92
92
|
*/
|
|
93
93
|
AttributeFilter.prototype.filterTransaction = filterTransaction
|
|
94
94
|
function filterTransaction(destinations, key) {
|
|
@@ -100,8 +100,7 @@ function filterTransaction(destinations, key) {
|
|
|
100
100
|
*
|
|
101
101
|
* @param {DESTINATIONS} destinations - The locations the attribute wants to be put.
|
|
102
102
|
* @param {string} key - The name of the attribute to test.
|
|
103
|
-
*
|
|
104
|
-
* @return {DESTINATIONS} The destinations the attribute should be put.
|
|
103
|
+
* @returns {DESTINATIONS} The destinations the attribute should be put.
|
|
105
104
|
*/
|
|
106
105
|
AttributeFilter.prototype.filterSegment = function filterSegment(destinations, key) {
|
|
107
106
|
return this._filter(SEGMENT_SCOPE_DETAILS, destinations, key)
|
|
@@ -112,8 +111,7 @@ AttributeFilter.prototype.filterSegment = function filterSegment(destinations, k
|
|
|
112
111
|
*
|
|
113
112
|
* @param {DESTINATIONS} destinations - The locations the attribute wants to be put.
|
|
114
113
|
* @param {string} key - The name of the attribute to test.
|
|
115
|
-
*
|
|
116
|
-
* @return {DESTINATIONS} The destinations the attribute should be put.
|
|
114
|
+
* @returns {DESTINATIONS} The destinations the attribute should be put.
|
|
117
115
|
*/
|
|
118
116
|
AttributeFilter.prototype.filterAll = function filterSegment(destinations, key) {
|
|
119
117
|
return this._filter(DESTINATION_DETAILS, destinations, key)
|
|
@@ -122,11 +120,10 @@ AttributeFilter.prototype.filterAll = function filterSegment(destinations, key)
|
|
|
122
120
|
/**
|
|
123
121
|
* Tests a given key against the global and destination filters.
|
|
124
122
|
*
|
|
125
|
-
* @param {
|
|
123
|
+
* @param {Array} scope - The destination details for filtering.
|
|
126
124
|
* @param {DESTINATIONS} destinations - The locations the attribute wants to be put.
|
|
127
125
|
* @param {string} key - The name of the attribute to test.
|
|
128
|
-
*
|
|
129
|
-
* @return {DESTINATIONS} The destinations the attribute should be put.
|
|
126
|
+
* @returns {DESTINATIONS} The destinations the attribute should be put.
|
|
130
127
|
*/
|
|
131
128
|
AttributeFilter.prototype._filter = function _filter(scope, destinations, key) {
|
|
132
129
|
// This method could be easily memoized since for a given destination and key
|
|
@@ -212,9 +209,12 @@ AttributeFilter.prototype.update = function update() {
|
|
|
212
209
|
/**
|
|
213
210
|
* Applies the global and destination rules to this key.
|
|
214
211
|
*
|
|
212
|
+
* @param globalInclude
|
|
213
|
+
* @param globalExclude
|
|
214
|
+
* @param destConfig
|
|
215
|
+
* @param key
|
|
215
216
|
* @private
|
|
216
|
-
*
|
|
217
|
-
* @return {bool|number} True if this key is explicitly included, false if it is
|
|
217
|
+
* @returns {bool|number} True if this key is explicitly included, false if it is
|
|
218
218
|
* explicitly excluded, or `NO_MATCH` if no rule applies.
|
|
219
219
|
*/
|
|
220
220
|
function _doTest(globalInclude, globalExclude, destConfig, key) {
|
|
@@ -289,10 +289,8 @@ function _matchRules(rules, key) {
|
|
|
289
289
|
* Converts the raw rules into a set of regular expressions to test against.
|
|
290
290
|
*
|
|
291
291
|
* @private
|
|
292
|
-
*
|
|
293
|
-
* @
|
|
294
|
-
*
|
|
295
|
-
* @return {object} An object with `exact` and `wildcard` properties which are
|
|
292
|
+
* @param {Array.<string>} rules - The set of rules to compose.
|
|
293
|
+
* @returns {object} An object with `exact` and `wildcard` properties which are
|
|
296
294
|
* `RegExp` instances for testing keys.
|
|
297
295
|
*/
|
|
298
296
|
function _importRules(rules) {
|
package/lib/config/default.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 17] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252*/
|
|
9
|
+
|
|
8
10
|
const defaultConfig = module.exports
|
|
9
11
|
const { array, int, float, boolean, object, objectList, allowList } = require('./formatters')
|
|
10
12
|
|
|
@@ -936,6 +938,21 @@ defaultConfig.definition = () => ({
|
|
|
936
938
|
record_errors: {
|
|
937
939
|
formatter: boolean,
|
|
938
940
|
default: true
|
|
941
|
+
},
|
|
942
|
+
/**
|
|
943
|
+
* List of gRPC error status codes the error tracer should disregard.
|
|
944
|
+
* Ignoring a status code means that the transaction is not renamed to
|
|
945
|
+
* match the code, and the request is not treated as an error by the error
|
|
946
|
+
* collector.
|
|
947
|
+
*
|
|
948
|
+
* NOTE: This configuration value has no effect on errors recorded using
|
|
949
|
+
* `noticeError()`.
|
|
950
|
+
*
|
|
951
|
+
* Defaults to no codes ignored.
|
|
952
|
+
*/
|
|
953
|
+
ignore_status_codes: {
|
|
954
|
+
formatter: array,
|
|
955
|
+
default: []
|
|
939
956
|
}
|
|
940
957
|
},
|
|
941
958
|
/**
|
|
@@ -12,17 +12,15 @@ function isValidHarvestConfig(harvestConfig) {
|
|
|
12
12
|
|
|
13
13
|
const harvestLimits = harvestConfig.harvest_limits
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
return (
|
|
16
16
|
isValidHarvestValue(harvestConfig.report_period_ms) &&
|
|
17
17
|
harvestLimits != null &&
|
|
18
18
|
Object.keys(harvestLimits).length > 0
|
|
19
|
-
|
|
20
|
-
return isValid
|
|
19
|
+
)
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
function isValidHarvestValue(value) {
|
|
24
|
-
|
|
25
|
-
return !!isValid
|
|
23
|
+
return !!(value != null && value >= 0)
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
module.exports = {
|
package/lib/config/index.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 29] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
+
/* eslint sonarjs/max-switch-cases: ["error", 36] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
10
|
+
|
|
8
11
|
const AttributeFilter = require('./attribute-filter')
|
|
9
12
|
const CollectorResponse = require('../collector/response')
|
|
10
13
|
const copy = require('../util/copy')
|
|
@@ -37,6 +40,7 @@ const HAS_ARBITRARY_KEYS = new Set(['ignore_messages', 'expected_messages', 'lab
|
|
|
37
40
|
const LASP_MAP = require('./lasp').LASP_MAP
|
|
38
41
|
const HSM = require('./hsm')
|
|
39
42
|
const REMOVE_BEFORE_SEND = new Set(['attributeFilter'])
|
|
43
|
+
const SSL_WARNING = 'SSL config key can no longer be disabled, not updating.'
|
|
40
44
|
|
|
41
45
|
const exists = fs.existsSync
|
|
42
46
|
let logger = null // Lazy-loaded in `initialize`.
|
|
@@ -305,7 +309,7 @@ Config.prototype._fromServer = function _fromServer(params, key) {
|
|
|
305
309
|
|
|
306
310
|
case 'ssl':
|
|
307
311
|
if (!isTruthular(params.ssl)) {
|
|
308
|
-
logger.warn(
|
|
312
|
+
logger.warn(SSL_WARNING)
|
|
309
313
|
}
|
|
310
314
|
break
|
|
311
315
|
|
|
@@ -963,7 +967,7 @@ Config.prototype._fromPassed = function _fromPassed(external, internal, arbitrar
|
|
|
963
967
|
}
|
|
964
968
|
|
|
965
969
|
if (key === 'ssl' && !isTruthular(external.ssl)) {
|
|
966
|
-
logger.warn(
|
|
970
|
+
logger.warn(SSL_WARNING)
|
|
967
971
|
return
|
|
968
972
|
}
|
|
969
973
|
|
|
@@ -1033,8 +1037,7 @@ Config.prototype._featureFlagsFromEnv = function _featureFlagsFromEnv() {
|
|
|
1033
1037
|
function deriveEnvVar(key, paths) {
|
|
1034
1038
|
let path = paths.join('_')
|
|
1035
1039
|
path = path ? `${path}_` : path
|
|
1036
|
-
|
|
1037
|
-
return envKey
|
|
1040
|
+
return `NEW_RELIC_${path.toUpperCase()}${key.toUpperCase()}`
|
|
1038
1041
|
}
|
|
1039
1042
|
|
|
1040
1043
|
/**
|
package/lib/environment.js
CHANGED
|
@@ -10,6 +10,7 @@ const { fsPromises } = require('./util/unwrapped-core')
|
|
|
10
10
|
const os = require('os')
|
|
11
11
|
const logger = require('./logger').child({ component: 'environment' })
|
|
12
12
|
const stringify = require('json-stringify-safe')
|
|
13
|
+
const DISPATCHER_VERSION = 'Dispatcher Version'
|
|
13
14
|
|
|
14
15
|
// As of 1.7.0 you can no longer dynamically link v8
|
|
15
16
|
// https://github.com/nodejs/io.js/commit/d726a177ed
|
|
@@ -418,7 +419,7 @@ function refreshSyncOnly() {
|
|
|
418
419
|
// gather persisted settings
|
|
419
420
|
const framework = getSetting('Framework')
|
|
420
421
|
const dispatcher = getSetting('Dispatcher')
|
|
421
|
-
const dispatcherVersion = getSetting(
|
|
422
|
+
const dispatcherVersion = getSetting(DISPATCHER_VERSION)
|
|
422
423
|
|
|
423
424
|
// clearing and rebuilding a global variable
|
|
424
425
|
settings = Object.create(null)
|
|
@@ -437,7 +438,7 @@ function refreshSyncOnly() {
|
|
|
437
438
|
|
|
438
439
|
if (dispatcherVersion.length) {
|
|
439
440
|
dispatcher.forEach(function addDispatchers(d) {
|
|
440
|
-
addSetting(
|
|
441
|
+
addSetting(DISPATCHER_VERSION, d)
|
|
441
442
|
})
|
|
442
443
|
}
|
|
443
444
|
|
|
@@ -503,12 +504,12 @@ module.exports = {
|
|
|
503
504
|
}
|
|
504
505
|
|
|
505
506
|
userSetDispatcher = !!userSet
|
|
506
|
-
clearSetting(
|
|
507
|
+
clearSetting(DISPATCHER_VERSION)
|
|
507
508
|
clearSetting('Dispatcher')
|
|
508
509
|
|
|
509
510
|
// TODO: Decide if this should only happen once for internals as well.
|
|
510
511
|
if (version) {
|
|
511
|
-
addSetting(
|
|
512
|
+
addSetting(DISPATCHER_VERSION, version)
|
|
512
513
|
}
|
|
513
514
|
|
|
514
515
|
addSetting('Dispatcher', dispatcher)
|
|
@@ -520,7 +521,7 @@ module.exports = {
|
|
|
520
521
|
// This method is only used for tests.
|
|
521
522
|
userSetDispatcher = false
|
|
522
523
|
clearSetting('Dispatcher')
|
|
523
|
-
clearSetting(
|
|
524
|
+
clearSetting(DISPATCHER_VERSION)
|
|
524
525
|
},
|
|
525
526
|
listPackages,
|
|
526
527
|
getJSON,
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 25] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
+
|
|
8
10
|
const errorsModule = require('./index')
|
|
9
11
|
|
|
10
12
|
const logger = require('../logger').child({ component: 'error_tracer' })
|
|
@@ -112,8 +114,7 @@ class ErrorCollector {
|
|
|
112
114
|
* possible.
|
|
113
115
|
*
|
|
114
116
|
* @param {Transaction} transaction
|
|
115
|
-
*
|
|
116
|
-
* @return {number} The number of unexpected errors
|
|
117
|
+
* @returns {number} The number of unexpected errors
|
|
117
118
|
*/
|
|
118
119
|
onTransactionFinished(transaction) {
|
|
119
120
|
if (!transaction) {
|
|
@@ -226,6 +227,8 @@ class ErrorCollector {
|
|
|
226
227
|
*
|
|
227
228
|
* @param {?Transaction} transaction Transaction associated with the error.
|
|
228
229
|
* @param {Exception} exception The Exception to be traced.
|
|
230
|
+
* @param error
|
|
231
|
+
* @param customAttributes
|
|
229
232
|
*/
|
|
230
233
|
addUserError(transaction, error, customAttributes) {
|
|
231
234
|
if (!error) {
|
|
@@ -260,7 +263,7 @@ class ErrorCollector {
|
|
|
260
263
|
*
|
|
261
264
|
* @param {?Transaction} transaction Transaction associated with the error.
|
|
262
265
|
* @param {?Exception} exception The Exception object to be traced.
|
|
263
|
-
* @
|
|
266
|
+
* @returns {bool} True if the error was collected.
|
|
264
267
|
*/
|
|
265
268
|
collect(transaction, exception) {
|
|
266
269
|
if (!exception) {
|
package/lib/errors/helper.js
CHANGED
|
@@ -21,20 +21,17 @@ module.exports = {
|
|
|
21
21
|
if (!config.error_collector.expected_messages[type]) {
|
|
22
22
|
return false
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return false
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
config.error_collector.expected_messages[type].length > 0 &&
|
|
27
|
+
config.error_collector.expected_messages[type].indexOf(message) !== -1
|
|
28
|
+
)
|
|
30
29
|
},
|
|
31
30
|
isExpectedErrorClass: function isExpectedErrorClass(config, className) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
return false
|
|
31
|
+
return (
|
|
32
|
+
config.error_collector.expected_classes.length > 0 &&
|
|
33
|
+
config.error_collector.expected_classes.indexOf(className) !== -1
|
|
34
|
+
)
|
|
38
35
|
},
|
|
39
36
|
isExpectedException: function isExpectedException(transaction, exception, config, urltils) {
|
|
40
37
|
const { type, message } = this.extractErrorInformation(transaction, exception, config, urltils)
|
|
@@ -123,11 +120,6 @@ module.exports = {
|
|
|
123
120
|
return false
|
|
124
121
|
}
|
|
125
122
|
|
|
126
|
-
|
|
127
|
-
if (-1 !== configIgnoreMessages.indexOf(errorInfo.message)) {
|
|
128
|
-
return true
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return false
|
|
123
|
+
return configIgnoreMessages.length > 0 && configIgnoreMessages.indexOf(errorInfo.message) !== -1
|
|
132
124
|
}
|
|
133
125
|
}
|