newrelic 6.13.1 → 7.0.1

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 CHANGED
@@ -1,4 +1,83 @@
1
- ## 6.13.1 (2020-09-24):
1
+ ### 7.0.1 (2020-11-07):
2
+
3
+ * Fixed a bug where spans queued up during backpressure situations would be improperly formatted and ultimately dropped when sent to an Infinite Tracing trace observer.
4
+ * Updated @grpc/grpc-js to version v1.2.0.
5
+ * Updated tap to clear up npm audit issues around lodash sub-dependency.
6
+
7
+ ### 7.0.0 (2020-11-09):
8
+
9
+ * Added official parity support for Node 14
10
+
11
+ * Dropped Node v8.x support. For further information on our support policy,
12
+ see: https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent.
13
+ * Removed Node v8.x from CI
14
+ * Adds check that minimum Node version is >=10 and warns if >=15
15
+ * Sets Node engine to >=10
16
+ * **BREAKING** Dropped support for Node v8.x HTTP get() function signature
17
+ * strictly uses global.URL class in http core instrumentation
18
+ * removes Nodejs 8.x - 9.x checks
19
+ * Update New Relic Dependencies to versions with updated Node version support
20
+ * @newrelic/aws-sdk v3.0.0
21
+ * @newrelic/koa v5.0.0
22
+ * @newrelic/native-metrics v6.0.0
23
+ * @newrelic/superagent v4.0.0
24
+ * @newrelic/test-utilities v5.0.0
25
+
26
+ * **BREAKING** Removed deprecated setIgnoreTransaction API method
27
+
28
+ * **BREAKING** Removed deprecated httpResponseCode, response.status and
29
+ httpResponseMessage http response attributes
30
+
31
+ * **BREAKING** Removed the api.custom_parameters_enabled configuration item and
32
+ associated environment variable NEW_RELIC_API_CUSTOM_PARAMETERS. Please use
33
+ api.custom_attributes_enabled instead
34
+
35
+ * **BREAKING** Removed deprecated Distributed Tracing API methods,
36
+ createDistributedTracePayload() and acceptDistributedTracePayload()
37
+
38
+ * Finalized removal of ignored_params and capture_params
39
+
40
+ * Added additional logging to W3C Trace Context header creation
41
+
42
+ ### 6.14.0 (2020-10-28):
43
+
44
+ * Updated README for consistency.
45
+
46
+ * Fixed issue where gRPC connection used for infinite tracing could throw if the server
47
+ shutdown during disconnect of an existing connection.
48
+
49
+ * Bumped @grpc/grpc-js to 1.1.7.
50
+
51
+ * Bumped @grpc/proto-loader to ^0.5.5.
52
+
53
+ * Infinite tracing logging and support metric improvements.
54
+
55
+ * Increased logging level of certain infinite tracing / gRPC errors.
56
+ * Decreased logging interval of dropped span warning for infinite tracing.
57
+ * Added additional support metrics and logging for infinite tracing.
58
+
59
+ * Fixed bug where errors would still be collected for transactions with ignored error
60
+ status codes in certain situations.
61
+
62
+ * Converted errors ignore unit tests to tap API.
63
+
64
+ * Added Node 14 to CI test coverage.
65
+
66
+ Many thanks to @jgeurts for the contribution.
67
+
68
+ ### 6.13.2 (2020-10-13):
69
+
70
+ * Removed lodash as a development dependency
71
+
72
+ * Check for named pipe existence before each flush
73
+
74
+ This removes the cached value used in 6.13.1
75
+
76
+ * Update shim documentation
77
+
78
+ Thank you to @ronen-e for the contribution!
79
+
80
+ ### 6.13.1 (2020-09-24):
2
81
 
3
82
  * Fixed named-pipe check for lambda invocations to avoid race-condition.
4
83
 
package/README.md CHANGED
@@ -10,7 +10,7 @@ In order to take full advantage of this package, make sure you have a [New Relic
10
10
 
11
11
  As with any instrumentation tool, please test before using in production.
12
12
 
13
- ## Installation and getting started
13
+ ## Installation
14
14
 
15
15
  To use New Relic's Node.js agent entails these three steps, which are described in detail below:
16
16
 
@@ -57,9 +57,13 @@ If you're compiling your JavaScript and can't control the final `require` order,
57
57
  $ node -r newrelic your-program.js
58
58
  $ node --require newrelic your-program.js
59
59
 
60
+ ## Getting Started
61
+
60
62
  For more information on getting started, [check the Node.js docs](https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/introduction-new-relic-nodejs).
61
63
 
62
- ## Using the API
64
+ ## Usage
65
+
66
+ ### Using the API
63
67
 
64
68
  The `newrelic` module returns an object with the Node agent's API methods attached.
65
69
 
@@ -72,7 +76,7 @@ The `newrelic` module returns an object with the Node agent's API methods attach
72
76
 
73
77
  You can read more about using the API over on the [New Relic documentation](https://docs.newrelic.com/docs/agents/nodejs-agent/api-guides/guide-using-nodejs-agent-api) site.
74
78
 
75
- ## Core agent development and tests
79
+ ## Testing
76
80
 
77
81
  These are the steps to work on core agent features, with more detail below:
78
82
 
@@ -149,17 +153,22 @@ Please review [New Relic’s General Data Privacy Notice](https://newrelic.com/t
149
153
 
150
154
  See our [roadmap](./ROADMAP_Node.md), to learn more about our product vision, understand our plans, and provide us valuable feedback.
151
155
 
152
- ## Contributing
156
+ ## Contribute
153
157
 
154
158
  We encourage your contributions to improve the Node.js agent! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.
159
+
155
160
  If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
156
161
 
157
162
  **A note about vulnerabilities**
158
163
 
159
- As noted in our [security policy](https://github.com/newrelic/node-newrelic/security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
164
+ As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
160
165
 
161
166
  If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [HackerOne](https://hackerone.com/newrelic).
162
167
 
168
+ If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).
169
+
170
+ To [all contributors](https://github.com/newrelic/node-newrelic/graphs/contributors), we thank you! Without your contribution, this project would not be what it is today. We also host a community project page dedicated to [New Relic Node Agent](https://opensource.newrelic.com/projects/newrelic/node-newrelic).
171
+
163
172
  ## License
164
173
 
165
174
  The Node.js agent is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
@@ -48,7 +48,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
48
48
  * [got](#got)
49
49
  * [http-errors](#http-errors)
50
50
  * [jsdoc](#jsdoc)
51
- * [lodash](#lodash)
52
51
  * [memcached](#memcached)
53
52
  * [minami](#minami)
54
53
  * [mongodb](#mongodb)
@@ -69,15 +68,12 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
69
68
  * [through](#through)
70
69
  * [when](#when)
71
70
 
72
- **[additional-licenses](#additional-licenses)**
73
-
74
- * [symantec](#symantec)
75
71
 
76
72
  ## dependencies
77
73
 
78
74
  ### @grpc/grpc-js
79
75
 
80
- This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.0.5](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.0.5)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.0.5/LICENSE):
76
+ This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.2.0](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.2.0)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.2.0/LICENSE):
81
77
 
82
78
  ```
83
79
  Apache License
@@ -286,7 +282,7 @@ This product includes source derived from [@grpc/grpc-js](https://github.com/grp
286
282
 
287
283
  ### @grpc/proto-loader
288
284
 
289
- This product includes source derived from [@grpc/proto-loader](https://github.com/grpc/grpc-node) ([v0.5.4](https://github.com/grpc/grpc-node/tree/v0.5.4)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/blob/v0.5.4/LICENSE):
285
+ This product includes source derived from [@grpc/proto-loader](https://github.com/grpc/grpc-node) ([v0.5.5](https://github.com/grpc/grpc-node/tree/v0.5.5)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/blob/v0.5.5/LICENSE):
290
286
 
291
287
  ```
292
288
  Apache License
@@ -495,7 +491,7 @@ This product includes source derived from [@grpc/proto-loader](https://github.co
495
491
 
496
492
  ### @newrelic/aws-sdk
497
493
 
498
- This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v2.0.0](https://github.com/newrelic/node-newrelic-aws-sdk/tree/v2.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-aws-sdk/blob/v2.0.0/LICENSE):
494
+ This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v3.0.0](https://github.com/newrelic/node-newrelic-aws-sdk/tree/v3.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-aws-sdk/blob/v3.0.0/LICENSE):
499
495
 
500
496
  ```
501
497
  Apache License
@@ -703,7 +699,7 @@ This product includes source derived from [@newrelic/aws-sdk](https://github.com
703
699
 
704
700
  ### @newrelic/koa
705
701
 
706
- This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v4.0.0](https://github.com/newrelic/node-newrelic-koa/tree/v4.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v4.0.0/LICENSE):
702
+ This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v5.0.0](https://github.com/newrelic/node-newrelic-koa/tree/v5.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v5.0.0/LICENSE):
707
703
 
708
704
  ```
709
705
  Apache License
@@ -912,7 +908,7 @@ Apache License
912
908
 
913
909
  ### @newrelic/superagent
914
910
 
915
- This product includes source derived from [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent) ([v3.0.0](https://github.com/newrelic/node-newrelic-superagent/tree/v3.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-superagent/blob/v3.0.0/LICENSE):
911
+ This product includes source derived from [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent) ([v4.0.0](https://github.com/newrelic/node-newrelic-superagent/tree/v4.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-superagent/blob/v4.0.0/LICENSE):
916
912
 
917
913
  ```
918
914
  Apache License
@@ -1324,7 +1320,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1324
1320
  ## optionalDependencies
1325
1321
 
1326
1322
  ### @newrelic/native-metrics
1327
- This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v5.3.0](https://github.com/newrelic/node-native-metrics/tree/v5.3.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v5.3.0/LICENSE):
1323
+ This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v6.0.0](https://github.com/newrelic/node-native-metrics/tree/v6.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v6.0.0/LICENSE):
1328
1324
 
1329
1325
  ```
1330
1326
  Apache License
@@ -1549,7 +1545,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1549
1545
 
1550
1546
  ### @newrelic/test-utilities
1551
1547
 
1552
- This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v4.0.0](https://github.com/newrelic/node-test-utilities/tree/v4.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v4.0.0/LICENSE):
1548
+ This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v5.0.0](https://github.com/newrelic/node-test-utilities/tree/v5.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v5.0.0/LICENSE):
1553
1549
 
1554
1550
  ```
1555
1551
  Apache License
@@ -2197,61 +2193,6 @@ https://github.com/jmblog/color-themes-for-google-code-prettify
2197
2193
 
2198
2194
  ```
2199
2195
 
2200
- ### lodash
2201
-
2202
- This product includes source derived from [lodash](https://github.com/lodash/lodash) ([v4.17.15](https://github.com/lodash/lodash/tree/v4.17.15)), distributed under the [MIT License](https://github.com/lodash/lodash/blob/v4.17.15/LICENSE):
2203
-
2204
- ```
2205
- Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
2206
-
2207
- Based on Underscore.js, copyright Jeremy Ashkenas,
2208
- DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
2209
-
2210
- This software consists of voluntary contributions made by many
2211
- individuals. For exact contribution history, see the revision history
2212
- available at https://github.com/lodash/lodash
2213
-
2214
- The following license applies to all parts of this software except as
2215
- documented below:
2216
-
2217
- ====
2218
-
2219
- Permission is hereby granted, free of charge, to any person obtaining
2220
- a copy of this software and associated documentation files (the
2221
- "Software"), to deal in the Software without restriction, including
2222
- without limitation the rights to use, copy, modify, merge, publish,
2223
- distribute, sublicense, and/or sell copies of the Software, and to
2224
- permit persons to whom the Software is furnished to do so, subject to
2225
- the following conditions:
2226
-
2227
- The above copyright notice and this permission notice shall be
2228
- included in all copies or substantial portions of the Software.
2229
-
2230
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2231
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2232
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2233
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2234
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2235
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2236
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2237
-
2238
- ====
2239
-
2240
- Copyright and related rights for sample code are waived via CC0. Sample
2241
- code is defined as all source code displayed within the prose of the
2242
- documentation.
2243
-
2244
- CC0: http://creativecommons.org/publicdomain/zero/1.0/
2245
-
2246
- ====
2247
-
2248
- Files located in the node_modules and vendor directories are externally
2249
- maintained libraries used by this software which have their own
2250
- licenses; we recommend you read them, as their terms may differ from the
2251
- terms above.
2252
-
2253
- ```
2254
-
2255
2196
  ### memcached
2256
2197
 
2257
2198
  This product includes source derived from [memcached](https://github.com/3rd-Eden/node-memcached) ([v2.2.2](https://github.com/3rd-Eden/node-memcached/tree/v2.2.2)), distributed under the [MIT License](https://github.com/3rd-Eden/node-memcached/blob/v2.2.2/LICENSE):
@@ -2944,7 +2885,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2944
2885
 
2945
2886
  ### tap
2946
2887
 
2947
- This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v14.10.7](https://github.com/tapjs/node-tap/tree/v14.10.7)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v14.10.7/LICENSE):
2888
+ This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v14.10.8](https://github.com/tapjs/node-tap/tree/v14.10.8)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v14.10.8/LICENSE):
2948
2889
 
2949
2890
  ```
2950
2891
  The ISC License
@@ -3056,6 +2997,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
3056
2997
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3057
2998
  ```
3058
2999
 
3000
+
3059
3001
  ## additional-licenses
3060
3002
 
3061
3003
  ### symantec
@@ -3260,4 +3202,4 @@ Root Certificate License Agreement v3.0 (January 2014)
3260
3202
  Portions copyright Node.js contributors. Depending on your existing libraries and package management settings,
3261
3203
  your systems may call externally maintained libraries in addition to those listed above.
3262
3204
  See [here](https://nodejs.org/en/docs/meta/topics/dependencies/) and [here](https://github.com/nodejs/node/blob/v4.3.1/LICENSE)
3263
- for additional details regarding externally maintained libraries and certain related licenses and notices.”
3205
+ for additional details regarding externally maintained libraries and certain related licenses and notices.”
package/api.js CHANGED
@@ -430,38 +430,6 @@ API.prototype.addCustomSpanAttribute = function addCustomSpanAttribute(key, valu
430
430
  spanContext.addCustomAttribute(key, value)
431
431
  }
432
432
 
433
- API.prototype.setIgnoreTransaction = util.deprecate(
434
- setIgnoreTransaction, [
435
- 'API#setIgnoreTransaction is being deprecated!',
436
- 'Please use TransactionHandle#ignore to ignore a transaction.',
437
- 'Use API#getTransaction to create a new TransactionHandle instance.'
438
- ].join(' ')
439
- )
440
-
441
- /**
442
- * Tell the tracer whether to ignore the current transaction. The most common
443
- * use for this will be to mark a transaction as ignored (maybe it's handling
444
- * a websocket polling channel, or maybe it's an external call you don't care
445
- * is slow), but it's also useful when you want a transaction that would
446
- * otherwise be ignored due to URL or transaction name normalization rules
447
- * to *not* be ignored.
448
- *
449
- * @param {boolean} ignored Ignore, or don't ignore, the current transaction.
450
- */
451
- function setIgnoreTransaction(ignored) {
452
- var metric = this.agent.metrics.getOrCreateMetric(
453
- NAMES.SUPPORTABILITY.API + '/setIgnoreTransaction'
454
- )
455
- metric.incrementCallCount()
456
-
457
- var transaction = this.agent.tracer.getTransaction()
458
- if (!transaction) {
459
- return logger.warn("No transaction found to ignore.")
460
- }
461
-
462
- transaction.setForceIgnore(ignored)
463
- }
464
-
465
433
  /**
466
434
  * Send errors to New Relic that you've already handled yourself. Should be an
467
435
  * `Error` or one of its subtypes, but the API will handle strings and objects
@@ -24,14 +24,9 @@ fi
24
24
 
25
25
  export AGENT_PATH=`pwd`
26
26
 
27
- # @koa/router 8.03+ breaks segment naming for nested routes
28
- skip="koa"
29
-
30
27
  # Don't run the aws-sdk tests if we don't have the keys set
31
28
  if [[ -z "$AWS_ACCESS_KEY_ID" ]]; then
32
- skip="${skip},aws-sdk"
29
+ time ./node_modules/.bin/versioned-tests $VERSIONED_MODE -i 2 -s aws-sdk ${directories[@]}
30
+ else
31
+ time ./node_modules/.bin/versioned-tests $VERSIONED_MODE -i 2 ${directories[@]}
33
32
  fi
34
-
35
-
36
- # This is meant to be temporary. Remove once new major version with fixes rolled into agent.
37
- time ./node_modules/.bin/versioned-tests $VERSIONED_MODE -i 2 -s $skip ${directories[@]}
package/index.js CHANGED
@@ -48,14 +48,16 @@ function initialize() {
48
48
  preAgentTime
49
49
  )
50
50
 
51
- // TODO: Update this check when Node v8 is deprecated.
52
- if (psemver.satisfies('<8.0.0')) {
51
+ // TODO: Update this check when Node v10 is deprecated.
52
+ if (psemver.satisfies('<10.0.0')) {
53
53
  message = 'New Relic for Node.js requires a version of Node equal to or\n' +
54
54
  'greater than 8.0.0. Not starting!'
55
55
 
56
56
  logger.error(message)
57
57
  throw new Error(message)
58
- } else if (!psemver.satisfies(pkgJSON.engines.node)) {
58
+
59
+ // TODO: Update this check when Node v16 support is added
60
+ } else if (!psemver.satisfies(pkgJSON.engines.node) || psemver.satisfies('>=15.0.0')) {
59
61
  logger.warn(
60
62
  'New Relic for Node.js %s has not been tested on Node.js %s. Please ' +
61
63
  'update the agent or downgrade your version of Node.js',
package/lib/agent.js CHANGED
@@ -581,6 +581,10 @@ Agent.prototype._beforeMetricDataSend = function _beforeMetricDataSend() {
581
581
 
582
582
  // Send uninstrumented supportability metrics every metric harvest cycle
583
583
  uninstrumented.createMetrics(this.metrics)
584
+
585
+ if (this.spanEventAggregator.isStream) {
586
+ this.spanEventAggregator.createMetrics()
587
+ }
584
588
  }
585
589
 
586
590
  Agent.prototype._generateEntityStatsAndClear = function _generateHarvestMetrics() {
@@ -107,17 +107,23 @@ RemoteMethod.prototype._post = function _post(data, nrHeaders, callback) {
107
107
  }
108
108
 
109
109
  if (options.compressed) {
110
- var useGzip = this._config.compressed_content_encoding === 'gzip'
111
- var compressor = useGzip ? zlib.gzip : zlib.deflate
112
- compressor(data, function onCompress(err, compressed) {
113
- if (err) {
114
- logger.warn(err, 'Error compressing JSON for delivery. Not sending.')
115
- return callback(err)
116
- }
117
-
118
- options.body = compressed
119
- makeRequest()
120
- })
110
+ // NOTE: gzip and deflate throw immediately in Node 14+ with an invalid argument
111
+ try {
112
+ var useGzip = this._config.compressed_content_encoding === 'gzip'
113
+ var compressor = useGzip ? zlib.gzip : zlib.deflate
114
+ compressor(data, function onCompress(err, compressed) {
115
+ if (err) {
116
+ logger.warn(err, 'Error compressing JSON for delivery. Not sending.')
117
+ return callback(err)
118
+ }
119
+
120
+ options.body = compressed
121
+ makeRequest()
122
+ })
123
+ } catch (err) {
124
+ logger.warn(err, 'Error compressing JSON for delivery. Not sending.')
125
+ return callback(err)
126
+ }
121
127
  } else {
122
128
  options.body = data
123
129
  makeRequest()
@@ -292,10 +292,7 @@ class ServerlessCollector {
292
292
  payload
293
293
  ]) + '\n'
294
294
 
295
- if (this.shouldUsePipe === undefined) {
296
- this.shouldUsePipe = fs.existsSync(this.pipePath)
297
- }
298
- const didUsePipe = this.shouldUsePipe && this.flushToPipeSync(serializedPayload)
295
+ const didUsePipe = fs.existsSync(this.pipePath) && this.flushToPipeSync(serializedPayload)
299
296
 
300
297
  if (!didUsePipe) {
301
298
  this.flushToStdOut(serializedPayload, payload.length, sync)
@@ -595,14 +595,6 @@ exports.config = () => ({
595
595
  * options are disabled when high-security mode is enabled.
596
596
  */
597
597
  api: {
598
- /**
599
- * Deprecated. Please use `api.custom_attributes_enabled` instead.
600
- *
601
- * @env NEW_RELIC_API_CUSTOM_PARAMETERS
602
- */
603
- // TODO: This somehow survived the v5 cut, even though
604
- // it's already removed from docs site. Remove in v6.
605
- custom_parameters_enabled: true,
606
598
  /**
607
599
  * Controls for the `API.addCustomAttribute` method.
608
600
  *
package/lib/config/env.js CHANGED
@@ -106,7 +106,6 @@ const ENV_MAPPING = {
106
106
  },
107
107
  api: {
108
108
  custom_attributes_enabled: 'NEW_RELIC_API_CUSTOM_ATTRIBUTES',
109
- custom_parameters_enabled: 'NEW_RELIC_API_CUSTOM_PARAMETERS',
110
109
  custom_events_enabled: 'NEW_RELIC_API_CUSTOM_EVENTS',
111
110
  notice_error_enabled: 'NEW_RELIC_API_NOTICE_ERROR'
112
111
  },
@@ -1025,15 +1025,6 @@ Config.prototype._fromPassed = function _fromPassed(external, internal, arbitrar
1025
1025
  return
1026
1026
  }
1027
1027
 
1028
- // TODO: remove in v6
1029
- if (key === 'ignored_params') {
1030
- warnDeprecated(key, 'attributes.exclude')
1031
- }
1032
-
1033
- if (key === 'capture_params') {
1034
- warnDeprecated(key, 'attributes.enabled')
1035
- }
1036
-
1037
1028
  try {
1038
1029
  var node = external[key]
1039
1030
  } catch (err) {
@@ -1049,14 +1040,6 @@ Config.prototype._fromPassed = function _fromPassed(external, internal, arbitrar
1049
1040
  internal[key] = node
1050
1041
  }
1051
1042
  }, this)
1052
-
1053
- function warnDeprecated(key, replacement) {
1054
- logger.warn(
1055
- 'Config key %s is deprecated, please use %s instead',
1056
- key,
1057
- replacement
1058
- )
1059
- }
1060
1043
  }
1061
1044
 
1062
1045
  /**
@@ -1327,10 +1310,6 @@ Config.prototype._canonicalize = function _canonicalize() {
1327
1310
  )
1328
1311
  }
1329
1312
 
1330
- this.api.custom_attributes_enabled = !this.api.custom_attributes_enabled
1331
- ? this.api.custom_attributes_enabled
1332
- : this.api.custom_parameters_enabled
1333
-
1334
1313
  this.serverless_mode.enabled = this.serverless_mode.enabled
1335
1314
  && this.feature_flag.serverless_mode
1336
1315
 
@@ -142,13 +142,18 @@ class ErrorCollector {
142
142
  }
143
143
 
144
144
  const isErroredTransaction = urltils.isError(this.config, transaction.statusCode)
145
+ const isIgnoredErrorStatusCode = urltils.isIgnoredError(
146
+ this.config,
147
+ transaction.statusCode
148
+ )
149
+
145
150
  const isExpectedErrorStatusCode = urltils.isExpectedError(
146
151
  this.config,
147
152
  transaction.statusCode
148
153
  )
149
154
 
150
155
  // collect other exceptions only if status code is not ignored
151
- if (transaction.exceptions.length) {
156
+ if (transaction.exceptions.length && !isIgnoredErrorStatusCode) {
152
157
  for (let i = 0; i < transaction.exceptions.length; i++) {
153
158
  const exception = transaction.exceptions[i]
154
159
  if (this.collect(transaction, exception)) {
@@ -20,7 +20,20 @@ class Exception {
20
20
  }
21
21
 
22
22
  getErrorDetails(config) {
23
- return errorHelper.extractErrorInformation(null, this.error, config)
23
+ const errorDetails = errorHelper.extractErrorInformation(null, this.error, config)
24
+ errorDetails.expected = this.isExpected(config, errorDetails)
25
+
26
+ return errorDetails
27
+ }
28
+
29
+ isExpected(config, {type, message}) {
30
+ if (!this._expected) {
31
+ this._expected =
32
+ errorHelper.isExpectedErrorClass(config, type) ||
33
+ errorHelper.isExpectedErrorMessage(config, type, message)
34
+ }
35
+
36
+ return this._expected
24
37
  }
25
38
  }
26
39
 
@@ -121,7 +121,7 @@ class GrpcConnection extends EventEmitter {
121
121
  // immediately.
122
122
  this._setState(connectionStates.connected, this.stream)
123
123
  } catch (err) {
124
- logger.trace(
124
+ logger.warn(
125
125
  err,
126
126
  'Unexpected error establishing gRPC stream, will not attempt reconnect.'
127
127
  )
@@ -198,9 +198,26 @@ class GrpcConnection extends EventEmitter {
198
198
  if (this.stream) {
199
199
  this.stream.removeAllListeners()
200
200
 
201
+ const oldStream = this.stream
202
+ this.stream.on('status', function endStreamStatusHandler(grpcStatus) {
203
+ logger.trace('End stream status received [%s]: %s', grpcStatus.code, grpcStatus.details)
204
+
205
+ // Cleanup the final end stream listeners.
206
+ oldStream.removeAllListeners()
207
+ })
208
+
209
+ // Listen to any final errors to prevent throwing.
210
+ // This is unlikely but if the server closes post
211
+ // removing listeners and prior to response it could
212
+ // happen. We noticed this via tests on Node 14.
213
+ this.stream.on('error', function endStreamErrorHandler(err) {
214
+ logger.trace('End stream error received. Code: [%s]: %s', err.code, err.details)
215
+ })
216
+
201
217
  // Indicates to server we are done.
202
218
  // Server officially closes the stream.
203
219
  this.stream.end()
220
+
204
221
  this.stream = null
205
222
  }
206
223
 
@@ -238,6 +255,9 @@ class GrpcConnection extends EventEmitter {
238
255
  // per the spec, An UNIMPLEMENTED status code from gRPC indicates
239
256
  // that the versioned Trace Observer is no longer available. Agents
240
257
  // MUST NOT attempt to reconnect in this case
258
+ logger.info(
259
+ '[UNIMPLEMENTED]: Trace Obserserver is no longer available. Shutting down connection.'
260
+ )
241
261
  this._disconnect()
242
262
  } else if (grpc.status[grpc.status.OK] === grpcStatusName) {
243
263
  this._reconnect()
@@ -256,7 +276,11 @@ class GrpcConnection extends EventEmitter {
256
276
  this._metrics.getOrCreateMetric(NAMES.INFINITE_TRACING.SPAN_RESPONSE_ERROR)
257
277
  .incrementCallCount()
258
278
 
259
- logger.trace('span stream error. Code: [%s]: %s',err.code, err.details)
279
+ // For errors, the status will either result in a disconnect or a reconnect
280
+ // delay that should prevent too frequent spamming. Unless the app is idle
281
+ // and regularly getting Status 13 reconnects from the server, in which case
282
+ // this will be almost the only logging.
283
+ logger.warn('Span stream error. Code: [%s]: %s', err.code, err.details)
260
284
  })
261
285
  }
262
286