newrelic 9.15.0 → 10.1.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 +72 -14
- package/README.md +0 -3
- package/THIRD_PARTY_NOTICES.md +3 -66
- package/esm-loader.mjs +12 -13
- package/lib/collector/serverless.js +7 -5
- package/lib/config/default.js +9 -1
- package/lib/grpc/connection.js +47 -23
- package/lib/grpc/endpoints/infinite-tracing/v1.proto +10 -0
- package/lib/instrumentation/@hapi/vision.js +4 -6
- package/lib/instrumentation/@nestjs/core.js +38 -0
- package/lib/instrumentation/mysql/mysql.js +19 -7
- package/lib/instrumentation/mysql/nr-hooks.js +5 -5
- package/lib/instrumentations.js +1 -1
- package/lib/metrics/names.js +3 -1
- package/lib/serverless/aws-lambda.js +60 -51
- package/lib/shim/conglomerate-shim.js +6 -2
- package/lib/shim/datastore-shim.js +8 -21
- package/lib/shim/index.js +4 -3
- package/lib/shim/message-shim.js +7 -10
- package/lib/shim/promise-shim.js +7 -8
- package/lib/shim/shim.js +101 -59
- package/lib/shim/transaction-shim.js +3 -2
- package/lib/shim/webframework-shim.js +12 -27
- package/lib/shimmer.js +118 -93
- package/lib/spans/base-span-streamer.js +135 -0
- package/lib/spans/batch-span-streamer.js +79 -0
- package/lib/spans/create-span-event-aggregator.js +25 -8
- package/lib/spans/span-streamer.js +13 -105
- package/lib/symbols.js +8 -1
- package/lib/transaction/index.js +8 -4
- package/lib/transaction/trace/index.js +63 -54
- package/lib/transaction/tracecontext.js +56 -44
- package/package.json +3 -3
package/NEWS.md
CHANGED
|
@@ -1,23 +1,81 @@
|
|
|
1
|
-
###
|
|
1
|
+
### v10.1.0 (2023-05-04)
|
|
2
2
|
|
|
3
|
-
* Added
|
|
3
|
+
* Added batching and compression to infinite tracing.
|
|
4
|
+
* These options are on by default.
|
|
5
|
+
* To restore uncompressed spans set `config.infinite_tracing.compression` to `false`.
|
|
6
|
+
* To send single spans vs batches set `config.infinite_tracing.batching` to `false`.
|
|
7
|
+
* The environment variables for these new configurations are: `NEW_RELIC_INFINITE_TRACING_BATCHING` and `NEW_RELIC_INFINITE_TRACING_COMPRESSION`.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
* Added support to record Nest.js error stack traces.
|
|
10
|
+
* Nest.js is officially supported via underlying instrumentation of express or fastify.
|
|
6
11
|
|
|
7
|
-
*
|
|
12
|
+
* Added job to create a release notes PR in the post-release workflow.
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
* Removed request library and updated helper to use http/https to make requests in tests.
|
|
10
15
|
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
### v9.13.0 (2023-03-20)
|
|
14
|
-
|
|
15
|
-
* Updated http instrumentation to no longer remove the `x-new-relic-disable-dt` header when using AWS SDK v3. This was done to prevent the "The request signature we calculated does not match the signature you provided. Check your key and signing method." error from AWS SDK.
|
|
16
|
-
|
|
17
|
-
* Added an API method `setUserID` to provide an ability to associate a unique identifier with a transaction event, transaction trace and errors within transaction. The attribute will be `enduser.id`.
|
|
18
|
-
|
|
19
|
-
* Added default configuration for security agent.
|
|
16
|
+
* Reduced cognitive complexity in lib/serverless/aws-lambda.js
|
|
20
17
|
|
|
18
|
+
### v10.0.0 (2023-04-19)
|
|
19
|
+
|
|
20
|
+
* **BREAKING** - Updated the default of `config.transaction_tracer.record_sql` from `off` to `obfuscated`. This means that sql statements will be captured but obfuscated.
|
|
21
|
+
|
|
22
|
+
* **BREAKING** - Route (URL) parameters are now stored as `request.parameters.route.*` attributes on Transactions, root Segments and Spans.
|
|
23
|
+
|
|
24
|
+
After this change, the following becomes true:
|
|
25
|
+
|
|
26
|
+
- Query parameters will be available as attributes prefixed with request.parameters.* on Transactions and Spans.
|
|
27
|
+
|
|
28
|
+
- Route parameters will be available as attributes prefixed with request.parameters.route.* on Transactions and Spans.
|
|
29
|
+
|
|
30
|
+
- Route parameters (aka url parameters) are a common feature of various web frameworks, where you can create a placeholder as part of an API route definition.
|
|
31
|
+
|
|
32
|
+
For example, given the following Express route definition and request url:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
app.get('/api/users/:id', myMiddleware, myController)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
curl http://localhost:3000/api/users/abc123?id=true
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The route parameter is `id`, and has a value of `abc123`. This would become `request.parameters.route.id: abc123` on the Transaction, root Segment, and Span attributes. This example also has a query parameter of `id`, which has a value of true. This would become `request.parameters.id: true` on the Transaction, root Segment, and Span attributes.
|
|
43
|
+
|
|
44
|
+
* **BREAKING** - Removed `captureUrlParams` from `WebFrameworkShim` class.
|
|
45
|
+
|
|
46
|
+
* **DEPRECATION NOTICE**: `shim.unwrap` and `shim.unwrapOnce` will no longer function if you attempt to unwrap an item that has been wrapped multiple times.
|
|
47
|
+
* This is because since we now allow instrumenting the same module more than once, you cannot safely unwrap without breaking all registered instrumentation. We plan to remove `shim.unwrap` and `shim.unwrapOnce` in the next major release.
|
|
48
|
+
|
|
49
|
+
* Added the ability to register instrumentation multiple hooks (onRequire, onResolved) for the same resolved moduleName.
|
|
50
|
+
* This has been a limitation of the agent from the beginning.
|
|
51
|
+
* If you used the api to instrument `api.instrument`, `api.instrumentDatastore`, `api.instrumentWebframework`, `api.instrumentMessages`, or `api.instrumentConglomerate`, it would override existing instrumentation hooks. The effect was that the Node.js agent would not function as designed.
|
|
52
|
+
|
|
53
|
+
* Refactored lib/transaction/tracecontext.js to reduce cognitive complexity.
|
|
54
|
+
|
|
55
|
+
* Refactored lib/transaction/trace/index.js to reduce cognitive complexity.
|
|
56
|
+
|
|
57
|
+
* Upgraded devDependencies jsdoc, and lean-jsdoc-theme.
|
|
58
|
+
|
|
59
|
+
### v9.15.0 (2023-04-04)
|
|
60
|
+
|
|
61
|
+
* Added a new configuration option `heroku.use_dyno_names` to specify whether or not to use `process.env.DYNO` for naming the host name and display host. This option defaults to true. If you are on heroku and do not want this functionality set `heroku.use_dyno_names` to `false`. You can also control this configuration options with the environment variable of `NEW_RELIC_HEROKU_USE_DYNO_NAMES`. Thanks @benney-au-le for your contribution 🚀
|
|
62
|
+
|
|
63
|
+
### v9.14.1 (2023-03-23)
|
|
64
|
+
|
|
65
|
+
* Restored assigning loaded version of agent to require.cache as `__NR_cache` instead of a symbol to properly detect attempts at loading agent twice.
|
|
66
|
+
|
|
67
|
+
### v9.14.0 (2023-03-23)
|
|
68
|
+
|
|
69
|
+
* Added new API function called `setErrorGroupCallback`, which provides a way for you to customize the `error.group.name` attribute of errors that are captured by the agent. This attribute controls how the Errors Inbox functionality groups similar errors together. To learn more about this function, please refer to our [example app](https://github.com/newrelic/newrelic-node-examples).
|
|
70
|
+
|
|
71
|
+
### v9.13.0 (2023-03-20)
|
|
72
|
+
|
|
73
|
+
* Updated http instrumentation to no longer remove the `x-new-relic-disable-dt` header when using AWS SDK v3. This was done to prevent the "The request signature we calculated does not match the signature you provided. Check your key and signing method." error from AWS SDK.
|
|
74
|
+
|
|
75
|
+
* Added an API method `setUserID` to provide an ability to associate a unique identifier with a transaction event, transaction trace and errors within transaction. The attribute will be `enduser.id`.
|
|
76
|
+
|
|
77
|
+
* Added default configuration for security agent.
|
|
78
|
+
|
|
21
79
|
### v9.12.1 (2023-03-15)
|
|
22
80
|
|
|
23
81
|
* Added ability to mark errors as expected when using `newrelic.noticeError`, by adding an optional boolean:
|
package/README.md
CHANGED
|
@@ -133,9 +133,6 @@ For more information on getting started, [check the Node.js docs](https://docs.n
|
|
|
133
133
|
There are several modules that can be installed and configured to accompany the Node.js agent:
|
|
134
134
|
|
|
135
135
|
* [@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.
|
|
136
|
-
* [@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.
|
|
137
|
-
* [@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.
|
|
138
|
-
* [@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.
|
|
139
136
|
* [@newrelic/next](https://github.com/newrelic/newrelic-node-nextjs): Provides instrumentation for the [Next.js](https://github.com/vercel/next.js/) npm package.
|
|
140
137
|
|
|
141
138
|
There are several modules included within the Node.js agent to add more instrumentation for 3rd party modules:
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -62,7 +62,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
62
62
|
* [prettier](#prettier)
|
|
63
63
|
* [proxyquire](#proxyquire)
|
|
64
64
|
* [q](#q)
|
|
65
|
-
* [request](#request)
|
|
66
65
|
* [rimraf](#rimraf)
|
|
67
66
|
* [should](#should)
|
|
68
67
|
* [sinon](#sinon)
|
|
@@ -1800,7 +1799,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
1800
1799
|
|
|
1801
1800
|
### @newrelic/test-utilities
|
|
1802
1801
|
|
|
1803
|
-
This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v7.
|
|
1802
|
+
This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v7.3.0](https://github.com/newrelic/node-test-utilities/tree/v7.3.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v7.3.0/LICENSE):
|
|
1804
1803
|
|
|
1805
1804
|
```
|
|
1806
1805
|
Apache License
|
|
@@ -2177,7 +2176,7 @@ SOFTWARE.
|
|
|
2177
2176
|
|
|
2178
2177
|
### clean-jsdoc-theme
|
|
2179
2178
|
|
|
2180
|
-
This product includes source derived from [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) ([v4.2.
|
|
2179
|
+
This product includes source derived from [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) ([v4.2.7](https://github.com/ankitskvmdam/clean-jsdoc-theme/tree/v4.2.7)), distributed under the [MIT License](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/v4.2.7/LICENSE):
|
|
2181
2180
|
|
|
2182
2181
|
```
|
|
2183
2182
|
MIT License
|
|
@@ -2709,7 +2708,7 @@ SOFTWARE.
|
|
|
2709
2708
|
|
|
2710
2709
|
### jsdoc
|
|
2711
2710
|
|
|
2712
|
-
This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([v4.0.
|
|
2711
|
+
This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([v4.0.2](https://github.com/jsdoc/jsdoc/tree/v4.0.2)), distributed under the [Apache-2.0 License](https://github.com/jsdoc/jsdoc/blob/v4.0.2/LICENSE.md):
|
|
2713
2712
|
|
|
2714
2713
|
```
|
|
2715
2714
|
# License
|
|
@@ -9165,68 +9164,6 @@ IN THE SOFTWARE.
|
|
|
9165
9164
|
|
|
9166
9165
|
```
|
|
9167
9166
|
|
|
9168
|
-
### request
|
|
9169
|
-
|
|
9170
|
-
This product includes source derived from [request](https://github.com/request/request) ([v2.88.2](https://github.com/request/request/tree/v2.88.2)), distributed under the [Apache-2.0 License](https://github.com/request/request/blob/v2.88.2/LICENSE):
|
|
9171
|
-
|
|
9172
|
-
```
|
|
9173
|
-
Apache License
|
|
9174
|
-
|
|
9175
|
-
Version 2.0, January 2004
|
|
9176
|
-
|
|
9177
|
-
http://www.apache.org/licenses/
|
|
9178
|
-
|
|
9179
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9180
|
-
|
|
9181
|
-
1. Definitions.
|
|
9182
|
-
|
|
9183
|
-
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
9184
|
-
|
|
9185
|
-
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
9186
|
-
|
|
9187
|
-
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
9188
|
-
|
|
9189
|
-
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
9190
|
-
|
|
9191
|
-
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
9192
|
-
|
|
9193
|
-
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
9194
|
-
|
|
9195
|
-
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
9196
|
-
|
|
9197
|
-
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
9198
|
-
|
|
9199
|
-
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
9200
|
-
|
|
9201
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
9202
|
-
|
|
9203
|
-
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
9204
|
-
|
|
9205
|
-
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
9206
|
-
|
|
9207
|
-
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
9208
|
-
|
|
9209
|
-
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
9210
|
-
|
|
9211
|
-
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
9212
|
-
|
|
9213
|
-
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
9214
|
-
|
|
9215
|
-
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
9216
|
-
|
|
9217
|
-
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
9218
|
-
|
|
9219
|
-
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
9220
|
-
|
|
9221
|
-
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
9222
|
-
|
|
9223
|
-
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
9224
|
-
|
|
9225
|
-
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
9226
|
-
|
|
9227
|
-
END OF TERMS AND CONDITIONS
|
|
9228
|
-
```
|
|
9229
|
-
|
|
9230
9167
|
### rimraf
|
|
9231
9168
|
|
|
9232
9169
|
This product includes source derived from [rimraf](https://github.com/isaacs/rimraf) ([v2.7.1](https://github.com/isaacs/rimraf/tree/v2.7.1)), distributed under the [ISC License](https://github.com/isaacs/rimraf/blob/v2.7.1/LICENSE):
|
package/esm-loader.mjs
CHANGED
|
@@ -68,19 +68,18 @@ export async function resolve(specifier, context, nextResolve) {
|
|
|
68
68
|
|
|
69
69
|
if (format === 'commonjs') {
|
|
70
70
|
// ES Modules translate import statements into fully qualified filepaths, so we create a copy of our instrumentation under this filepath
|
|
71
|
-
const instrumentationDefinitionCopy =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
71
|
+
const instrumentationDefinitionCopy = [...instrumentationDefinition]
|
|
72
|
+
instrumentationDefinitionCopy.forEach((copy) => {
|
|
73
|
+
// Stripping the prefix is necessary because the code downstream gets this url without it
|
|
74
|
+
copy.moduleName = fileURLToPath(url)
|
|
75
|
+
|
|
76
|
+
// Added to keep our Supportability metrics from exploding/including customer info via full filepath
|
|
77
|
+
copy.specifier = specifier
|
|
78
|
+
shimmer.registerInstrumentation(copy)
|
|
79
|
+
logger.debug(
|
|
80
|
+
`Registered CommonJS instrumentation for ${specifier} under ${copy.moduleName}`
|
|
81
|
+
)
|
|
82
|
+
})
|
|
84
83
|
} else if (format === 'module') {
|
|
85
84
|
registeredSpecifiers.set(url, specifier)
|
|
86
85
|
const modifiedUrl = new URL(url)
|
|
@@ -23,10 +23,10 @@ class ServerlessCollector {
|
|
|
23
23
|
* Constructs a new serverless collector instance with the give agent.
|
|
24
24
|
*
|
|
25
25
|
* @class
|
|
26
|
-
* @param pipePath
|
|
27
26
|
* @classdesc
|
|
28
27
|
* A helper class for wrapping modules with segments
|
|
29
28
|
* @param {Agent} agent - The agent this collector will use
|
|
29
|
+
* @param {string} pipePath path of the named pipe to the Lambda extension, if it's enabled
|
|
30
30
|
*/
|
|
31
31
|
constructor(agent, pipePath) {
|
|
32
32
|
this._agent = agent
|
|
@@ -45,7 +45,7 @@ class ServerlessCollector {
|
|
|
45
45
|
/**
|
|
46
46
|
* Sets the ARN to be sent up in the metadata.
|
|
47
47
|
*
|
|
48
|
-
* @param arn
|
|
48
|
+
* @param {string} arn Amazon Resource Name of the function
|
|
49
49
|
*/
|
|
50
50
|
setLambdaArn(arn) {
|
|
51
51
|
this.metadata.arn = arn
|
|
@@ -54,7 +54,7 @@ class ServerlessCollector {
|
|
|
54
54
|
/**
|
|
55
55
|
* Sets the function_version to be sent up in the metadata.
|
|
56
56
|
*
|
|
57
|
-
* @param function_version
|
|
57
|
+
* @param {string} function_version version indicator for Lambda function
|
|
58
58
|
*/
|
|
59
59
|
setLambdaFunctionVersion(function_version) {
|
|
60
60
|
this.metadata.function_version = function_version
|
|
@@ -84,7 +84,7 @@ class ServerlessCollector {
|
|
|
84
84
|
/**
|
|
85
85
|
* There is nothing to actually restart for serverless, so we do nothing.
|
|
86
86
|
*
|
|
87
|
-
* @param cb
|
|
87
|
+
* @param {Function} cb callback function, if any
|
|
88
88
|
*/
|
|
89
89
|
restart(cb) {
|
|
90
90
|
setImmediate(cb, null, CollectorResponse.success(null))
|
|
@@ -216,6 +216,7 @@ class ServerlessCollector {
|
|
|
216
216
|
* Constructs, serializes, and prints the final consolidated payload to stdout.
|
|
217
217
|
*
|
|
218
218
|
* @param {Function} cb The callback to invoke when finished.
|
|
219
|
+
* @returns {boolean} indicating if callback was defined and successfully executed
|
|
219
220
|
*/
|
|
220
221
|
flushPayload(cb) {
|
|
221
222
|
if (!this.enabled) {
|
|
@@ -270,7 +271,8 @@ class ServerlessCollector {
|
|
|
270
271
|
/**
|
|
271
272
|
* Writes payload to pipe
|
|
272
273
|
*
|
|
273
|
-
* @param payload
|
|
274
|
+
* @param {string} payload serialized stringified-JSON payload to flush
|
|
275
|
+
* @returns {boolean} whether or not flush was successful
|
|
274
276
|
*/
|
|
275
277
|
flushToPipeSync(payload) {
|
|
276
278
|
try {
|
package/lib/config/default.js
CHANGED
|
@@ -573,7 +573,7 @@ defaultConfig.definition = () => ({
|
|
|
573
573
|
*/
|
|
574
574
|
record_sql: {
|
|
575
575
|
formatter: allowList.bind(null, ['off', 'obfuscated', 'raw']),
|
|
576
|
-
default: '
|
|
576
|
+
default: 'obfuscated',
|
|
577
577
|
env: 'NEW_RELIC_RECORD_SQL'
|
|
578
578
|
},
|
|
579
579
|
|
|
@@ -1122,6 +1122,14 @@ defaultConfig.definition = () => ({
|
|
|
1122
1122
|
formatter: int,
|
|
1123
1123
|
default: 10000
|
|
1124
1124
|
}
|
|
1125
|
+
},
|
|
1126
|
+
batching: {
|
|
1127
|
+
formatter: boolean,
|
|
1128
|
+
default: true
|
|
1129
|
+
},
|
|
1130
|
+
compression: {
|
|
1131
|
+
formatter: boolean,
|
|
1132
|
+
default: true
|
|
1125
1133
|
}
|
|
1126
1134
|
},
|
|
1127
1135
|
/**
|
package/lib/grpc/connection.js
CHANGED
|
@@ -41,15 +41,17 @@ class GrpcConnection extends EventEmitter {
|
|
|
41
41
|
* Standard property setting/initialization, and sets an initial
|
|
42
42
|
* connection state of disconnected
|
|
43
43
|
*
|
|
44
|
-
* @param {object}
|
|
44
|
+
* @param {object} infiniteTracingConfig config item config.infinite_tracing
|
|
45
45
|
* @param {MetricAggregator} metrics metric aggregator, for supportability metrics
|
|
46
46
|
* @param {number} [reconnectDelayMs=15000] number of milliseconds to wait before reconnecting
|
|
47
47
|
* for error states that require a reconnect delay.
|
|
48
48
|
*/
|
|
49
|
-
constructor(
|
|
49
|
+
constructor(infiniteTracingConfig, metrics, reconnectDelayMs = DEFAULT_RECONNECT_DELAY_MS) {
|
|
50
50
|
super()
|
|
51
|
+
this._compression = infiniteTracingConfig.compression
|
|
52
|
+
this._method = infiniteTracingConfig.batching ? 'recordSpanBatch' : 'recordSpan'
|
|
51
53
|
|
|
52
|
-
this._reconnectDelayMs = reconnectDelayMs
|
|
54
|
+
this._reconnectDelayMs = reconnectDelayMs
|
|
53
55
|
|
|
54
56
|
this._metrics = metrics
|
|
55
57
|
this._setState(connectionStates.disconnected)
|
|
@@ -58,6 +60,7 @@ class GrpcConnection extends EventEmitter {
|
|
|
58
60
|
this._runId = null
|
|
59
61
|
this._requestHeadersMap = null
|
|
60
62
|
|
|
63
|
+
const traceObserverConfig = infiniteTracingConfig.trace_observer
|
|
61
64
|
this._endpoint = this.getTraceObserverEndpoint(traceObserverConfig)
|
|
62
65
|
|
|
63
66
|
this._client = null
|
|
@@ -70,18 +73,17 @@ class GrpcConnection extends EventEmitter {
|
|
|
70
73
|
* Allows setting of connection details _after_ object constructions
|
|
71
74
|
* but before the actual connection.
|
|
72
75
|
*
|
|
73
|
-
* @param {string} endpoint the GRPC server's endpoint
|
|
74
76
|
* @param {string} licenseKey the agent license key
|
|
75
77
|
* @param {string} runId the current agent run id (also called agent run token)
|
|
76
78
|
* @param {object} requestHeadersMap request headers map received from server connect.
|
|
77
79
|
* @param {string} [rootCerts] string of root (ca) certificates to attach to the connection.
|
|
80
|
+
* @returns {GrpcConnection} the instance of grpc connection
|
|
78
81
|
*/
|
|
79
82
|
setConnectionDetails(licenseKey, runId, requestHeadersMap, rootCerts) {
|
|
80
83
|
this._licenseKey = licenseKey
|
|
81
84
|
this._runId = runId
|
|
82
85
|
this._requestHeadersMap = requestHeadersMap
|
|
83
86
|
this._rootCerts = rootCerts
|
|
84
|
-
|
|
85
87
|
return this
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -95,9 +97,8 @@ class GrpcConnection extends EventEmitter {
|
|
|
95
97
|
* Used to indicate a transition from one connection state to
|
|
96
98
|
* the next. Also responsible for emitting the connect state event
|
|
97
99
|
*
|
|
98
|
-
* @param {
|
|
99
|
-
* @param {
|
|
100
|
-
* @param stream
|
|
100
|
+
* @param {number} state The connection state (See connectionStates above)
|
|
101
|
+
* @param {object} stream duplex stream
|
|
101
102
|
*/
|
|
102
103
|
_setState(state, stream = null) {
|
|
103
104
|
this._state = state
|
|
@@ -145,10 +146,11 @@ class GrpcConnection extends EventEmitter {
|
|
|
145
146
|
/**
|
|
146
147
|
* Method returns GRPC metadata for initial connection
|
|
147
148
|
*
|
|
148
|
-
* @param {string} licenseKey
|
|
149
|
-
* @param {string} runId
|
|
150
|
-
* @param requestHeadersMap
|
|
151
|
-
* @param env
|
|
149
|
+
* @param {string} licenseKey agent key
|
|
150
|
+
* @param {string} runId agent run id
|
|
151
|
+
* @param {object} requestHeadersMap map of request headers to include
|
|
152
|
+
* @param {object} env process.env
|
|
153
|
+
* @returns {object} grpc metadata
|
|
152
154
|
*/
|
|
153
155
|
_getMetadata(licenseKey, runId, requestHeadersMap, env) {
|
|
154
156
|
const metadata = new grpc.Metadata()
|
|
@@ -172,8 +174,8 @@ class GrpcConnection extends EventEmitter {
|
|
|
172
174
|
* Adds test metadata used to simulate connectivity issues
|
|
173
175
|
* when appropriate env vars are set
|
|
174
176
|
*
|
|
175
|
-
* @param {
|
|
176
|
-
* @param env
|
|
177
|
+
* @param {object} metadata metadata to set
|
|
178
|
+
* @param {object} env process.env
|
|
177
179
|
*/
|
|
178
180
|
_setTestMetadata(metadata, env) {
|
|
179
181
|
for (const [key, envVar] of Object.entries(GRPC_TEST_META)) {
|
|
@@ -236,7 +238,7 @@ class GrpcConnection extends EventEmitter {
|
|
|
236
238
|
* Events from the GRPC stream (a ClientDuplexStreamImpl) are the main way
|
|
237
239
|
* we communicate with the GRPC server.
|
|
238
240
|
*
|
|
239
|
-
* @param {
|
|
241
|
+
* @param {object} stream duplex stream
|
|
240
242
|
*/
|
|
241
243
|
_setupSpanStreamObservers(stream) {
|
|
242
244
|
// Node streams require all data sent by the server to be read before the end
|
|
@@ -263,7 +265,7 @@ class GrpcConnection extends EventEmitter {
|
|
|
263
265
|
// that the versioned Trace Observer is no longer available. Agents
|
|
264
266
|
// MUST NOT attempt to reconnect in this case
|
|
265
267
|
logger.info(
|
|
266
|
-
'[UNIMPLEMENTED]: Trace
|
|
268
|
+
'[UNIMPLEMENTED]: Trace Observer is no longer available. Shutting down connection.'
|
|
267
269
|
)
|
|
268
270
|
this._disconnect()
|
|
269
271
|
} else if (grpc.status[grpc.status.OK] === grpcStatusName) {
|
|
@@ -297,7 +299,8 @@ class GrpcConnection extends EventEmitter {
|
|
|
297
299
|
/**
|
|
298
300
|
* Creates the GRPC credentials needed
|
|
299
301
|
*
|
|
300
|
-
* @param grpcApi
|
|
302
|
+
* @param {object} grpcApi grpc lib
|
|
303
|
+
* @returns {object} ssl credentials
|
|
301
304
|
*/
|
|
302
305
|
_generateCredentials(grpcApi) {
|
|
303
306
|
let certBuffer = null
|
|
@@ -325,15 +328,17 @@ class GrpcConnection extends EventEmitter {
|
|
|
325
328
|
*
|
|
326
329
|
* Contains the actual logic that connects to the GRPC service.
|
|
327
330
|
* "Connection" can be a somewhat misleading term here. This method
|
|
328
|
-
* invokes the
|
|
331
|
+
* invokes the either `recordSpan` or `recordSpanBatch` remote procedure call. Behind the scenes
|
|
329
332
|
* this makes an http2 request with the metadata, and then returns
|
|
330
333
|
* a stream for further writing.
|
|
334
|
+
*
|
|
335
|
+
* @returns {object} stream duplex stream
|
|
331
336
|
*/
|
|
332
337
|
_connectSpans() {
|
|
333
338
|
if (!this._client) {
|
|
334
339
|
// Only create once to avoid potential memory leak.
|
|
335
340
|
// We create here (currently) for consistent error handling.
|
|
336
|
-
this._client = this._createClient(
|
|
341
|
+
this._client = this._createClient()
|
|
337
342
|
}
|
|
338
343
|
|
|
339
344
|
const metadata = this._getMetadata(
|
|
@@ -343,7 +348,7 @@ class GrpcConnection extends EventEmitter {
|
|
|
343
348
|
process.env
|
|
344
349
|
)
|
|
345
350
|
|
|
346
|
-
const stream = this._client.
|
|
351
|
+
const stream = this._client[this._method](metadata)
|
|
347
352
|
this._setupSpanStreamObservers(stream)
|
|
348
353
|
|
|
349
354
|
return stream
|
|
@@ -357,9 +362,10 @@ class GrpcConnection extends EventEmitter {
|
|
|
357
362
|
* the stream is closed and we do not have a handle to the client. Currently
|
|
358
363
|
* impacting grpc-js@1.2.11 and several earlier versions.
|
|
359
364
|
*
|
|
360
|
-
* @
|
|
365
|
+
* @returns {object} protobuf API for IngestService
|
|
361
366
|
*/
|
|
362
|
-
_createClient(
|
|
367
|
+
_createClient() {
|
|
368
|
+
const endpoint = this._endpoint
|
|
363
369
|
logger.trace('Creating gRPC client for: ', endpoint)
|
|
364
370
|
|
|
365
371
|
const packageDefinition = protoLoader.loadSync(PROTO_DEFINITION_PATH, PROTO_OPTIONS)
|
|
@@ -369,7 +375,25 @@ class GrpcConnection extends EventEmitter {
|
|
|
369
375
|
const traceApi = protoDescriptor.com.newrelic.trace.v1
|
|
370
376
|
|
|
371
377
|
const credentials = this._generateCredentials(grpc)
|
|
372
|
-
|
|
378
|
+
|
|
379
|
+
// If you want to use mock server use insecure creds
|
|
380
|
+
// const credentials = grpc.credentials.createInsecure()
|
|
381
|
+
|
|
382
|
+
const opts = {}
|
|
383
|
+
if (this._compression) {
|
|
384
|
+
// 2 = gzip compression
|
|
385
|
+
// see: https://github.com/grpc/grpc-node/blob/master/packages/grpc-js/src/compression-algorithms.ts#L21
|
|
386
|
+
opts['grpc.default_compression_algorithm'] = 2
|
|
387
|
+
this._metrics
|
|
388
|
+
.getOrCreateMetric(`${NAMES.INFINITE_TRACING.COMPRESSION}/enabled`)
|
|
389
|
+
.incrementCallCount()
|
|
390
|
+
} else {
|
|
391
|
+
this._metrics
|
|
392
|
+
.getOrCreateMetric(`${NAMES.INFINITE_TRACING.COMPRESSION}/disabled`)
|
|
393
|
+
.incrementCallCount()
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return new traceApi.IngestService(endpoint, credentials, opts)
|
|
373
397
|
}
|
|
374
398
|
}
|
|
375
399
|
|
|
@@ -6,6 +6,15 @@ service IngestService {
|
|
|
6
6
|
// Accepts a stream of Span messages, and returns an irregular stream of
|
|
7
7
|
// RecordStatus messages.
|
|
8
8
|
rpc RecordSpan(stream Span) returns (stream RecordStatus) {}
|
|
9
|
+
|
|
10
|
+
// Accepts a stream of SpanBatch messages, and returns an irregular
|
|
11
|
+
// stream of RecordStatus messages. This endpoint can be used to improve
|
|
12
|
+
// throughput when Span messages are small
|
|
13
|
+
rpc RecordSpanBatch(stream SpanBatch) returns (stream RecordStatus) {}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
message SpanBatch {
|
|
17
|
+
repeated Span spans = 1;
|
|
9
18
|
}
|
|
10
19
|
|
|
11
20
|
message Span {
|
|
@@ -27,3 +36,4 @@ message AttributeValue {
|
|
|
27
36
|
message RecordStatus {
|
|
28
37
|
uint64 messages_seen = 1;
|
|
29
38
|
}
|
|
39
|
+
|
|
@@ -20,13 +20,11 @@ module.exports = function initialize(agent, vision, moduleName, shim) {
|
|
|
20
20
|
|
|
21
21
|
shim.wrap(plugin, 'register', function wrapRegister(shim, register) {
|
|
22
22
|
return function wrappedRegister(server) {
|
|
23
|
-
shim.
|
|
23
|
+
if (!shim.isWrapped(server, 'decorate')) {
|
|
24
|
+
shim.wrap(server, 'decorate', wrapDecorate)
|
|
25
|
+
}
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
shim.unwrapOnce(server, 'decorate')
|
|
28
|
-
|
|
29
|
-
return ret
|
|
27
|
+
return register.apply(this, arguments)
|
|
30
28
|
}
|
|
31
29
|
})
|
|
32
30
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict'
|
|
7
|
+
const logger = require('../../logger').child({ component: 'nestjs' })
|
|
8
|
+
const semver = require('semver')
|
|
9
|
+
|
|
10
|
+
module.exports = function initialize(agent, core, moduleName, shim) {
|
|
11
|
+
const nestJsVersion = shim.require('./package.json').version
|
|
12
|
+
shim.setFramework(shim.NEST)
|
|
13
|
+
// Earliest version that runs in the tests
|
|
14
|
+
if (semver.lt(nestJsVersion, '8.0.0')) {
|
|
15
|
+
logger.debug(
|
|
16
|
+
`Not instrumenting Nest.js version ${nestJsVersion}; minimum instrumentable version is 8.0.0`
|
|
17
|
+
)
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
shim.wrap(core.BaseExceptionFilter.prototype, 'handleUnknownError', (shim, original) => {
|
|
22
|
+
return function wrappedHandleUnknownError(exception) {
|
|
23
|
+
const segment = shim.getActiveSegment()
|
|
24
|
+
const transaction = segment?.transaction
|
|
25
|
+
if (transaction) {
|
|
26
|
+
shim.agent.errors.add(transaction, exception)
|
|
27
|
+
logger.trace(exception, 'Captured error handled by Nest.js exception filter.')
|
|
28
|
+
} else {
|
|
29
|
+
logger.trace(
|
|
30
|
+
exception,
|
|
31
|
+
'Ignoring error handled by Nest.js exception filter: not in a transaction'
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return original.apply(this, arguments)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|