newrelic 8.7.0 → 8.9.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,60 +1,169 @@
1
- ### v8.7.0 (2022-01-04)
2
-
3
- * Updated `onResolved` instrumentation hook to only be called the first time we see a specific module filepath resolved.
4
-
5
- * Removed `tracer.segment` in place of direct usage of context manager.
6
-
1
+ ### v8.9.0 (2022-03-15)
2
+
3
+ * Added support for `initializeUnorderedBulkOp`, and `initializeOrderedBulkOp` in mongodb v3 instrumentation.
4
+
5
+ Thanks to Denis Lantsman (@dlants) for the contribution.
6
+
7
+ * Updated logger to delay logging until configuration is parsed. The logger will now queue all log entries that occur before the agent can parse the configuration.
8
+
9
+ Thanks to Cody Landry (@codylandry) for the contribution.
10
+
11
+ * Added `NEW_RELIC_ALLOW_ALL_HEADERS` as a boolean environment variable, same behavior as existing `allow_all_headers`.
12
+
13
+ * Updated the AWS IMDBS v2 endpoint to use `latest` to align with the internal agent specification.
14
+
15
+ * Bumped `@newrelic/koa` to ^6.1.1.
16
+
17
+ * Added Next.js to External Modules list in README.
18
+
19
+ * Updated mysql and mysql2 versioned tests to run against their own databases on the MySQL instance.
20
+
21
+ * Removed upper-bound testing from restify versioned tests so future major versions will be covered.
22
+
23
+ * Removed upper-bound testing from mysql2 versioned tests to cover existing and future major versions.
24
+
25
+ Continues to skip version 1.6.2 which had a bug that broke tests which was resolved in 1.6.3.
26
+
27
+ * Updated @hapi/hapi Node 16 versioned test runs to run against @hapi/hapi >=20.1.2 so future major releases will be ran.
28
+
29
+ * Fixed sparse checkout of non-default branch for external versioned tests.
30
+
31
+ * Added external versioned tests for the Apollo Server plugin instrumentation.
32
+
33
+ * Added nock delay to test timeouts in utilization integration tests.
34
+
35
+ * Added newrelic-node-nextjs to external versioned tests to be run on every PR.
36
+
37
+ * Updated external version test running to support more test scenarios.
38
+ * Adds `test/versioned-external` to lint ignore to avoid issues for scripts in tests that auto run linting tools (next/react).
39
+ * Adds `index.js` and `nr-hooks.js` to files automatically checked-out for test runs.
40
+
41
+ ### v8.8.0 (2022-02-23)
42
+
43
+ * Updated AWS metadata capture to utilize IMDSv2.
44
+
45
+ * Fixed link to discuss.newrelic.com in README
46
+
47
+ * Updated minimum Node version warning to output current Node version from process.
48
+
49
+ * Bumped `@newrelic/native-metrics` to ^7.1.1.
50
+
51
+ * Added `Nextjs` to a framework constant within the webframework-shim.
52
+
53
+ * Updated shim to pass active segment to inContext callback.
54
+
55
+ * Bumped `@grpc/grpc-js` to ^1.5.5.
56
+
57
+ * Bumped `@grpc/proto-loader` to ^0.6.9.
58
+
59
+ * Bumped `@newrelic/superagent` to ^5.1.0.
60
+
61
+ * Bumped `@newrelic/koa` to ^6.1.0.
62
+
63
+ * Bumped `async` to ^3.2.3.
64
+
65
+ * Resolved several npm audit warnings for dev deps.
66
+
67
+ * Fixed Post Release workflow by properly configuring git credentials so it can push API docs to branch
68
+ * Added `set -e` in publish docs script to exit on possible failures
69
+ * Removed redundant `npm ci` in publish API docs script
70
+
71
+ * Added ability to ignore certain PRs in `bin/pending-prs.js` report to slack
72
+
73
+ * Updated README to include `@newrelic/pino-enricher` as an external module.
74
+
75
+ * Fixed documentation in a sample of the Datastore Instrumentation for Node.js.
76
+
77
+ * Added a new `mongo:5` container to `npm run sevices` to test mongodb driver >=4.2.0.
78
+
79
+ * Fixed conditions in post release workflow to function when triggered via successful release and manual invoked.
80
+
81
+ * Updated method for retrieving agent version from repository by using `cat package.json | jq .version`
82
+
83
+ * Fixed minor formatting and spelling issues in `create-docs-pr.js`.
84
+
85
+ * Fixed an issue with the docs PR script that assumed `\n` in the NEWS.md file when extract version and release date
86
+
87
+ ### v8.7.1 (2022-01-18)
88
+
89
+ * Bumped @newrelic/aws-sdk to ^4.1.1.
90
+
91
+ * Upgraded `@newrelic/test-utilities` to ^6.3.0.
92
+
93
+ Includes `helpers.getShim` so sub packages properly execute.
94
+
95
+ * Resolved dependabot and certain npm audit warnings.
96
+
97
+ * Automation and CI improvements:
98
+ * Added a script to be used by agent developers to add a PR to `docs-website` after the release of agent.
99
+ * Changed the trigger for post release jobs.
100
+ * Updated the `create-release-tag` script to pass in workflows to check before creating tag.
101
+ * Fixed `create-release-tag` to properly filter out all async workflow run checks
102
+ * Updated agent release to pass in a different list of workflows vs the default
103
+ * Fixed release creation reusable workflow by passing in repo to `bin/create-release-tag.js` and `bin/create-github-release.js`.
104
+ * Added `workflow_dispatch` to Agent Post Release workflow for manual testing.
105
+ * Added a reusable workflow to create a release tag, publish to NPM and publish a GitHub release.
106
+ * Updated agent release workflow to reference reusable workflow.
107
+ * Added a new workflow to update RPM and publish API docs on a published release event type.
108
+
109
+
110
+ ### v8.7.0 (2022-01-04)
111
+
112
+ * Updated `onResolved` instrumentation hook to only be called the first time we see a specific module filepath resolved.
113
+
114
+ * Removed `tracer.segment` in place of direct usage of context manager.
115
+
7
116
  * Fixed an issue where multiple calls to `instrumentLoadedModule` resulted in re-instrumenting the same module.
8
-
9
- * Fixed issue where `instrumentLoadedModule` would return `true` even if the instrumentation handler indicated it did not apply instrumentation.
10
-
117
+
118
+ * Fixed issue where `instrumentLoadedModule` would return `true` even if the instrumentation handler indicated it did not apply instrumentation.
119
+
11
120
  * Added support metrics for tracking when instrumentation was applied per module.
12
121
 
13
122
  * `Supportability/Features/Instrumentation/OnResolved/<module-name>`
14
123
  * `Supportability/Features/Instrumentation/OnResolved/<module-name>/Version/<major version>`
15
124
  * `Supportability/Features/Instrumentation/OnRequire/<module-name>`
16
- * `Supportability/Features/Instrumentation/OnRequire/<module-name>/Version/<major version>`
17
-
18
- * Fixed issue where expected status code ranges would not be parsed until ignored status codes were also defined.
19
-
20
- * Added an input `changelog_file` to pass in name of changelog. This defaults to `NEWS.md` but some repos use `CHANGELOG.md`
21
-
22
- * Abstracted `bin/prepare-release.js` to work against other repositories.
23
-
24
- * Added reusable prepare-release workflow that can be referenced in all other newrelic Node.js repositories.
25
-
26
- * Updated pending PRs workflow to check all repos the team owns.
27
-
28
- * Changed the event type from `pull_request` to `pull_request_target` to allow for auto assign of PRs to the Node.js Engineering Board
29
-
30
- * Fixed add to board workflow to properly pass repository secrets into reusable board workflow.
31
-
32
- * Changes token used to post issues to org level project board
33
-
34
- * Runs versioned tests for external modules against tests defined in the external repository instead of tests published in npm modules.
35
-
36
- * Added a reusable workflow to automatically add issues to the Node.js Engineering Board when created.
37
-
38
- * Added CI job to update system configurations with new agent version on release.
39
-
40
- * Moved `methods.js` under bluebird versioned test folder.
41
-
42
- ### v8.6.0 (2021-11-17)
43
-
125
+ * `Supportability/Features/Instrumentation/OnRequire/<module-name>/Version/<major version>`
126
+
127
+ * Fixed issue where expected status code ranges would not be parsed until ignored status codes were also defined.
128
+
129
+ * Added an input `changelog_file` to pass in name of changelog. This defaults to `NEWS.md` but some repos use `CHANGELOG.md`
130
+
131
+ * Abstracted `bin/prepare-release.js` to work against other repositories.
132
+
133
+ * Added reusable prepare-release workflow that can be referenced in all other newrelic Node.js repositories.
134
+
135
+ * Updated pending PRs workflow to check all repos the team owns.
136
+
137
+ * Changed the event type from `pull_request` to `pull_request_target` to allow for auto assign of PRs to the Node.js Engineering Board
138
+
139
+ * Fixed add to board workflow to properly pass repository secrets into reusable board workflow.
140
+
141
+ * Changes token used to post issues to org level project board
142
+
143
+ * Runs versioned tests for external modules against tests defined in the external repository instead of tests published in npm modules.
144
+
145
+ * Added a reusable workflow to automatically add issues to the Node.js Engineering Board when created.
146
+
147
+ * Added CI job to update system configurations with new agent version on release.
148
+
149
+ * Moved `methods.js` under bluebird versioned test folder.
150
+
151
+ ### v8.6.0 (2021-11-17)
152
+
44
153
  * Added `onResolved` instrumentation hook to apply instrumentation prior to module load.
45
154
 
46
- This hook fires after the module filepath has been resolved just prior to the module being loaded by the CommonJS module loader.
47
-
48
- * Fixed issue where `recordConsume` was not binding consumer if it was a promise
49
-
50
- * Pinned mongo versioned tests to `<4.2.0` until we can address https://github.com/newrelic/node-newrelic/issues/982
51
-
52
- * Introduced a context management API to be used in place of manually calling tracer.segment get/set.
53
-
54
- ### v8.5.2 (2021-11-09)
55
-
56
- * Fixed issue where unhandled promise rejections were not getting logged as errors in a lambda execution
57
-
155
+ This hook fires after the module filepath has been resolved just prior to the module being loaded by the CommonJS module loader.
156
+
157
+ * Fixed issue where `recordConsume` was not binding consumer if it was a promise
158
+
159
+ * Pinned mongo versioned tests to `<4.2.0` until we can address https://github.com/newrelic/node-newrelic/issues/982
160
+
161
+ * Introduced a context management API to be used in place of manually calling tracer.segment get/set.
162
+
163
+ ### v8.5.2 (2021-11-09)
164
+
165
+ * Fixed issue where unhandled promise rejections were not getting logged as errors in a lambda execution
166
+
58
167
  ### v8.5.1 (2021-11-03)
59
168
 
60
169
  * Fixed bug where failure to retrieve CPU/Memory details for certain Linux distros could result in a crash.
package/README.md CHANGED
@@ -67,8 +67,10 @@ For more information on getting started, [check the Node.js docs](https://docs.n
67
67
  There are several modules that can be installed and configured to accompany the Node.js agent:
68
68
 
69
69
  * [@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.
70
- * [@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/winston-enricher](https://github.com/newrelic/newrelic-node-log-extensions/tree/main/packages/winston-log-enricher): Provides distributed trace and span information output as JSON-formatted log messages in Winston. This is most commonly used with the New Relic Logs product.
71
+ * [@newrelic/pino-enricher](https://github.com/newrelic/newrelic-node-log-extensions/tree/main/packages/pino-log-enricher): Provides distributed trace and span information output as JSON-formatted log messages in Pino. This is most commonly used with the New Relic Logs product.
71
72
  * [@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.
73
+ * [@newrelic/next](https://github.com/newrelic/newrelic-node-nextjs): Provides instrumentation for the [Next.js](https://github.com/vercel/next.js/) npm package.
72
74
 
73
75
  There are several modules included within the Node.js agent to add more instrumentation for 3rd party modules:
74
76
 
@@ -152,7 +154,7 @@ If the issue has been confirmed as a bug or is a feature request, please file a
152
154
  **Support Channels**
153
155
 
154
156
  * [New Relic Documentation](https://docs.newrelic.com/docs/agents/nodejs-agent/getting-started/introduction-new-relic-nodejs): Comprehensive guidance for using our platform
155
- * [New Relic Community](https://discuss.newrelic.com/c/support-products-agents/node-js-agent/): The best place to engage in troubleshooting questions
157
+ * [New Relic Community](https://discuss.newrelic.com/tags/c/telemetry-data-platform/agents/nodeagent): The best place to engage in troubleshooting questions
156
158
  * [New Relic Developer](https://developer.newrelic.com/): Resources for building a custom observability applications
157
159
  * [New Relic University](https://learn.newrelic.com/): A range of online training for New Relic users of every level
158
160
  * [New Relic Technical Support](https://support.newrelic.com/) 24/7/365 ticketed support. Read more about our [Technical Support Offerings](https://docs.newrelic.com/docs/licenses/license-information/general-usage-licenses/support-plan).
@@ -86,7 +86,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
86
86
 
87
87
  ### @grpc/grpc-js
88
88
 
89
- This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.3.7](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.3.7)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.3.7/LICENSE):
89
+ This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.5.5](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.5.5)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.5.5/LICENSE):
90
90
 
91
91
  ```
92
92
  Apache License
@@ -295,7 +295,7 @@ This product includes source derived from [@grpc/grpc-js](https://github.com/grp
295
295
 
296
296
  ### @grpc/proto-loader
297
297
 
298
- This product includes source derived from [@grpc/proto-loader](https://github.com/grpc/grpc-node) ([v0.5.6](https://github.com/grpc/grpc-node/tree/v0.5.6)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/blob/v0.5.6/LICENSE):
298
+ This product includes source derived from [@grpc/proto-loader](https://github.com/grpc/grpc-node) ([v0.6.9](https://github.com/grpc/grpc-node/tree/v0.6.9)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/blob/v0.6.9/LICENSE):
299
299
 
300
300
  ```
301
301
  Apache License
@@ -504,7 +504,7 @@ This product includes source derived from [@grpc/proto-loader](https://github.co
504
504
 
505
505
  ### @newrelic/aws-sdk
506
506
 
507
- This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v4.0.1](https://github.com/newrelic/node-newrelic-aws-sdk/tree/v4.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-aws-sdk/blob/v4.0.1/LICENSE):
507
+ This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v4.1.1](https://github.com/newrelic/node-newrelic-aws-sdk/tree/v4.1.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-aws-sdk/blob/v4.1.1/LICENSE):
508
508
 
509
509
  ```
510
510
  Apache License
@@ -712,7 +712,7 @@ This product includes source derived from [@newrelic/aws-sdk](https://github.com
712
712
 
713
713
  ### @newrelic/koa
714
714
 
715
- This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v6.0.1](https://github.com/newrelic/node-newrelic-koa/tree/v6.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v6.0.1/LICENSE):
715
+ This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v6.1.0](https://github.com/newrelic/node-newrelic-koa/tree/v6.1.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v6.1.0/LICENSE):
716
716
 
717
717
  ```
718
718
  Apache License
@@ -921,7 +921,7 @@ Apache License
921
921
 
922
922
  ### @newrelic/superagent
923
923
 
924
- This product includes source derived from [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent) ([v5.0.1](https://github.com/newrelic/node-newrelic-superagent/tree/v5.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-superagent/blob/v5.0.1/LICENSE):
924
+ This product includes source derived from [@newrelic/superagent](https://github.com/newrelic/node-newrelic-superagent) ([v5.1.0](https://github.com/newrelic/node-newrelic-superagent/tree/v5.1.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-superagent/blob/v5.1.0/LICENSE):
925
925
 
926
926
  ```
927
927
  Apache License
@@ -1159,7 +1159,7 @@ THE SOFTWARE.
1159
1159
 
1160
1160
  ### async
1161
1161
 
1162
- This product includes source derived from [async](https://github.com/caolan/async) ([v3.2.1](https://github.com/caolan/async/tree/v3.2.1)), distributed under the [MIT License](https://github.com/caolan/async/blob/v3.2.1/LICENSE):
1162
+ This product includes source derived from [async](https://github.com/caolan/async) ([v3.2.3](https://github.com/caolan/async/tree/v3.2.3)), distributed under the [MIT License](https://github.com/caolan/async/blob/v3.2.3/LICENSE):
1163
1163
 
1164
1164
  ```
1165
1165
  Copyright (c) 2010-2018 Caolan McMahon
@@ -1770,7 +1770,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1770
1770
 
1771
1771
  ### @newrelic/test-utilities
1772
1772
 
1773
- This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v6.1.1](https://github.com/newrelic/node-test-utilities/tree/v6.1.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v6.1.1/LICENSE):
1773
+ This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v6.3.0](https://github.com/newrelic/node-test-utilities/tree/v6.3.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v6.3.0/LICENSE):
1774
1774
 
1775
1775
  ```
1776
1776
  Apache License
@@ -2531,7 +2531,7 @@ SOFTWARE.
2531
2531
 
2532
2532
  ### jsdoc
2533
2533
 
2534
- This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([v3.6.7](https://github.com/jsdoc/jsdoc/tree/v3.6.7)), distributed under the [Apache-2.0 License](https://github.com/jsdoc/jsdoc/blob/v3.6.7/LICENSE.md):
2534
+ This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([v3.6.10](https://github.com/jsdoc/jsdoc/tree/v3.6.10)), distributed under the [Apache-2.0 License](https://github.com/jsdoc/jsdoc/blob/v3.6.10/LICENSE.md):
2535
2535
 
2536
2536
  ```
2537
2537
  # License
@@ -3292,7 +3292,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3292
3292
 
3293
3293
  ### tap
3294
3294
 
3295
- This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v15.0.10](https://github.com/tapjs/node-tap/tree/v15.0.10)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v15.0.10/LICENSE):
3295
+ This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v15.1.6](https://github.com/tapjs/node-tap/tree/v15.1.6)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v15.1.6/LICENSE):
3296
3296
 
3297
3297
  ```
3298
3298
  The ISC License
@@ -3377,7 +3377,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3377
3377
 
3378
3378
  ### @newrelic/native-metrics
3379
3379
 
3380
- This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v7.0.1](https://github.com/newrelic/node-native-metrics/tree/v7.0.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v7.0.1/LICENSE):
3380
+ This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v7.1.1](https://github.com/newrelic/node-native-metrics/tree/v7.1.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v7.1.1/LICENSE):
3381
3381
 
3382
3382
  ```
3383
3383
  Apache License
package/index.js CHANGED
@@ -45,10 +45,9 @@ function initialize() {
45
45
  logger.debug('Process was running %s seconds before agent was loaded.', preAgentTime)
46
46
 
47
47
  if (!psemver.satisfies(pkgJSON.engines.node)) {
48
- // TODO: Update this message when Node v12 is deprecated.
49
48
  message =
50
- 'New Relic for Node.js requires a version of Node equal to or\n' +
51
- 'greater than 12.0.0. Not starting!'
49
+ `New Relic for Node.js requires a version of Node ${pkgJSON.engines.node}. \n` +
50
+ `Please upgrade from your current Node version: ${process.version}. Not starting!`
52
51
 
53
52
  logger.error(message)
54
53
  throw new Error(message)
@@ -134,6 +134,8 @@ exports.config = () => ({
134
134
  * When true, all request headers except for those listed in attributes.exclude
135
135
  * will be captured for all traces, unless otherwise specified in a destination's
136
136
  * attributes include/exclude lists.
137
+ *
138
+ * @env NEW_RELIC_ALLOW_ALL_HEADERS
137
139
  */
138
140
  allow_all_headers: false,
139
141
 
package/lib/config/env.js CHANGED
@@ -21,6 +21,7 @@ const ENV_MAPPING = {
21
21
  proxy_user: 'NEW_RELIC_PROXY_USER',
22
22
  proxy_pass: 'NEW_RELIC_PROXY_PASS',
23
23
  agent_enabled: 'NEW_RELIC_ENABLED',
24
+ allow_all_headers: 'NEW_RELIC_ALLOW_ALL_HEADERS',
24
25
  attributes: {
25
26
  enabled: 'NEW_RELIC_ATTRIBUTES_ENABLED',
26
27
  exclude: 'NEW_RELIC_ATTRIBUTES_EXCLUDE',
@@ -206,6 +207,7 @@ const OBJECT_LIST_VARS = new Set(['NEW_RELIC_NAMING_RULES'])
206
207
  // fancy--just use 'true' and 'false', everybody.
207
208
  const BOOLEAN_VARS = new Set([
208
209
  'NEW_RELIC_ENABLED',
210
+ 'NEW_RELIC_ALLOW_ALL_HEADERS',
209
211
  'NEW_RELIC_ATTRIBUTES_ENABLED',
210
212
  'NEW_RELIC_ERROR_COLLECTOR_ENABLED',
211
213
  'NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_ENABLED',
@@ -1623,7 +1623,8 @@ function initialize(config) {
1623
1623
  /**
1624
1624
  * When the logger is required here, it bootstraps itself and then
1625
1625
  * injects itself into this module's closure via setLogger on the
1626
- * instance of the logger it creates.
1626
+ * instance of the logger it creates. Logs are queued until config
1627
+ * has been loaded to apply logging settings to bootstrapping logs
1627
1628
  */
1628
1629
  logger = require('../logger')
1629
1630
 
@@ -1712,7 +1713,14 @@ function getOrCreateInstance() {
1712
1713
 
1713
1714
  // Config construction has potential to throw due to invalid settings.
1714
1715
  // This allows the agent to return a stub api without crashing the process.
1715
- _configInstance = Object.assign(defaultConfig(), { agent_enabled: false })
1716
+ _configInstance = Object.assign(defaultConfig(), {
1717
+ agent_enabled: false,
1718
+ logging: {
1719
+ enabled: true,
1720
+ filepath: 'stdout'
1721
+ }
1722
+ })
1723
+
1716
1724
  _configInstance.setLogger = Config.prototype.setLogger
1717
1725
  }
1718
1726
  }
@@ -43,6 +43,23 @@ common.instrumentCollection = function instrumentCollection(shim, Collection) {
43
43
  }
44
44
  }
45
45
 
46
+ /**
47
+ * Instruments the execute method on
48
+ * the BulkOperationBase class
49
+ *
50
+ * @param {Shim} shim
51
+ * @param {BulkOperationModule} bulk operation module, typically from mongodb/lib/bulk/common
52
+ * @param BulkOperationModule
53
+ */
54
+ common.instrumentBulkOperation = function instrumentBulkOperation(shim, BulkOperationModule) {
55
+ const BulkOperationBase = BulkOperationModule && BulkOperationModule.BulkOperationBase
56
+
57
+ if (BulkOperationBase && BulkOperationBase.prototype) {
58
+ const proto = BulkOperationBase.prototype
59
+ shim.recordBatchQuery(proto, 'execute', common.makeBulkDescFunc(shim, 'execute'))
60
+ }
61
+ }
62
+
46
63
  /**
47
64
  * Instruments all methods from constants.DB_OPS on
48
65
  * the Db class.
@@ -84,6 +101,25 @@ common.makeQueryDescFunc = function makeQueryDescFunc(shim, methodName) {
84
101
  }
85
102
  }
86
103
 
104
+ /**
105
+ * Sets up the desc for all instrumented bulk operations
106
+ *
107
+ * @param {Shim} shim
108
+ * @param {string} methodName
109
+ */
110
+ common.makeBulkDescFunc = function makeBulkDescFunc(shim) {
111
+ return function bulkDescFunc() {
112
+ const parameters = getInstanceAttributeParameters(shim, this)
113
+ return {
114
+ query: this.isOrdered ? 'orderedBulk' : 'unorderedBulk',
115
+ parameters,
116
+ promise: true,
117
+ callback: shim.LAST,
118
+ opaque: true
119
+ }
120
+ }
121
+ }
122
+
87
123
  /**
88
124
  * Sets up a listener for `started` on instrumenter(mongo APM). This applies to
89
125
  * mongo <4. The listener adds the following attributes to the active segment:
@@ -161,9 +197,10 @@ function setHostPort(shim, connStr, db, client) {
161
197
  * @param obj
162
198
  */
163
199
  function getInstanceAttributeParameters(shim, obj) {
164
- if (obj.s && obj.s.db && obj.s.topology) {
200
+ if (obj.s && obj.s.topology) {
165
201
  shim.logger.trace('Adding datastore instance attributes from obj.s.db + obj.s.topology')
166
- const databaseName = obj.s.db.databaseName || null
202
+ const databaseName =
203
+ (obj.s.db && obj.s.db.databaseName) || (obj.s.namespace && obj.s.namespace.db) || null
167
204
  const topology = obj.s.topology
168
205
  if (topology.s && topology.s.options) {
169
206
  return doCapture(topology.s.options, databaseName)
@@ -7,6 +7,7 @@
7
7
 
8
8
  const {
9
9
  captureAttributesOnStarted,
10
+ instrumentBulkOperation,
10
11
  instrumentCollection,
11
12
  instrumentCursor,
12
13
  instrumentDb,
@@ -27,6 +28,8 @@ function queryParser(operation) {
27
28
  collection = this.operation.target
28
29
  } else if (this.ns) {
29
30
  collection = this.ns.split(/\./)[1] || collection
31
+ } else if (this.s && this.s.collection && this.s.collection.collectionName) {
32
+ collection = this.s.collection.collectionName
30
33
  }
31
34
  return { operation, collection }
32
35
  }
@@ -68,6 +71,7 @@ module.exports = function instrument(shim, mongodb) {
68
71
  instrumentCursor(shim, mongodb.Cursor)
69
72
  instrumentCursor(shim, shim.require('./lib/aggregation_cursor'))
70
73
  instrumentCursor(shim, shim.require('./lib/command_cursor'))
74
+ instrumentBulkOperation(shim, shim.require('./lib/bulk/common'))
71
75
  instrumentCollection(shim, mongodb.Collection)
72
76
  instrumentDb(shim, mongodb.Db)
73
77
 
package/lib/logger.js CHANGED
@@ -9,12 +9,16 @@ const Logger = require('./util/logger')
9
9
  const fs = require('./util/unwrapped-core').fs
10
10
 
11
11
  // create bootstrapping logger
12
- module.exports = new Logger({
12
+ const logger = new Logger({
13
13
  name: 'newrelic_bootstrap',
14
- stream: process.stdout,
15
- level: 'info'
14
+ level: 'info',
15
+
16
+ // logger is configured below. Logs are queued until configured
17
+ configured: false
16
18
  })
17
19
 
20
+ module.exports = logger
21
+
18
22
  /**
19
23
  * Don't load config until this point, because it requires this
20
24
  * module, and if it gets loaded too early, module.exports will have no
@@ -28,8 +32,8 @@ if (config) {
28
32
  enabled: config.logging.enabled
29
33
  }
30
34
 
31
- // create the "real" logger
32
- module.exports = new Logger(options)
35
+ // configure logger
36
+ logger.configure(options)
33
37
 
34
38
  if (config.logging.enabled) {
35
39
  let stream
@@ -52,9 +56,6 @@ if (config) {
52
56
  /* eslint-enable no-console */
53
57
  })
54
58
  }
55
- module.exports.pipe(stream)
59
+ logger.pipe(stream)
56
60
  }
57
-
58
- // now tell the config module to switch to the real logger
59
- config.setLogger(module.exports)
60
61
  }
package/lib/shim/shim.js CHANGED
@@ -1307,7 +1307,7 @@ function applySegment(func, segment, full, context, args, inContextCB) {
1307
1307
  }
1308
1308
 
1309
1309
  if (typeof inContextCB === 'function') {
1310
- inContextCB()
1310
+ inContextCB(segment)
1311
1311
  }
1312
1312
 
1313
1313
  try {