newrelic 9.12.1 → 9.14.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 +12 -0
- package/THIRD_PARTY_NOTICES.md +215 -5
- package/api.js +70 -0
- package/lib/config/default.js +62 -0
- package/lib/errors/error-collector.js +6 -0
- package/lib/errors/index.js +37 -0
- package/lib/instrumentation/core/http-outbound.js +2 -5
- package/lib/metrics/normalizer/tx_segment.js +21 -22
- package/lib/shimmer.js +44 -28
- package/package.json +3 -3
package/NEWS.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
### v9.14.0 (2023-03-23)
|
|
2
|
+
|
|
3
|
+
* 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).
|
|
4
|
+
|
|
5
|
+
### v9.13.0 (2023-03-20)
|
|
6
|
+
|
|
7
|
+
* 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.
|
|
8
|
+
|
|
9
|
+
* 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`.
|
|
10
|
+
|
|
11
|
+
* Added default configuration for security agent.
|
|
12
|
+
|
|
1
13
|
### v9.12.1 (2023-03-15)
|
|
2
14
|
|
|
3
15
|
* Added ability to mark errors as expected when using `newrelic.noticeError`, by adding an optional boolean:
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -74,6 +74,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
74
74
|
**[optionalDependencies](#optionalDependencies)**
|
|
75
75
|
|
|
76
76
|
* [@contrast/fn-inspect](#contrastfn-inspect)
|
|
77
|
+
* [@newrelic/native-metrics](#newrelicnative-metrics)
|
|
77
78
|
|
|
78
79
|
**[Additional Licenses](#additional-licenses)**
|
|
79
80
|
|
|
@@ -84,7 +85,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
84
85
|
|
|
85
86
|
### @grpc/grpc-js
|
|
86
87
|
|
|
87
|
-
This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.
|
|
88
|
+
This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.8.12](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.8.12)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.8.12/LICENSE):
|
|
88
89
|
|
|
89
90
|
```
|
|
90
91
|
Apache License
|
|
@@ -293,7 +294,7 @@ This product includes source derived from [@grpc/grpc-js](https://github.com/grp
|
|
|
293
294
|
|
|
294
295
|
### @grpc/proto-loader
|
|
295
296
|
|
|
296
|
-
This product includes source derived from [@grpc/proto-loader](https://github.com/grpc/grpc-node) ([v0.7.
|
|
297
|
+
This product includes source derived from [@grpc/proto-loader](https://github.com/grpc/grpc-node) ([v0.7.5](https://github.com/grpc/grpc-node/tree/v0.7.5)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/blob/v0.7.5/LICENSE):
|
|
297
298
|
|
|
298
299
|
```
|
|
299
300
|
Apache License
|
|
@@ -502,7 +503,7 @@ This product includes source derived from [@grpc/proto-loader](https://github.co
|
|
|
502
503
|
|
|
503
504
|
### @newrelic/aws-sdk
|
|
504
505
|
|
|
505
|
-
This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v5.0.
|
|
506
|
+
This product includes source derived from [@newrelic/aws-sdk](https://github.com/newrelic/node-newrelic-aws-sdk) ([v5.0.2](https://github.com/newrelic/node-newrelic-aws-sdk/tree/v5.0.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-aws-sdk/blob/v5.0.2/LICENSE):
|
|
506
507
|
|
|
507
508
|
```
|
|
508
509
|
Apache License
|
|
@@ -710,7 +711,7 @@ This product includes source derived from [@newrelic/aws-sdk](https://github.com
|
|
|
710
711
|
|
|
711
712
|
### @newrelic/koa
|
|
712
713
|
|
|
713
|
-
This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v7.
|
|
714
|
+
This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v7.1.1](https://github.com/newrelic/node-newrelic-koa/tree/v7.1.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v7.1.1/LICENSE):
|
|
714
715
|
|
|
715
716
|
```
|
|
716
717
|
Apache License
|
|
@@ -1255,7 +1256,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
1255
1256
|
|
|
1256
1257
|
### readable-stream
|
|
1257
1258
|
|
|
1258
|
-
This product includes source derived from [readable-stream](https://github.com/nodejs/readable-stream) ([v3.6.
|
|
1259
|
+
This product includes source derived from [readable-stream](https://github.com/nodejs/readable-stream) ([v3.6.2](https://github.com/nodejs/readable-stream/tree/v3.6.2)), distributed under the [MIT License](https://github.com/nodejs/readable-stream/blob/v3.6.2/LICENSE):
|
|
1259
1260
|
|
|
1260
1261
|
```
|
|
1261
1262
|
Node.js is licensed for use as follows:
|
|
@@ -9452,6 +9453,215 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
9452
9453
|
|
|
9453
9454
|
```
|
|
9454
9455
|
|
|
9456
|
+
### @newrelic/native-metrics
|
|
9457
|
+
|
|
9458
|
+
This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v9.0.0](https://github.com/newrelic/node-native-metrics/tree/v9.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v9.0.0/LICENSE):
|
|
9459
|
+
|
|
9460
|
+
```
|
|
9461
|
+
Apache License
|
|
9462
|
+
Version 2.0, January 2004
|
|
9463
|
+
http://www.apache.org/licenses/
|
|
9464
|
+
|
|
9465
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9466
|
+
|
|
9467
|
+
1. Definitions.
|
|
9468
|
+
|
|
9469
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
9470
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
9471
|
+
|
|
9472
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
9473
|
+
the copyright owner that is granting the License.
|
|
9474
|
+
|
|
9475
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
9476
|
+
other entities that control, are controlled by, or are under common
|
|
9477
|
+
control with that entity. For the purposes of this definition,
|
|
9478
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
9479
|
+
direction or management of such entity, whether by contract or
|
|
9480
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
9481
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
9482
|
+
|
|
9483
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
9484
|
+
exercising permissions granted by this License.
|
|
9485
|
+
|
|
9486
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
9487
|
+
including but not limited to software source code, documentation
|
|
9488
|
+
source, and configuration files.
|
|
9489
|
+
|
|
9490
|
+
"Object" form shall mean any form resulting from mechanical
|
|
9491
|
+
transformation or translation of a Source form, including but
|
|
9492
|
+
not limited to compiled object code, generated documentation,
|
|
9493
|
+
and conversions to other media types.
|
|
9494
|
+
|
|
9495
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
9496
|
+
Object form, made available under the License, as indicated by a
|
|
9497
|
+
copyright notice that is included in or attached to the work
|
|
9498
|
+
(an example is provided in the Appendix below).
|
|
9499
|
+
|
|
9500
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
9501
|
+
form, that is based on (or derived from) the Work and for which the
|
|
9502
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
9503
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
9504
|
+
of this License, Derivative Works shall not include works that remain
|
|
9505
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
9506
|
+
the Work and Derivative Works thereof.
|
|
9507
|
+
|
|
9508
|
+
"Contribution" shall mean any work of authorship, including
|
|
9509
|
+
the original version of the Work and any modifications or additions
|
|
9510
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
9511
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
9512
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
9513
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
9514
|
+
means any form of electronic, verbal, or written communication sent
|
|
9515
|
+
to the Licensor or its representatives, including but not limited to
|
|
9516
|
+
communication on electronic mailing lists, source code control systems,
|
|
9517
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
9518
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
9519
|
+
excluding communication that is conspicuously marked or otherwise
|
|
9520
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
9521
|
+
|
|
9522
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
9523
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
9524
|
+
subsequently incorporated within the Work.
|
|
9525
|
+
|
|
9526
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
9527
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
9528
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
9529
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
9530
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
9531
|
+
Work and such Derivative Works in Source or Object form.
|
|
9532
|
+
|
|
9533
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
9534
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
9535
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
9536
|
+
(except as stated in this section) patent license to make, have made,
|
|
9537
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
9538
|
+
where such license applies only to those patent claims licensable
|
|
9539
|
+
by such Contributor that are necessarily infringed by their
|
|
9540
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
9541
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
9542
|
+
institute patent litigation against any entity (including a
|
|
9543
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
9544
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
9545
|
+
or contributory patent infringement, then any patent licenses
|
|
9546
|
+
granted to You under this License for that Work shall terminate
|
|
9547
|
+
as of the date such litigation is filed.
|
|
9548
|
+
|
|
9549
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
9550
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
9551
|
+
modifications, and in Source or Object form, provided that You
|
|
9552
|
+
meet the following conditions:
|
|
9553
|
+
|
|
9554
|
+
(a) You must give any other recipients of the Work or
|
|
9555
|
+
Derivative Works a copy of this License; and
|
|
9556
|
+
|
|
9557
|
+
(b) You must cause any modified files to carry prominent notices
|
|
9558
|
+
stating that You changed the files; and
|
|
9559
|
+
|
|
9560
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
9561
|
+
that You distribute, all copyright, patent, trademark, and
|
|
9562
|
+
attribution notices from the Source form of the Work,
|
|
9563
|
+
excluding those notices that do not pertain to any part of
|
|
9564
|
+
the Derivative Works; and
|
|
9565
|
+
|
|
9566
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
9567
|
+
distribution, then any Derivative Works that You distribute must
|
|
9568
|
+
include a readable copy of the attribution notices contained
|
|
9569
|
+
within such NOTICE file, excluding those notices that do not
|
|
9570
|
+
pertain to any part of the Derivative Works, in at least one
|
|
9571
|
+
of the following places: within a NOTICE text file distributed
|
|
9572
|
+
as part of the Derivative Works; within the Source form or
|
|
9573
|
+
documentation, if provided along with the Derivative Works; or,
|
|
9574
|
+
within a display generated by the Derivative Works, if and
|
|
9575
|
+
wherever such third-party notices normally appear. The contents
|
|
9576
|
+
of the NOTICE file are for informational purposes only and
|
|
9577
|
+
do not modify the License. You may add Your own attribution
|
|
9578
|
+
notices within Derivative Works that You distribute, alongside
|
|
9579
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
9580
|
+
that such additional attribution notices cannot be construed
|
|
9581
|
+
as modifying the License.
|
|
9582
|
+
|
|
9583
|
+
You may add Your own copyright statement to Your modifications and
|
|
9584
|
+
may provide additional or different license terms and conditions
|
|
9585
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
9586
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
9587
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
9588
|
+
the conditions stated in this License.
|
|
9589
|
+
|
|
9590
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
9591
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
9592
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
9593
|
+
this License, without any additional terms or conditions.
|
|
9594
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
9595
|
+
the terms of any separate license agreement you may have executed
|
|
9596
|
+
with Licensor regarding such Contributions.
|
|
9597
|
+
|
|
9598
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
9599
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
9600
|
+
except as required for reasonable and customary use in describing the
|
|
9601
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
9602
|
+
|
|
9603
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
9604
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
9605
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
9606
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
9607
|
+
implied, including, without limitation, any warranties or conditions
|
|
9608
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
9609
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
9610
|
+
appropriateness of using or redistributing the Work and assume any
|
|
9611
|
+
risks associated with Your exercise of permissions under this License.
|
|
9612
|
+
|
|
9613
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
9614
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
9615
|
+
unless required by applicable law (such as deliberate and grossly
|
|
9616
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
9617
|
+
liable to You for damages, including any direct, indirect, special,
|
|
9618
|
+
incidental, or consequential damages of any character arising as a
|
|
9619
|
+
result of this License or out of the use or inability to use the
|
|
9620
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
9621
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
9622
|
+
other commercial damages or losses), even if such Contributor
|
|
9623
|
+
has been advised of the possibility of such damages.
|
|
9624
|
+
|
|
9625
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
9626
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
9627
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
9628
|
+
or other liability obligations and/or rights consistent with this
|
|
9629
|
+
License. However, in accepting such obligations, You may act only
|
|
9630
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
9631
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
9632
|
+
defend, and hold each Contributor harmless for any liability
|
|
9633
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
9634
|
+
of your accepting any such warranty or additional liability.
|
|
9635
|
+
|
|
9636
|
+
END OF TERMS AND CONDITIONS
|
|
9637
|
+
|
|
9638
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
9639
|
+
|
|
9640
|
+
To apply the Apache License to your work, attach the following
|
|
9641
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
9642
|
+
replaced with your own identifying information. (Don't include
|
|
9643
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
9644
|
+
comment syntax for the file format. We also recommend that a
|
|
9645
|
+
file or class name and description of purpose be included on the
|
|
9646
|
+
same "printed page" as the copyright notice for easier
|
|
9647
|
+
identification within third-party archives.
|
|
9648
|
+
|
|
9649
|
+
Copyright [yyyy] [name of copyright owner]
|
|
9650
|
+
|
|
9651
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9652
|
+
you may not use this file except in compliance with the License.
|
|
9653
|
+
You may obtain a copy of the License at
|
|
9654
|
+
|
|
9655
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9656
|
+
|
|
9657
|
+
Unless required by applicable law or agreed to in writing, software
|
|
9658
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9659
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9660
|
+
See the License for the specific language governing permissions and
|
|
9661
|
+
limitations under the License.
|
|
9662
|
+
|
|
9663
|
+
```
|
|
9664
|
+
|
|
9455
9665
|
## Additional Licenses
|
|
9456
9666
|
|
|
9457
9667
|
### Symantec
|
package/api.js
CHANGED
|
@@ -28,6 +28,7 @@ const ATTR_DEST = require('./lib/config/attribute-filter').DESTINATIONS
|
|
|
28
28
|
const MODULE_TYPE = require('./lib/shim/constants').MODULE_TYPE
|
|
29
29
|
const NAMES = require('./lib/metrics/names')
|
|
30
30
|
const obfuscate = require('./lib/util/sql/obfuscate')
|
|
31
|
+
const { DESTINATIONS } = require('./lib/config/attribute-filter')
|
|
31
32
|
|
|
32
33
|
/*
|
|
33
34
|
*
|
|
@@ -1694,6 +1695,28 @@ API.prototype.obfuscateSql = function obfuscateSql(sql, dialect) {
|
|
|
1694
1695
|
return obfuscate(sql, dialect)
|
|
1695
1696
|
}
|
|
1696
1697
|
|
|
1698
|
+
/**
|
|
1699
|
+
* Assigns `enduser.id` attribute on transaction and trace events. It will also
|
|
1700
|
+
* assign the attribute to errors if they occur within a transaction.
|
|
1701
|
+
*
|
|
1702
|
+
* @param {string} id a unique identifier used to set the `enduser.id` attribute
|
|
1703
|
+
*/
|
|
1704
|
+
API.prototype.setUserID = function setUserID(id) {
|
|
1705
|
+
const metric = this.agent.metrics.getOrCreateMetric(NAMES.SUPPORTABILITY.API + '/setUserID')
|
|
1706
|
+
metric.incrementCallCount()
|
|
1707
|
+
|
|
1708
|
+
const transaction = this.agent.tracer.getTransaction()
|
|
1709
|
+
|
|
1710
|
+
if (!(id && transaction)) {
|
|
1711
|
+
logger.warn(
|
|
1712
|
+
'User id is empty or not in a transaction, not assigning `enduser.id` attribute to transaction events, trace events, and/or errors.'
|
|
1713
|
+
)
|
|
1714
|
+
return
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
transaction.trace.attributes.addAttribute(DESTINATIONS.TRANS_COMMON, 'enduser.id', id)
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1697
1720
|
/**
|
|
1698
1721
|
* Function for removing invalid attribute key/value pairs from an object
|
|
1699
1722
|
*
|
|
@@ -1716,4 +1739,51 @@ function _filterAttributes(attributes, name) {
|
|
|
1716
1739
|
return filteredAttributes
|
|
1717
1740
|
}
|
|
1718
1741
|
|
|
1742
|
+
/**
|
|
1743
|
+
* Function for adding a custom callback to generate Error Group names, which
|
|
1744
|
+
* will be used by the Errors Inbox to group similar errors together via the `error.group.name`
|
|
1745
|
+
* agent attribute.
|
|
1746
|
+
*
|
|
1747
|
+
* Provided functions must return a string, and receive an object as an argument,
|
|
1748
|
+
* which contains information related to the Error that occurred, and has the
|
|
1749
|
+
* following format:
|
|
1750
|
+
*
|
|
1751
|
+
* ```
|
|
1752
|
+
* {
|
|
1753
|
+
* customAttributes: object,
|
|
1754
|
+
* 'request.uri': string,
|
|
1755
|
+
* 'http.statusCode': string,
|
|
1756
|
+
* 'http.method': string,
|
|
1757
|
+
* error: Error,
|
|
1758
|
+
* 'error.expected': boolean
|
|
1759
|
+
* }
|
|
1760
|
+
* ```
|
|
1761
|
+
*
|
|
1762
|
+
* Calling this function multiple times will replace previously defined functions
|
|
1763
|
+
*
|
|
1764
|
+
* @param {Function} callback - callback function to generate `error.group.name` attribute
|
|
1765
|
+
* @example
|
|
1766
|
+
* function myCallback(metadata) {
|
|
1767
|
+
* if (metadata['http.statusCode'] === '400') {
|
|
1768
|
+
* return 'Bad User Input'
|
|
1769
|
+
* }
|
|
1770
|
+
* }
|
|
1771
|
+
* newrelic.setErrorGroupCallback(myCallback)
|
|
1772
|
+
*/
|
|
1773
|
+
API.prototype.setErrorGroupCallback = function setErrorGroupCallback(callback) {
|
|
1774
|
+
const metric = this.agent.metrics.getOrCreateMetric(
|
|
1775
|
+
NAMES.SUPPORTABILITY.API + '/setErrorGroupCallback'
|
|
1776
|
+
)
|
|
1777
|
+
metric.incrementCallCount()
|
|
1778
|
+
|
|
1779
|
+
if (!this.shim.isFunction(callback) || this.shim.isPromise(callback)) {
|
|
1780
|
+
logger.warn(
|
|
1781
|
+
'Error Group callback must be a synchronous function, Error Group attribute will not be added'
|
|
1782
|
+
)
|
|
1783
|
+
return
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
this.agent.errors.errorGroupCallback = callback
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1719
1789
|
module.exports = API
|
package/lib/config/default.js
CHANGED
|
@@ -1256,6 +1256,68 @@ defaultConfig.definition = () => ({
|
|
|
1256
1256
|
default: ''
|
|
1257
1257
|
}
|
|
1258
1258
|
}
|
|
1259
|
+
},
|
|
1260
|
+
/**
|
|
1261
|
+
* Security agent configurations
|
|
1262
|
+
*/
|
|
1263
|
+
security: {
|
|
1264
|
+
/**
|
|
1265
|
+
* Toggles the generation of security events by the security agent.
|
|
1266
|
+
*/
|
|
1267
|
+
enabled: {
|
|
1268
|
+
formatter: boolean,
|
|
1269
|
+
default: false
|
|
1270
|
+
},
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* Flag to tell the Node.js agent to load the security agent.
|
|
1274
|
+
* This property is read only once at application start.
|
|
1275
|
+
*/
|
|
1276
|
+
agent: {
|
|
1277
|
+
enabled: {
|
|
1278
|
+
formatter: boolean,
|
|
1279
|
+
default: false
|
|
1280
|
+
}
|
|
1281
|
+
},
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Security agent provides two modes: IAST and RASP. Default is IAST.
|
|
1285
|
+
*/
|
|
1286
|
+
mode: {
|
|
1287
|
+
formatter: allowList.bind(null, ['IAST', 'RASP']),
|
|
1288
|
+
default: 'IAST'
|
|
1289
|
+
},
|
|
1290
|
+
|
|
1291
|
+
/**
|
|
1292
|
+
* Security agent validator URL. Must be prefixed with wss://.
|
|
1293
|
+
*/
|
|
1294
|
+
validator_service_url: {
|
|
1295
|
+
default: 'wss://csec.nr-data.net'
|
|
1296
|
+
},
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* Provide ability to toggle sending security events for the following rules.
|
|
1300
|
+
*/
|
|
1301
|
+
detection: {
|
|
1302
|
+
rci: {
|
|
1303
|
+
enabled: {
|
|
1304
|
+
formatter: boolean,
|
|
1305
|
+
default: true
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
rxss: {
|
|
1309
|
+
enabled: {
|
|
1310
|
+
formatter: boolean,
|
|
1311
|
+
default: true
|
|
1312
|
+
}
|
|
1313
|
+
},
|
|
1314
|
+
deserialization: {
|
|
1315
|
+
enabled: {
|
|
1316
|
+
formatter: boolean,
|
|
1317
|
+
default: true
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1259
1321
|
}
|
|
1260
1322
|
})
|
|
1261
1323
|
|
|
@@ -36,6 +36,8 @@ class ErrorCollector {
|
|
|
36
36
|
this.seenStringsByTransaction = Object.create(null)
|
|
37
37
|
|
|
38
38
|
this.traceAggregator.on('starting error_data data send.', this._onSendErrorTrace.bind(this))
|
|
39
|
+
|
|
40
|
+
this.errorGroupCallback = null
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
_onSendErrorTrace() {
|
|
@@ -330,6 +332,10 @@ class ErrorCollector {
|
|
|
330
332
|
return false
|
|
331
333
|
}
|
|
332
334
|
|
|
335
|
+
if (this.errorGroupCallback) {
|
|
336
|
+
exception.errorGroupCallback = this.errorGroupCallback
|
|
337
|
+
}
|
|
338
|
+
|
|
333
339
|
const errorTrace = createError(transaction, exception, this.config)
|
|
334
340
|
this._maybeRecordErrorMetrics(errorTrace, transaction)
|
|
335
341
|
|
package/lib/errors/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
const logger = require('../logger').child({ component: 'errors_lib' })
|
|
8
9
|
const DESTINATIONS = require('../config/attribute-filter').DESTINATIONS
|
|
9
10
|
const props = require('../util/properties')
|
|
10
11
|
const urltils = require('../util/urltils')
|
|
@@ -25,6 +26,7 @@ class Exception {
|
|
|
25
26
|
this.customAttributes = customAttributes || {}
|
|
26
27
|
this.agentAttributes = agentAttributes || {}
|
|
27
28
|
this._expected = expected
|
|
29
|
+
this.errorGroupCallback = null
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
getErrorDetails(config) {
|
|
@@ -107,9 +109,44 @@ function createError(transaction, exception, config) {
|
|
|
107
109
|
params.intrinsics[ERROR_EXPECTED_PATH] =
|
|
108
110
|
exception._expected || errorHelper.isExpected(type, message, transaction, config, urltils)
|
|
109
111
|
|
|
112
|
+
maybeAddAgentAttributes(params, exception)
|
|
113
|
+
|
|
110
114
|
return [0, name, message, type, params]
|
|
111
115
|
}
|
|
112
116
|
|
|
117
|
+
function isValidErrorGroupOutput(output) {
|
|
118
|
+
return (typeof output === 'string' || output instanceof String) && output !== ''
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function maybeAddAgentAttributes(attributes, exception) {
|
|
122
|
+
if (exception.errorGroupCallback) {
|
|
123
|
+
const callbackInput = {
|
|
124
|
+
'error': exception.error,
|
|
125
|
+
'customAttributes': Object.assign({}, attributes.userAttributes),
|
|
126
|
+
'request.uri': attributes.agentAttributes['request.uri'],
|
|
127
|
+
'http.statusCode': attributes.agentAttributes['http.statusCode'],
|
|
128
|
+
'http.method': attributes.agentAttributes['request.method'],
|
|
129
|
+
'error.expected': attributes.intrinsics[ERROR_EXPECTED_PATH]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const callbackOutput = exception.errorGroupCallback(callbackInput)
|
|
134
|
+
|
|
135
|
+
if (!isValidErrorGroupOutput(callbackOutput)) {
|
|
136
|
+
logger.warn('Function provided via setErrorGroupCallback return value malformed')
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
attributes.agentAttributes['error.group.name'] = callbackOutput
|
|
141
|
+
} catch (err) {
|
|
142
|
+
logger.warn(
|
|
143
|
+
err,
|
|
144
|
+
'Function provided via setErrorGroupCallback failed, not generating `error.group.name`'
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
113
150
|
function maybeAddUserAttributes(userAttributes, exception, config) {
|
|
114
151
|
const customAttributes = exception.customAttributes
|
|
115
152
|
if (!config.high_security && config.api.custom_attributes_enabled && customAttributes) {
|
|
@@ -167,11 +167,8 @@ function maybeAddDtCatHeaders(agent, transaction, outboundHeaders, headers = {})
|
|
|
167
167
|
if (agent.config.distributed_tracing.enabled) {
|
|
168
168
|
if (!!(headers[symbols.disableDT] || headers['x-new-relic-disable-dt'])) {
|
|
169
169
|
logger.trace('Distributed tracing disabled by instrumentation.')
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
// the same issue that we had to change this to a string header
|
|
173
|
-
// see: https://github.com/newrelic/node-newrelic-aws-sdk/issues/168
|
|
174
|
-
delete headers['x-new-relic-disable-dt']
|
|
170
|
+
// do not try to delete this header because AWS will fail with signature fail
|
|
171
|
+
// See: https://github.com/newrelic/node-newrelic/issues/1549
|
|
175
172
|
} else {
|
|
176
173
|
transaction.insertDistributedTraceHeaders(outboundHeaders)
|
|
177
174
|
}
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
/* eslint sonarjs/cognitive-complexity: ["error", 17] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
-
|
|
10
8
|
const logger = require('../../logger').child({ component: 'tx_segment_normalizer' })
|
|
11
9
|
|
|
12
10
|
module.exports = TxSegmentNormalizer
|
|
@@ -17,7 +15,7 @@ function TxSegmentNormalizer() {
|
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* This normalize method is wicked. The best bet is to read the spec:
|
|
20
|
-
* https://
|
|
18
|
+
* https://source.datanerd.us/agents/agent-specs/blob/main/Metric-Name-Rules-PORTED.md
|
|
21
19
|
*
|
|
22
20
|
* A copy paste of the rules that were followed:
|
|
23
21
|
* 1. Find the first rule where the prefix key matches the prefix of the
|
|
@@ -31,11 +29,28 @@ function TxSegmentNormalizer() {
|
|
|
31
29
|
* 6. Join together the modified segments with slashes, and re-prepend the prefix.
|
|
32
30
|
*
|
|
33
31
|
* @param {string} path - The transaction metric path to normalize.
|
|
34
|
-
* @returns {
|
|
32
|
+
* @returns {{ignore: boolean, matched: boolean, value: string}} - The results of normalizing the given path.
|
|
35
33
|
*/
|
|
36
34
|
TxSegmentNormalizer.prototype.normalize = function normalize(path) {
|
|
37
35
|
let currentTerm
|
|
38
36
|
let prefix
|
|
37
|
+
let result
|
|
38
|
+
let prev
|
|
39
|
+
|
|
40
|
+
const normalizeParts = (part, idx, parts) => {
|
|
41
|
+
if (part === '' && idx + 1 === parts.length) {
|
|
42
|
+
return // if this is the last one, don't iterate
|
|
43
|
+
}
|
|
44
|
+
if (currentTerm.terms.indexOf(part) === -1) {
|
|
45
|
+
if (prev === '*') {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
result.push((prev = '*'))
|
|
49
|
+
} else {
|
|
50
|
+
result.push((prev = part))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
for (let i = 0; i < this.terms.length; i++) {
|
|
40
55
|
currentTerm = this.terms[i]
|
|
41
56
|
prefix = currentTerm.prefix
|
|
@@ -44,26 +59,10 @@ TxSegmentNormalizer.prototype.normalize = function normalize(path) {
|
|
|
44
59
|
}
|
|
45
60
|
const fragment = path.slice(prefix.length)
|
|
46
61
|
const parts = fragment.split('/')
|
|
47
|
-
|
|
48
|
-
let prev
|
|
49
|
-
let segment
|
|
50
|
-
|
|
51
|
-
for (let j = 0; j < parts.length; j++) {
|
|
52
|
-
segment = parts[j]
|
|
62
|
+
result = []
|
|
53
63
|
|
|
54
|
-
|
|
55
|
-
break
|
|
56
|
-
}
|
|
64
|
+
parts.forEach(normalizeParts)
|
|
57
65
|
|
|
58
|
-
if (currentTerm.terms.indexOf(segment) === -1) {
|
|
59
|
-
if (prev === '*') {
|
|
60
|
-
continue
|
|
61
|
-
}
|
|
62
|
-
result.push((prev = '*'))
|
|
63
|
-
} else {
|
|
64
|
-
result.push((prev = segment))
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
66
|
logger.trace('Normalizing %s because of rule: %s', path, currentTerm)
|
|
68
67
|
return {
|
|
69
68
|
matched: true, // To match MetricNormalizer
|
package/lib/shimmer.js
CHANGED
|
@@ -352,33 +352,15 @@ const shimmer = (module.exports = {
|
|
|
352
352
|
shimmer.unwrapMethod(Module, 'Module', '_load')
|
|
353
353
|
},
|
|
354
354
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
Object.
|
|
364
|
-
const core = CORE_INSTRUMENTATION[mojule]
|
|
365
|
-
const filePath = path.join(__dirname, 'instrumentation', 'core', core.file)
|
|
366
|
-
let uninstrumented = null
|
|
367
|
-
|
|
368
|
-
try {
|
|
369
|
-
uninstrumented = require(mojule)
|
|
370
|
-
} catch (err) {
|
|
371
|
-
logger.trace('Could not load core module %s got error %s', mojule, err)
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
const shim = shims.createShimFromType(core.type, agent, mojule, mojule)
|
|
375
|
-
applyDebugState(shim, core)
|
|
376
|
-
_firstPartyInstrumentation(agent, filePath, shim, uninstrumented, mojule)
|
|
377
|
-
})
|
|
378
|
-
|
|
379
|
-
// Register all the first-party instrumentations.
|
|
380
|
-
Object.keys(INSTRUMENTATIONS).forEach(function forEachInstrumentation(moduleName) {
|
|
381
|
-
const instrInfo = INSTRUMENTATIONS[moduleName]
|
|
355
|
+
/**
|
|
356
|
+
* Registers all instrumentation for "first-party" libraries.
|
|
357
|
+
*
|
|
358
|
+
* This is all 3rd party libs with the exception of the domain library in Node.js core
|
|
359
|
+
*
|
|
360
|
+
* @param {object} agent NR agent
|
|
361
|
+
*/
|
|
362
|
+
registerFirstPartyInstrumentation(agent) {
|
|
363
|
+
for (const [moduleName, instrInfo] of Object.entries(INSTRUMENTATIONS)) {
|
|
382
364
|
if (instrInfo.module) {
|
|
383
365
|
// Because external instrumentations can change independent of
|
|
384
366
|
// the agent core, we don't want breakages in them to entirely
|
|
@@ -401,7 +383,7 @@ const shimmer = (module.exports = {
|
|
|
401
383
|
onRequire: _firstPartyInstrumentation.bind(null, agent, fileName)
|
|
402
384
|
})
|
|
403
385
|
}
|
|
404
|
-
}
|
|
386
|
+
}
|
|
405
387
|
|
|
406
388
|
// Even though domain is a core module we add it as a registered
|
|
407
389
|
// instrumentation to be lazy-loaded because we do not want to cause domain
|
|
@@ -414,6 +396,40 @@ const shimmer = (module.exports = {
|
|
|
414
396
|
})
|
|
415
397
|
},
|
|
416
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Registers all instrumentation for Node.js core libraries.
|
|
401
|
+
*
|
|
402
|
+
* @param {object} agent NR agent
|
|
403
|
+
*/
|
|
404
|
+
registerCoreInstrumentation(agent) {
|
|
405
|
+
// Instrument global.
|
|
406
|
+
const globalShim = new shims.Shim(agent, 'globals', 'globals')
|
|
407
|
+
applyDebugState(globalShim, global)
|
|
408
|
+
const globalsFilepath = path.join(__dirname, 'instrumentation', 'core', 'globals.js')
|
|
409
|
+
_firstPartyInstrumentation(agent, globalsFilepath, globalShim, global, 'globals')
|
|
410
|
+
|
|
411
|
+
// Instrument each of the core modules.
|
|
412
|
+
for (const [mojule, core] of Object.entries(CORE_INSTRUMENTATION)) {
|
|
413
|
+
const filePath = path.join(__dirname, 'instrumentation', 'core', core.file)
|
|
414
|
+
let uninstrumented = null
|
|
415
|
+
|
|
416
|
+
try {
|
|
417
|
+
uninstrumented = require(mojule)
|
|
418
|
+
} catch (err) {
|
|
419
|
+
logger.trace('Could not load core module %s got error %s', mojule, err)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const shim = shims.createShimFromType(core.type, agent, mojule, mojule)
|
|
423
|
+
applyDebugState(shim, core)
|
|
424
|
+
_firstPartyInstrumentation(agent, filePath, shim, uninstrumented, mojule)
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
|
|
428
|
+
bootstrapInstrumentation: function bootstrapInstrumentation(agent) {
|
|
429
|
+
shimmer.registerCoreInstrumentation(agent)
|
|
430
|
+
shimmer.registerFirstPartyInstrumentation(agent)
|
|
431
|
+
},
|
|
432
|
+
|
|
417
433
|
registerInstrumentation: function registerInstrumentation(opts) {
|
|
418
434
|
if (!hasValidRegisterOptions(opts)) {
|
|
419
435
|
return
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.14.0",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
"newrelic-naming-rules": "./bin/test-naming-rules.js"
|
|
180
180
|
},
|
|
181
181
|
"dependencies": {
|
|
182
|
-
"@grpc/grpc-js": "^1.8.
|
|
182
|
+
"@grpc/grpc-js": "^1.8.10",
|
|
183
183
|
"@grpc/proto-loader": "^0.7.5",
|
|
184
184
|
"@newrelic/aws-sdk": "^5.0.2",
|
|
185
185
|
"@newrelic/koa": "^7.1.1",
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
"https-proxy-agent": "^5.0.0",
|
|
190
190
|
"json-bigint": "^1.0.0",
|
|
191
191
|
"json-stringify-safe": "^5.0.0",
|
|
192
|
-
"readable-stream": "^3.6.
|
|
192
|
+
"readable-stream": "^3.6.1",
|
|
193
193
|
"semver": "^5.3.0",
|
|
194
194
|
"winston-transport": "^4.5.0"
|
|
195
195
|
},
|