newrelic 7.3.1 → 7.4.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 CHANGED
@@ -1,3 +1,27 @@
1
+ ### v7.4.0 (2021-05-11)
2
+
3
+ * Updated third party notices and manifest for husky and lint-staged.
4
+
5
+ * Updated redis versioned tests to use unique DB indexes per file to avoid collisions and flushing of in-progress tests.
6
+
7
+ * Pinned hapi 17 versioned tests to only minor/patch versions within 17.x.
8
+
9
+ * Bumped timeout for redis versioned tests.
10
+
11
+ * Wired up husky + lint staged to execute linting on all changed files in pre-commit hook.
12
+
13
+ * Handled a proxy misconfiguration of collector and log an actionable warning message.
14
+
15
+ * Added `flaky_code` and `success_delay_ms` handling of flaky grpc connections to infinite tracing.
16
+
17
+ * Added resources to README to highlight external modules that customers should be aware of and possibly use for their applications.
18
+
19
+ * Logged all New Relic metadata env vars at startup.
20
+
21
+ * Fixed images for improved reader experience.
22
+
23
+ Thank you to @henryjw for the contribution.
24
+
1
25
  ### v7.3.1 (2021-04-14)
2
26
 
3
27
  * Fixed issue with 'new_promise_tracking' feature flag functionality where segments for ended transactions would get propagated in certain cases by promises that had no continuations scheduled (via await or manually).
package/README.md CHANGED
@@ -52,7 +52,7 @@ To use New Relic's Node.js agent entails these three steps, which are described
52
52
  /* ... the rest of your program ... */
53
53
  ```
54
54
 
55
- If you're compiling your JavaScript and can't control the final `require` order, the Node,js agent will work with node's `-r/--require` flag.
55
+ If you're compiling your JavaScript and can't control the final `require` order, the Node.js agent will work with node's `-r/--require` flag.
56
56
 
57
57
  $ node -r newrelic your-program.js
58
58
  $ node --require newrelic your-program.js
@@ -61,11 +61,26 @@ If you're compiling your JavaScript and can't control the final `require` order,
61
61
 
62
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).
63
63
 
64
+ ### External Modules
65
+
66
+ There are several modules that can be installed and configured to accompany the Node.js agent:
67
+
68
+ * [@newrelic/apollo-server-plugin](https://github.com/newrelic/newrelic-node-apollo-server-plugin): New Relic's official Apollo Server plugin for use with the Node.js agent.
69
+ * [@newrelic/winston-enricher](https://github.com/newrelic/newrelic-winston-logenricher-node): Provides distributed trace and span information output as JSON-formatted log messages. This is most commonly used with the New Relic Logs product.
70
+ * [@newrelic/mysql](https://github.com/newrelic/node-newrelic-mysql)(**Experimental**): Standalone instrumentation for [mysql2](https://github.com/sidorares/node-mysql2#readme) and [mysql2/promise](https://github.com/sidorares/node-mysql2/blob/master/documentation/Promise-Wrapper.md) as well as the same instrumentation for [mysql](https://github.com/mysqljs/mysql#readme) within the Node.js agent.
71
+
72
+ There are several modules included within the Node.js agent to add more instrumentation for 3rd party modules:
73
+
74
+ * [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk): Provides instrumentation for the [AWS SDK](https://www.npmjs.com/package/aws-sdk) npm package.
75
+ * [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa): Provides instrumentation for [koa](https://koajs.com/), [koa-router](https://github.com/ZijianHe/koa-router), [@koa/router](https://github.com/koajs/router), and [koa-route](https://github.com/koajs/route) npm packages.
76
+ * [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent): Provides instrumentation for [superagent](https://github.com/visionmedia/superagent) npm package.
77
+ * [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics): Provides hooks into the native v8 layer of Node.js to provide metrics to the Node.js agent.
78
+
64
79
  ## Usage
65
80
 
66
81
  ### Using the API
67
82
 
68
- The `newrelic` module returns an object with the Node agent's API methods attached.
83
+ The `newrelic` module returns an object with the Node.js agent's API methods attached.
69
84
 
70
85
  ```js
71
86
  const newrelic = require('newrelic')
@@ -49,7 +49,9 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
49
49
  * [glob](#glob)
50
50
  * [got](#got)
51
51
  * [http-errors](#http-errors)
52
+ * [husky](#husky)
52
53
  * [jsdoc](#jsdoc)
54
+ * [lint-staged](#lint-staged)
53
55
  * [memcached](#memcached)
54
56
  * [minami](#minami)
55
57
  * [mongodb](#mongodb)
@@ -1927,7 +1929,7 @@ SOFTWARE.
1927
1929
 
1928
1930
  ### commander
1929
1931
 
1930
- This product includes source derived from [commander](https://github.com/tj/commander.js) ([v7.0.0](https://github.com/tj/commander.js/tree/v7.0.0)), distributed under the [MIT License](https://github.com/tj/commander.js/blob/v7.0.0/LICENSE):
1932
+ This product includes source derived from [commander](https://github.com/tj/commander.js) ([v7.2.0](https://github.com/tj/commander.js/tree/v7.2.0)), distributed under the [MIT License](https://github.com/tj/commander.js/blob/v7.2.0/LICENSE):
1931
1933
 
1932
1934
  ```
1933
1935
  (The MIT License)
@@ -2016,7 +2018,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2016
2018
 
2017
2019
  ### fastify
2018
2020
 
2019
- This product includes source derived from [fastify](https://github.com/fastify/fastify) ([v2.14.1](https://github.com/fastify/fastify/tree/v2.14.1)), distributed under the [MIT License](https://github.com/fastify/fastify/blob/v2.14.1/LICENSE):
2021
+ This product includes source derived from [fastify](https://github.com/fastify/fastify) ([v2.15.3](https://github.com/fastify/fastify/tree/v2.15.3)), distributed under the [MIT License](https://github.com/fastify/fastify/blob/v2.15.3/LICENSE):
2020
2022
 
2021
2023
  ```
2022
2024
  MIT License
@@ -2139,6 +2141,35 @@ THE SOFTWARE.
2139
2141
 
2140
2142
  ```
2141
2143
 
2144
+ ### husky
2145
+
2146
+ This product includes source derived from [husky](https://github.com/typicode/husky) ([v6.0.0](https://github.com/typicode/husky/tree/v6.0.0)), distributed under the [MIT License](https://github.com/typicode/husky/blob/v6.0.0/LICENSE):
2147
+
2148
+ ```
2149
+ MIT License
2150
+
2151
+ Copyright (c) 2021 typicode
2152
+
2153
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2154
+ of this software and associated documentation files (the "Software"), to deal
2155
+ in the Software without restriction, including without limitation the rights
2156
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2157
+ copies of the Software, and to permit persons to whom the Software is
2158
+ furnished to do so, subject to the following conditions:
2159
+
2160
+ The above copyright notice and this permission notice shall be included in all
2161
+ copies or substantial portions of the Software.
2162
+
2163
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2164
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2165
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2166
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2167
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2168
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2169
+ SOFTWARE.
2170
+
2171
+ ```
2172
+
2142
2173
  ### jsdoc
2143
2174
 
2144
2175
  This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([v3.6.3](https://github.com/jsdoc/jsdoc/tree/v3.6.3)), distributed under the [Apache-2.0 License](https://github.com/jsdoc/jsdoc/blob/v3.6.3/LICENSE.md):
@@ -2249,6 +2280,35 @@ https://github.com/jmblog/color-themes-for-google-code-prettify
2249
2280
 
2250
2281
  ```
2251
2282
 
2283
+ ### lint-staged
2284
+
2285
+ This product includes source derived from [lint-staged](https://github.com/okonet/lint-staged) ([v11.0.0](https://github.com/okonet/lint-staged/tree/v11.0.0)), distributed under the [MIT License](https://github.com/okonet/lint-staged/blob/v11.0.0/LICENSE):
2286
+
2287
+ ```
2288
+ The MIT License (MIT)
2289
+
2290
+ Copyright (c) 2016 Andrey Okonetchnikov
2291
+
2292
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2293
+ of this software and associated documentation files (the "Software"), to deal
2294
+ in the Software without restriction, including without limitation the rights
2295
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2296
+ copies of the Software, and to permit persons to whom the Software is
2297
+ furnished to do so, subject to the following conditions:
2298
+
2299
+ The above copyright notice and this permission notice shall be included in all
2300
+ copies or substantial portions of the Software.
2301
+
2302
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2303
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2304
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2305
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2306
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2307
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2308
+ SOFTWARE.
2309
+
2310
+ ```
2311
+
2252
2312
  ### memcached
2253
2313
 
2254
2314
  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):
@@ -117,6 +117,22 @@ CollectorAPI.prototype.connect = function connect(callback) {
117
117
  this._reqHeadersMap = null
118
118
  }
119
119
 
120
+ /**
121
+ * Checks if proxy is configured to connect via `proxy_host` and `proxy_port`
122
+ * and if error code is EPROTO or ECONNRESET. This is an indication their proxy
123
+ * server only accepts HTTP connections, and we should provide an actionable warning to
124
+ * fix the misconfiguration by setting `proxy` to a fully qualified URL
125
+ *
126
+ * @param {Error} error
127
+ * @returns {Boolean}
128
+ */
129
+ function isProxyMisconfigured(error) {
130
+ const config = api._agent.config
131
+ return error &&
132
+ ['EPROTO', 'ECONNRESET'].includes(error.code) &&
133
+ config.proxy_host && config.proxy_port && !config.proxy
134
+ }
135
+
120
136
  function retry(error, response) {
121
137
  metric.incrementCallCount()
122
138
 
@@ -142,6 +158,14 @@ CollectorAPI.prototype.connect = function connect(callback) {
142
158
  ' (status code %s)',
143
159
  response.status
144
160
  )
161
+ } else if (isProxyMisconfigured(error)) {
162
+ logger.warn(
163
+ error,
164
+ 'Your proxy server appears to be configured to accept connections over http. ' +
165
+ 'When setting `proxy_host` and `proxy_port` New Relic attempts to connect over ' +
166
+ 'SSL(https). If your proxy is configured to accept connections over http, try ' +
167
+ 'setting `proxy` to a fully qualified URL(e.g http://proxy-host:8080).'
168
+ )
145
169
  }
146
170
 
147
171
  let backoff = BACKOFFS[Math.min(attempts, max) - 1]
@@ -55,6 +55,8 @@ function facts(agent, callback) {
55
55
  }, {})
56
56
  }
57
57
 
58
+ logger.debug('New Relic metadata %o', results.metadata)
59
+
58
60
  results.event_harvest_config = {
59
61
  harvest_limits: {
60
62
  analytic_event_data: agent.config.transaction_events.max_samples_stored,
@@ -11,6 +11,12 @@ const logger = require('../logger').child({component: 'grpc_connection'})
11
11
  const EventEmitter = require('events')
12
12
  const NAMES = require('../metrics/names')
13
13
  const util = require('util')
14
+ const GRPC_TEST_META = {
15
+ flaky: 'NEWRELIC_GRPCCONNECTION_METADATA_FLAKY',
16
+ delay: 'NEWRELIC_GRPCCONNECTION_METADATA_DELAY',
17
+ flaky_code: 'NEWRELIC_GRPCCONNECTION_METADATA_FLAKY_CODE',
18
+ success_delay_ms: 'NEWRELIC_GRPCCONNECTION_METADATA_SUCCESS_DELAY_MS'
19
+ }
14
20
 
15
21
  const connectionStates = require('./connection/states')
16
22
 
@@ -163,22 +169,27 @@ class GrpcConnection extends EventEmitter {
163
169
  }
164
170
  }
165
171
 
166
- // check environment variables for testing parameters and
167
- // pass to server via meta-data.
168
- const flaky = parseInt(env.NEWRELIC_GRPCCONNECTION_METADATA_FLAKY, 10)
169
- const delay = parseInt(env.NEWRELIC_GRPCCONNECTION_METADATA_DELAY, 10)
170
- if (flaky) {
171
- logger.trace('Adding flaky metadata: %s', flaky)
172
- metadata.add('flaky', flaky)
173
- }
174
- if (delay) {
175
- logger.trace('Adding delay metadata: %s', delay)
176
- metadata.add('delay',delay)
177
- }
172
+ this._setTestMetadata(metadata, env)
178
173
 
179
174
  return metadata
180
175
  }
181
176
 
177
+ /**
178
+ * Adds test metadata used to simulate connectivity issues
179
+ * when appropriate env vars are set
180
+ *
181
+ * @param {Metadata} metadata
182
+ */
183
+ _setTestMetadata(metadata, env) {
184
+ for (const [key, envVar] of Object.entries(GRPC_TEST_META)) {
185
+ const value = parseInt(env[envVar], 10)
186
+ if (value) {
187
+ logger.trace('Adding %s metadata: %s', key, value)
188
+ metadata.add(key, value)
189
+ }
190
+ }
191
+ }
192
+
182
193
  /**
183
194
  * Disconnects from gRPC endpoint and schedules establishing a new connection.
184
195
  * @param {number} reconnectDelayMs number of milliseconds to wait before reconnecting.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "7.3.1",
3
+ "version": "7.4.0",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -176,7 +176,9 @@
176
176
  "glob": "^7.1.2",
177
177
  "got": "^8.0.1",
178
178
  "http-errors": "^1.7.3",
179
+ "husky": "^6.0.0",
179
180
  "jsdoc": "^3.6.3",
181
+ "lint-staged": "^11.0.0",
180
182
  "memcached": ">=0.2.8",
181
183
  "minami": "^1.1.1",
182
184
  "mongodb": "^3.3.3",