newrelic 9.8.1 → 9.10.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 +35 -0
- package/THIRD_PARTY_NOTICES.md +35 -285
- package/api.js +16 -1
- package/lib/collector/facts.js +0 -28
- package/lib/config/default.js +49 -1
- package/lib/config/formatters.js +16 -0
- package/lib/config/index.js +17 -4
- package/lib/instrumentation/core/http-outbound.js +1 -0
- package/lib/instrumentation/core/http.js +1 -1
- package/lib/instrumentations.js +16 -1
- package/lib/metrics/names.js +0 -1
- package/lib/serverless/api-gateway.js +52 -9
- package/lib/shim/constants.js +7 -1
- package/lib/shimmer.js +7 -2
- package/lib/transaction/trace/index.js +4 -1
- package/lib/util/urltils.js +24 -0
- package/package.json +10 -10
package/NEWS.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
### v9.10.0 (2023-02-09)
|
|
2
|
+
|
|
3
|
+
* Exposed a method on [API](https://newrelic.github.io/node-newrelic/API.html#obfuscateSql) to obfuscate sql: `newrelic.obfuscateSql`.
|
|
4
|
+
|
|
5
|
+
* Add support for [Multi Value Parameters](https://aws.amazon.com/blogs/compute/support-for-multi-value-parameters-in-amazon-api-gateway) from API Gateway and ALB events for Lambdas (Thank you @Engerim for your contribution 🙏🏻)
|
|
6
|
+
|
|
7
|
+
### v9.9.0 (2023-02-06)
|
|
8
|
+
* Added support for url obfuscation using regex (Thanks for your contribution @matewilk)
|
|
9
|
+
* For Distributed Tracing, this means that:
|
|
10
|
+
* Incoming and outgoing requests' `path` will be obfuscated
|
|
11
|
+
* Transaction's `request.url` attribute will be obfuscated
|
|
12
|
+
* Span's `http.uri` path will be obfuscated
|
|
13
|
+
* For transactions, this means that:
|
|
14
|
+
* Transaction trace details `url` will be obfuscated
|
|
15
|
+
* With the following example configuration, url obfuscation will turn `/api/v1/users/12345456/edit` to `/api/v1/users/**/edit`.
|
|
16
|
+
```js
|
|
17
|
+
url_obfuscation: {
|
|
18
|
+
enabled: true,
|
|
19
|
+
regex: {
|
|
20
|
+
pattern: /(\/api\/v1\/users\/)([\d]+)(\/.*$)/,
|
|
21
|
+
flags: "i",
|
|
22
|
+
replacement: '$1**$3'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
* You can also use environment variables to configure url obfuscation:
|
|
27
|
+
```yml
|
|
28
|
+
NEW_RELIC_URL_OBFUSCATION_ENABLED: "true",
|
|
29
|
+
NEW_RELIC_URL_OBFUSCATION_REGEX_PATTERN: '/(\/api\/v1\/users\/)([\d]+)(\/.*$)/',
|
|
30
|
+
NEW_RELIC_URL_OBFUSCATION_REGEX_FLAGS: 'i',
|
|
31
|
+
NEW_RELIC_URL_OBFUSCATION_REGEX_REPLACEMENT: '$1**$3'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
* Add a new tracking type of instrumentation. This will be responsible for logging `Supportability/Features/Instrumentation/OnResolved/<pkg>` and `Supportability/Features/Instrumentation/OnResolved/<pkg>/Version/<version>` metrics when packages are required.
|
|
35
|
+
|
|
1
36
|
### v9.8.1 (2023-01-25)
|
|
2
37
|
|
|
3
38
|
* Changed GCP metadata parsing to use `json-bigint` to avoid loss of precision from numerical instance ID.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -40,6 +40,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
40
40
|
* [async](#async)
|
|
41
41
|
* [c8](#c8)
|
|
42
42
|
* [chai](#chai)
|
|
43
|
+
* [clean-jsdoc-theme](#clean-jsdoc-theme)
|
|
43
44
|
* [commander](#commander)
|
|
44
45
|
* [eslint-config-prettier](#eslint-config-prettier)
|
|
45
46
|
* [eslint-plugin-disable](#eslint-plugin-disable)
|
|
@@ -57,7 +58,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
57
58
|
* [lint-staged](#lint-staged)
|
|
58
59
|
* [lockfile-lint](#lockfile-lint)
|
|
59
60
|
* [memcached](#memcached)
|
|
60
|
-
* [minami](#minami)
|
|
61
61
|
* [nock](#nock)
|
|
62
62
|
* [prettier](#prettier)
|
|
63
63
|
* [proxyquire](#proxyquire)
|
|
@@ -74,7 +74,6 @@ 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)
|
|
78
77
|
|
|
79
78
|
**[Additional Licenses](#additional-licenses)**
|
|
80
79
|
|
|
@@ -1367,7 +1366,7 @@ SOFTWARE.
|
|
|
1367
1366
|
|
|
1368
1367
|
### @newrelic/eslint-config
|
|
1369
1368
|
|
|
1370
|
-
This product includes source derived from [@newrelic/eslint-config](https://github.com/newrelic/eslint-config-newrelic) ([v0.
|
|
1369
|
+
This product includes source derived from [@newrelic/eslint-config](https://github.com/newrelic/eslint-config-newrelic) ([v0.3.0](https://github.com/newrelic/eslint-config-newrelic/tree/v0.3.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/eslint-config-newrelic/blob/v0.3.0/LICENSE):
|
|
1371
1370
|
|
|
1372
1371
|
```
|
|
1373
1372
|
Apache License
|
|
@@ -2175,6 +2174,35 @@ SOFTWARE.
|
|
|
2175
2174
|
|
|
2176
2175
|
```
|
|
2177
2176
|
|
|
2177
|
+
### clean-jsdoc-theme
|
|
2178
|
+
|
|
2179
|
+
This product includes source derived from [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) ([v4.2.4](https://github.com/ankitskvmdam/clean-jsdoc-theme/tree/v4.2.4)), distributed under the [MIT License](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/v4.2.4/LICENSE):
|
|
2180
|
+
|
|
2181
|
+
```
|
|
2182
|
+
MIT License
|
|
2183
|
+
|
|
2184
|
+
Copyright (c) 2019-2022 Ankit Kumar (अंकित कुमार)
|
|
2185
|
+
|
|
2186
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
2187
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
2188
|
+
in the Software without restriction, including without limitation the rights
|
|
2189
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
2190
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
2191
|
+
furnished to do so, subject to the following conditions:
|
|
2192
|
+
|
|
2193
|
+
The above copyright notice and this permission notice shall be included in all
|
|
2194
|
+
copies or substantial portions of the Software.
|
|
2195
|
+
|
|
2196
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
2197
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
2198
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
2199
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
2200
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
2201
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
2202
|
+
SOFTWARE.
|
|
2203
|
+
|
|
2204
|
+
```
|
|
2205
|
+
|
|
2178
2206
|
### commander
|
|
2179
2207
|
|
|
2180
2208
|
This product includes source derived from [commander](https://github.com/tj/commander.js) ([v7.2.0](https://github.com/tj/commander.js/tree/v7.2.0)), distributed under the [MIT License](https://github.com/tj/commander.js/blob/v7.2.0/LICENSE):
|
|
@@ -2373,7 +2401,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|
|
2373
2401
|
|
|
2374
2402
|
### eslint-plugin-sonarjs
|
|
2375
2403
|
|
|
2376
|
-
This product includes source derived from [eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs) ([v0.
|
|
2404
|
+
This product includes source derived from [eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs) ([v0.18.0](https://github.com/SonarSource/eslint-plugin-sonarjs/tree/v0.18.0)), distributed under the [LGPL-3.0 License](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/v0.18.0/LICENSE):
|
|
2377
2405
|
|
|
2378
2406
|
```
|
|
2379
2407
|
GNU LESSER GENERAL PUBLIC LICENSE
|
|
@@ -2680,7 +2708,7 @@ SOFTWARE.
|
|
|
2680
2708
|
|
|
2681
2709
|
### jsdoc
|
|
2682
2710
|
|
|
2683
|
-
This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([
|
|
2711
|
+
This product includes source derived from [jsdoc](https://github.com/jsdoc/jsdoc) ([v4.0.0](https://github.com/jsdoc/jsdoc/tree/v4.0.0)), distributed under the [Apache-2.0 License](https://github.com/jsdoc/jsdoc/blob/v4.0.0/LICENSE.md):
|
|
2684
2712
|
|
|
2685
2713
|
```
|
|
2686
2714
|
# License
|
|
@@ -3041,75 +3069,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
3041
3069
|
THE SOFTWARE.
|
|
3042
3070
|
```
|
|
3043
3071
|
|
|
3044
|
-
### minami
|
|
3045
|
-
|
|
3046
|
-
This product includes source derived from [minami](https://github.com/Nijikokun/minami) ([v1.2.3](https://github.com/Nijikokun/minami/tree/v1.2.3)), distributed under the [Apache-2.0 License](https://github.com/Nijikokun/minami/blob/v1.2.3/LICENSE):
|
|
3047
|
-
|
|
3048
|
-
```
|
|
3049
|
-
# License
|
|
3050
|
-
|
|
3051
|
-
Minami is free software, licensed under the Apache License, Version 2.0 (the
|
|
3052
|
-
"License"). Commercial and non-commercial use are permitted in compliance with
|
|
3053
|
-
the License.
|
|
3054
|
-
|
|
3055
|
-
Copyright (c) 2014-2015 Nijiko Yonskai <nijikokun@gmail.com> and the
|
|
3056
|
-
[contributors to Minami](https://github.com/Nijikokun/minami/graphs/contributors).
|
|
3057
|
-
All rights reserved.
|
|
3058
|
-
|
|
3059
|
-
You may obtain a copy of the License at:
|
|
3060
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
3061
|
-
|
|
3062
|
-
In addition, a copy of the License is included with this distribution.
|
|
3063
|
-
|
|
3064
|
-
As stated in Section 7, "Disclaimer of Warranty," of the License:
|
|
3065
|
-
|
|
3066
|
-
> Licensor provides the Work (and each Contributor provides its Contributions)
|
|
3067
|
-
> on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
3068
|
-
> express or implied, including, without limitation, any warranties or
|
|
3069
|
-
> conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
3070
|
-
> PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
3071
|
-
> appropriateness of using or redistributing the Work and assume any risks
|
|
3072
|
-
> associated with Your exercise of permissions under this License.
|
|
3073
|
-
|
|
3074
|
-
The source code for JSDoc 3 is available at:
|
|
3075
|
-
https://github.com/Nijikokun/minami
|
|
3076
|
-
|
|
3077
|
-
# Third-Party Software
|
|
3078
|
-
|
|
3079
|
-
Minami includes or depends upon the following third-party software, either in
|
|
3080
|
-
whole or in part. Each third-party software package is provided under its own
|
|
3081
|
-
license.
|
|
3082
|
-
|
|
3083
|
-
## JSDoc 3
|
|
3084
|
-
|
|
3085
|
-
JSDoc 3 is free software, licensed under the Apache License, Version 2.0 (the
|
|
3086
|
-
"License"). Commercial and non-commercial use are permitted in compliance with
|
|
3087
|
-
the License.
|
|
3088
|
-
|
|
3089
|
-
Copyright (c) 2011-2015 Michael Mathews <micmath@gmail.com> and the
|
|
3090
|
-
[contributors to JSDoc](https://github.com/jsdoc3/jsdoc/graphs/contributors).
|
|
3091
|
-
All rights reserved.
|
|
3092
|
-
|
|
3093
|
-
You may obtain a copy of the License at:
|
|
3094
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
3095
|
-
|
|
3096
|
-
In addition, a copy of the License is included with this distribution.
|
|
3097
|
-
|
|
3098
|
-
As stated in Section 7, "Disclaimer of Warranty," of the License:
|
|
3099
|
-
|
|
3100
|
-
> Licensor provides the Work (and each Contributor provides its Contributions)
|
|
3101
|
-
> on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
3102
|
-
> express or implied, including, without limitation, any warranties or
|
|
3103
|
-
> conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
3104
|
-
> PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
3105
|
-
> appropriateness of using or redistributing the Work and assume any risks
|
|
3106
|
-
> associated with Your exercise of permissions under this License.
|
|
3107
|
-
|
|
3108
|
-
The source code for JSDoc 3 is available at:
|
|
3109
|
-
https://github.com/jsdoc3/jsdoc
|
|
3110
|
-
|
|
3111
|
-
```
|
|
3112
|
-
|
|
3113
3072
|
### nock
|
|
3114
3073
|
|
|
3115
3074
|
This product includes source derived from [nock](https://github.com/nock/nock) ([v11.8.0](https://github.com/nock/nock/tree/v11.8.0)), distributed under the [MIT License](https://github.com/nock/nock/blob/v11.8.0/LICENSE):
|
|
@@ -9355,12 +9314,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
9355
9314
|
|
|
9356
9315
|
### tap
|
|
9357
9316
|
|
|
9358
|
-
This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.3.
|
|
9317
|
+
This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.3.4](https://github.com/tapjs/node-tap/tree/v16.3.4)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v16.3.4/LICENSE):
|
|
9359
9318
|
|
|
9360
9319
|
```
|
|
9361
9320
|
The ISC License
|
|
9362
9321
|
|
|
9363
|
-
Copyright (c) 2011-
|
|
9322
|
+
Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
|
|
9364
9323
|
|
|
9365
9324
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
9366
9325
|
purpose with or without fee is hereby granted, provided that the above
|
|
@@ -9493,215 +9452,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
9493
9452
|
|
|
9494
9453
|
```
|
|
9495
9454
|
|
|
9496
|
-
### @newrelic/native-metrics
|
|
9497
|
-
|
|
9498
|
-
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):
|
|
9499
|
-
|
|
9500
|
-
```
|
|
9501
|
-
Apache License
|
|
9502
|
-
Version 2.0, January 2004
|
|
9503
|
-
http://www.apache.org/licenses/
|
|
9504
|
-
|
|
9505
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9506
|
-
|
|
9507
|
-
1. Definitions.
|
|
9508
|
-
|
|
9509
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
9510
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
9511
|
-
|
|
9512
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
9513
|
-
the copyright owner that is granting the License.
|
|
9514
|
-
|
|
9515
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
9516
|
-
other entities that control, are controlled by, or are under common
|
|
9517
|
-
control with that entity. For the purposes of this definition,
|
|
9518
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
9519
|
-
direction or management of such entity, whether by contract or
|
|
9520
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
9521
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
9522
|
-
|
|
9523
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
9524
|
-
exercising permissions granted by this License.
|
|
9525
|
-
|
|
9526
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
9527
|
-
including but not limited to software source code, documentation
|
|
9528
|
-
source, and configuration files.
|
|
9529
|
-
|
|
9530
|
-
"Object" form shall mean any form resulting from mechanical
|
|
9531
|
-
transformation or translation of a Source form, including but
|
|
9532
|
-
not limited to compiled object code, generated documentation,
|
|
9533
|
-
and conversions to other media types.
|
|
9534
|
-
|
|
9535
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
9536
|
-
Object form, made available under the License, as indicated by a
|
|
9537
|
-
copyright notice that is included in or attached to the work
|
|
9538
|
-
(an example is provided in the Appendix below).
|
|
9539
|
-
|
|
9540
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
9541
|
-
form, that is based on (or derived from) the Work and for which the
|
|
9542
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
9543
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
9544
|
-
of this License, Derivative Works shall not include works that remain
|
|
9545
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
9546
|
-
the Work and Derivative Works thereof.
|
|
9547
|
-
|
|
9548
|
-
"Contribution" shall mean any work of authorship, including
|
|
9549
|
-
the original version of the Work and any modifications or additions
|
|
9550
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
9551
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
9552
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
9553
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
9554
|
-
means any form of electronic, verbal, or written communication sent
|
|
9555
|
-
to the Licensor or its representatives, including but not limited to
|
|
9556
|
-
communication on electronic mailing lists, source code control systems,
|
|
9557
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
9558
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
9559
|
-
excluding communication that is conspicuously marked or otherwise
|
|
9560
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
9561
|
-
|
|
9562
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
9563
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
9564
|
-
subsequently incorporated within the Work.
|
|
9565
|
-
|
|
9566
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
9567
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
9568
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
9569
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
9570
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
9571
|
-
Work and such Derivative Works in Source or Object form.
|
|
9572
|
-
|
|
9573
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
9574
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
9575
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
9576
|
-
(except as stated in this section) patent license to make, have made,
|
|
9577
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
9578
|
-
where such license applies only to those patent claims licensable
|
|
9579
|
-
by such Contributor that are necessarily infringed by their
|
|
9580
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
9581
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
9582
|
-
institute patent litigation against any entity (including a
|
|
9583
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
9584
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
9585
|
-
or contributory patent infringement, then any patent licenses
|
|
9586
|
-
granted to You under this License for that Work shall terminate
|
|
9587
|
-
as of the date such litigation is filed.
|
|
9588
|
-
|
|
9589
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
9590
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
9591
|
-
modifications, and in Source or Object form, provided that You
|
|
9592
|
-
meet the following conditions:
|
|
9593
|
-
|
|
9594
|
-
(a) You must give any other recipients of the Work or
|
|
9595
|
-
Derivative Works a copy of this License; and
|
|
9596
|
-
|
|
9597
|
-
(b) You must cause any modified files to carry prominent notices
|
|
9598
|
-
stating that You changed the files; and
|
|
9599
|
-
|
|
9600
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
9601
|
-
that You distribute, all copyright, patent, trademark, and
|
|
9602
|
-
attribution notices from the Source form of the Work,
|
|
9603
|
-
excluding those notices that do not pertain to any part of
|
|
9604
|
-
the Derivative Works; and
|
|
9605
|
-
|
|
9606
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
9607
|
-
distribution, then any Derivative Works that You distribute must
|
|
9608
|
-
include a readable copy of the attribution notices contained
|
|
9609
|
-
within such NOTICE file, excluding those notices that do not
|
|
9610
|
-
pertain to any part of the Derivative Works, in at least one
|
|
9611
|
-
of the following places: within a NOTICE text file distributed
|
|
9612
|
-
as part of the Derivative Works; within the Source form or
|
|
9613
|
-
documentation, if provided along with the Derivative Works; or,
|
|
9614
|
-
within a display generated by the Derivative Works, if and
|
|
9615
|
-
wherever such third-party notices normally appear. The contents
|
|
9616
|
-
of the NOTICE file are for informational purposes only and
|
|
9617
|
-
do not modify the License. You may add Your own attribution
|
|
9618
|
-
notices within Derivative Works that You distribute, alongside
|
|
9619
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
9620
|
-
that such additional attribution notices cannot be construed
|
|
9621
|
-
as modifying the License.
|
|
9622
|
-
|
|
9623
|
-
You may add Your own copyright statement to Your modifications and
|
|
9624
|
-
may provide additional or different license terms and conditions
|
|
9625
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
9626
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
9627
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
9628
|
-
the conditions stated in this License.
|
|
9629
|
-
|
|
9630
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
9631
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
9632
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
9633
|
-
this License, without any additional terms or conditions.
|
|
9634
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
9635
|
-
the terms of any separate license agreement you may have executed
|
|
9636
|
-
with Licensor regarding such Contributions.
|
|
9637
|
-
|
|
9638
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
9639
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
9640
|
-
except as required for reasonable and customary use in describing the
|
|
9641
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
9642
|
-
|
|
9643
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
9644
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
9645
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
9646
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
9647
|
-
implied, including, without limitation, any warranties or conditions
|
|
9648
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
9649
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
9650
|
-
appropriateness of using or redistributing the Work and assume any
|
|
9651
|
-
risks associated with Your exercise of permissions under this License.
|
|
9652
|
-
|
|
9653
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
9654
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
9655
|
-
unless required by applicable law (such as deliberate and grossly
|
|
9656
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
9657
|
-
liable to You for damages, including any direct, indirect, special,
|
|
9658
|
-
incidental, or consequential damages of any character arising as a
|
|
9659
|
-
result of this License or out of the use or inability to use the
|
|
9660
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
9661
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
9662
|
-
other commercial damages or losses), even if such Contributor
|
|
9663
|
-
has been advised of the possibility of such damages.
|
|
9664
|
-
|
|
9665
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
9666
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
9667
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
9668
|
-
or other liability obligations and/or rights consistent with this
|
|
9669
|
-
License. However, in accepting such obligations, You may act only
|
|
9670
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
9671
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
9672
|
-
defend, and hold each Contributor harmless for any liability
|
|
9673
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
9674
|
-
of your accepting any such warranty or additional liability.
|
|
9675
|
-
|
|
9676
|
-
END OF TERMS AND CONDITIONS
|
|
9677
|
-
|
|
9678
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
9679
|
-
|
|
9680
|
-
To apply the Apache License to your work, attach the following
|
|
9681
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
9682
|
-
replaced with your own identifying information. (Don't include
|
|
9683
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
9684
|
-
comment syntax for the file format. We also recommend that a
|
|
9685
|
-
file or class name and description of purpose be included on the
|
|
9686
|
-
same "printed page" as the copyright notice for easier
|
|
9687
|
-
identification within third-party archives.
|
|
9688
|
-
|
|
9689
|
-
Copyright [yyyy] [name of copyright owner]
|
|
9690
|
-
|
|
9691
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9692
|
-
you may not use this file except in compliance with the License.
|
|
9693
|
-
You may obtain a copy of the License at
|
|
9694
|
-
|
|
9695
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9696
|
-
|
|
9697
|
-
Unless required by applicable law or agreed to in writing, software
|
|
9698
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
9699
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9700
|
-
See the License for the specific language governing permissions and
|
|
9701
|
-
limitations under the License.
|
|
9702
|
-
|
|
9703
|
-
```
|
|
9704
|
-
|
|
9705
9455
|
## Additional Licenses
|
|
9706
9456
|
|
|
9707
9457
|
### Symantec
|
package/api.js
CHANGED
|
@@ -27,6 +27,7 @@ const {
|
|
|
27
27
|
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
|
+
const obfuscate = require('./lib/util/sql/obfuscate')
|
|
30
31
|
|
|
31
32
|
/*
|
|
32
33
|
*
|
|
@@ -646,7 +647,7 @@ function _generateRUMHeader(options = {}, metadata, loader) {
|
|
|
646
647
|
* @param {object} config agent configuration settings
|
|
647
648
|
* @param {Transaction} transaction the active transaction or null
|
|
648
649
|
* @param {boolean} allowTransactionlessInjection whether or not to allow the Browser Agent to be injected when there is no active transaction
|
|
649
|
-
* @returns {{ isValidConfig: boolean, failureIdx
|
|
650
|
+
* @returns {{ isValidConfig: boolean, failureIdx: number, quietMode: boolean }} object containing validation results
|
|
650
651
|
*/
|
|
651
652
|
function validateBrowserMonitoring(config, transaction, allowTransactionlessInjection) {
|
|
652
653
|
/*
|
|
@@ -1669,6 +1670,20 @@ API.prototype.setLambdaHandler = function setLambdaHandler(handler) {
|
|
|
1669
1670
|
return this.awsLambda.patchLambdaHandler(handler)
|
|
1670
1671
|
}
|
|
1671
1672
|
|
|
1673
|
+
/**
|
|
1674
|
+
* Obfuscates SQL for a given database engine.
|
|
1675
|
+
*
|
|
1676
|
+
* @param {string} sql sql statement
|
|
1677
|
+
* @param {string} dialect engine of the sql (mysql, postgres, cassandra, oracle)
|
|
1678
|
+
* @returns {string} sql that obfuscates raw values
|
|
1679
|
+
*/
|
|
1680
|
+
API.prototype.obfuscateSql = function obfuscateSql(sql, dialect) {
|
|
1681
|
+
const metric = this.agent.metrics.getOrCreateMetric(NAMES.SUPPORTABILITY.API + '/obfuscateSql')
|
|
1682
|
+
metric.incrementCallCount()
|
|
1683
|
+
|
|
1684
|
+
return obfuscate(sql, dialect)
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1672
1687
|
/**
|
|
1673
1688
|
* Function for removing invalid attribute key/value pairs from an object
|
|
1674
1689
|
*
|
package/lib/collector/facts.js
CHANGED
|
@@ -9,12 +9,6 @@ const fetchSystemInfo = require('../system-info')
|
|
|
9
9
|
const logger = require('../logger').child({ component: 'facts' })
|
|
10
10
|
const os = require('os')
|
|
11
11
|
const parseLabels = require('../util/label-parser')
|
|
12
|
-
const NAMES = require('../metrics/names')
|
|
13
|
-
|
|
14
|
-
// For now static and tentative list of which logging libraries we
|
|
15
|
-
// want to track. Later might come up with a better way of populating
|
|
16
|
-
// this list.
|
|
17
|
-
const LOG_LIBRARIES = ['winston', 'bunyan', 'pino', 'loglevel', 'npmlog', 'fancy-log']
|
|
18
12
|
|
|
19
13
|
module.exports = facts
|
|
20
14
|
|
|
@@ -38,8 +32,6 @@ async function facts(agent, callback) {
|
|
|
38
32
|
systemInfo = systemInfo || Object.create(null)
|
|
39
33
|
environment = environment || []
|
|
40
34
|
|
|
41
|
-
countSupportabilityForLogLibraries(environment, agent)
|
|
42
|
-
|
|
43
35
|
const hostname = agent.config.getHostnameSafe()
|
|
44
36
|
const results = {
|
|
45
37
|
utilization: {
|
|
@@ -148,23 +140,3 @@ function getIdentifierOverride(appNames) {
|
|
|
148
140
|
appNames.concat([]).sort().join(',')
|
|
149
141
|
].join(':')
|
|
150
142
|
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* This function searches the computed environment for the presence of
|
|
154
|
-
* some popular logging libraries. If present, it increments the
|
|
155
|
-
* corresponding supportability metrics.
|
|
156
|
-
*
|
|
157
|
-
* @param {Array} environment the environment computed by
|
|
158
|
-
* @param {object} agent the New Relic agent
|
|
159
|
-
*/
|
|
160
|
-
function countSupportabilityForLogLibraries(environment, agent) {
|
|
161
|
-
const packages = environment.find((elt) => elt[0] === 'Packages')[1]
|
|
162
|
-
packages.forEach((pkg) => {
|
|
163
|
-
pkg = JSON.parse(pkg)[0]
|
|
164
|
-
if (LOG_LIBRARIES.includes(pkg)) {
|
|
165
|
-
agent.metrics
|
|
166
|
-
.getOrCreateMetric(`${NAMES.SUPPORTABILITY.NODEJS_DEPENDENCIES}/${pkg}`)
|
|
167
|
-
.incrementCallCount()
|
|
168
|
-
}
|
|
169
|
-
})
|
|
170
|
-
}
|
package/lib/config/default.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
8
|
const defaultConfig = module.exports
|
|
9
|
-
const { array, int, float, boolean, object, objectList, allowList } = require('./formatters')
|
|
9
|
+
const { array, int, float, boolean, object, objectList, allowList, regex } = require('./formatters')
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A function that returns the definition of the agent configuration
|
|
@@ -52,6 +52,13 @@ defaultConfig.definition = () => ({
|
|
|
52
52
|
* You shouldn't need to change this.
|
|
53
53
|
*/
|
|
54
54
|
host: '',
|
|
55
|
+
/**
|
|
56
|
+
* Endpoint to send OpenTelemetry spans to.
|
|
57
|
+
*
|
|
58
|
+
* This should be automatically deduced from your region and other
|
|
59
|
+
* settings, but if desired, you can override it.
|
|
60
|
+
*/
|
|
61
|
+
otlp_endpoint: '',
|
|
55
62
|
/**
|
|
56
63
|
* The port on which the collector proxy will be listening.
|
|
57
64
|
*
|
|
@@ -1208,6 +1215,47 @@ defaultConfig.definition = () => ({
|
|
|
1208
1215
|
formatter: boolean,
|
|
1209
1216
|
default: false
|
|
1210
1217
|
}
|
|
1218
|
+
},
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Obfuscates URL parameters
|
|
1222
|
+
* for outgoing and incoming requests
|
|
1223
|
+
* for distrubuted tracing attributes - both transaction and span attributes
|
|
1224
|
+
* for transaction trace transaction details
|
|
1225
|
+
*/
|
|
1226
|
+
url_obfuscation: {
|
|
1227
|
+
/**
|
|
1228
|
+
* Toggles whether to obfuscate URL parameters
|
|
1229
|
+
*/
|
|
1230
|
+
enabled: {
|
|
1231
|
+
formatter: boolean,
|
|
1232
|
+
default: false
|
|
1233
|
+
},
|
|
1234
|
+
|
|
1235
|
+
regex: {
|
|
1236
|
+
/**
|
|
1237
|
+
* A regular expression to match URL parameters to obfuscate
|
|
1238
|
+
*/
|
|
1239
|
+
pattern: {
|
|
1240
|
+
formatter: regex,
|
|
1241
|
+
default: null
|
|
1242
|
+
},
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* A string containing RegEx flags to use when matching URL parameters
|
|
1246
|
+
*/
|
|
1247
|
+
flags: {
|
|
1248
|
+
default: ''
|
|
1249
|
+
},
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* A string containing a replacement value for URL parameters
|
|
1253
|
+
* can contain refferences to capture groups in the pattern
|
|
1254
|
+
*/
|
|
1255
|
+
replacement: {
|
|
1256
|
+
default: ''
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1211
1259
|
}
|
|
1212
1260
|
})
|
|
1213
1261
|
|
package/lib/config/formatters.js
CHANGED
|
@@ -106,3 +106,19 @@ formatters.objectList = function objectList(val, logger) {
|
|
|
106
106
|
formatters.allowList = function allowList(list, val) {
|
|
107
107
|
return list.includes(val) ? val : list[0]
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Parse a config setting as a regex
|
|
112
|
+
*
|
|
113
|
+
* @param {string} val valid regex
|
|
114
|
+
* @param {logger} logger agent logger instance
|
|
115
|
+
* @returns {RegExp} regex
|
|
116
|
+
*/
|
|
117
|
+
formatters.regex = function regex(val, logger) {
|
|
118
|
+
try {
|
|
119
|
+
return new RegExp(val)
|
|
120
|
+
} catch (error) {
|
|
121
|
+
logger.error(`New Relic configurator could not validate regex: ${val}`)
|
|
122
|
+
logger.error(error.stack)
|
|
123
|
+
}
|
|
124
|
+
}
|
package/lib/config/index.js
CHANGED
|
@@ -993,7 +993,7 @@ Config.prototype._fromPassed = function _fromPassed(external, internal, arbitrar
|
|
|
993
993
|
return
|
|
994
994
|
}
|
|
995
995
|
|
|
996
|
-
if (typeof node === 'object' && !Array.isArray(node)) {
|
|
996
|
+
if (typeof node === 'object' && !Array.isArray(node) && !(node instanceof RegExp)) {
|
|
997
997
|
// is top level and can have arbitrary keys
|
|
998
998
|
const allowArbitrary = internal === this || HAS_ARBITRARY_KEYS.has(key)
|
|
999
999
|
this._fromPassed(node, internal[key], allowArbitrary)
|
|
@@ -1095,7 +1095,13 @@ Config.prototype._fromEnvironment = function _fromEnvironment(
|
|
|
1095
1095
|
setFromEnv({ config, key, envVar, paths })
|
|
1096
1096
|
} else if (type === 'object') {
|
|
1097
1097
|
if (value.hasOwnProperty('env')) {
|
|
1098
|
-
setFromEnv({
|
|
1098
|
+
setFromEnv({
|
|
1099
|
+
config,
|
|
1100
|
+
key,
|
|
1101
|
+
envVar: value.env,
|
|
1102
|
+
paths,
|
|
1103
|
+
formatter: value.formatter
|
|
1104
|
+
})
|
|
1099
1105
|
} else if (value.hasOwnProperty('default')) {
|
|
1100
1106
|
const envVar = deriveEnvVar(key, paths)
|
|
1101
1107
|
setFromEnv({ config, key, envVar, formatter: value.formatter, paths })
|
|
@@ -1298,14 +1304,21 @@ Config.prototype._canonicalize = function _canonicalize() {
|
|
|
1298
1304
|
const level = this.logging.level
|
|
1299
1305
|
this.logging.level = logAliases[level] || level
|
|
1300
1306
|
|
|
1307
|
+
const region = parseKey(this.license_key)
|
|
1301
1308
|
if (this.host === '') {
|
|
1302
|
-
const region = parseKey(this.license_key)
|
|
1303
1309
|
if (region) {
|
|
1304
|
-
this.host =
|
|
1310
|
+
this.host = `collector.${region}.nr-data.net`
|
|
1305
1311
|
} else {
|
|
1306
1312
|
this.host = 'collector.newrelic.com'
|
|
1307
1313
|
}
|
|
1308
1314
|
}
|
|
1315
|
+
if (this.otlp_endpoint === '') {
|
|
1316
|
+
if (region) {
|
|
1317
|
+
this.otlp_endpoint = `otlp.${region}.nr-data.net`
|
|
1318
|
+
} else {
|
|
1319
|
+
this.otlp_endpoint = 'otlp.nr-data.net'
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1309
1322
|
|
|
1310
1323
|
if (this.license_key) {
|
|
1311
1324
|
this.license_key = this.license_key.trim()
|
|
@@ -215,6 +215,7 @@ function applySegment(opts, makeRequest, hostname, segment) {
|
|
|
215
215
|
segment.start()
|
|
216
216
|
const request = makeRequest(opts)
|
|
217
217
|
const parsed = urltils.scrubAndParseParameters(request.path)
|
|
218
|
+
parsed.path = urltils.obfuscatePath(segment.transaction.agent.config, parsed.path)
|
|
218
219
|
const proto = parsed.protocol || opts.protocol || 'http:'
|
|
219
220
|
segment.name += parsed.path
|
|
220
221
|
request[symbols.segment] = segment
|
|
@@ -86,7 +86,7 @@ function wrapEmitWithTransaction(agent, emit, isHTTPS) {
|
|
|
86
86
|
|
|
87
87
|
// the error tracer needs a URL for tracing, even though naming overwrites
|
|
88
88
|
transaction.parsedUrl = url.parse(request.url, true)
|
|
89
|
-
transaction.url = transaction.parsedUrl.
|
|
89
|
+
transaction.url = urltils.obfuscatePath(agent.config, transaction.parsedUrl.path)
|
|
90
90
|
transaction.verb = request.method
|
|
91
91
|
|
|
92
92
|
// URL is sent as an agent attribute with transaction events
|
package/lib/instrumentations.js
CHANGED
|
@@ -38,6 +38,21 @@ module.exports = function instrumentations() {
|
|
|
38
38
|
'undici': { type: MODULE_TYPE.TRANSACTION },
|
|
39
39
|
'@hapi/vision': { type: MODULE_TYPE.WEB_FRAMEWORK },
|
|
40
40
|
'when': { module: './instrumentation/when' },
|
|
41
|
-
'winston': { type: MODULE_TYPE.GENERIC }
|
|
41
|
+
'winston': { type: MODULE_TYPE.GENERIC },
|
|
42
|
+
/**
|
|
43
|
+
* The modules below are listed here purely to take
|
|
44
|
+
* advantage of the Supportability/Features/onRequire/<module>
|
|
45
|
+
* metrics for libraries we want to track for some reason or another.
|
|
46
|
+
* The big uses cases are:
|
|
47
|
+
* Logging libraries we want to instrument in the future
|
|
48
|
+
* Libraries that have OpenTelemetry instrumentation we want to register
|
|
49
|
+
* or have already registered.
|
|
50
|
+
*/
|
|
51
|
+
'loglevel': { type: MODULE_TYPE.TRACKING },
|
|
52
|
+
'npmlog': { type: MODULE_TYPE.TRACKING },
|
|
53
|
+
'fancy-log': { type: MODULE_TYPE.TRACKING },
|
|
54
|
+
'@prisma/client': { type: MODULE_TYPE.TRACKING },
|
|
55
|
+
'@nestjs/core': { type: MODULE_TYPE.TRACKING },
|
|
56
|
+
'knex': { type: MODULE_TYPE.TRACKING }
|
|
42
57
|
}
|
|
43
58
|
}
|
package/lib/metrics/names.js
CHANGED
|
@@ -23,7 +23,6 @@ const SUPPORTABILITY = {
|
|
|
23
23
|
TRANSACTION_API: 'Supportability/API/Transaction',
|
|
24
24
|
UTILIZATION: 'Supportability/utilization',
|
|
25
25
|
DEPENDENCIES: 'Supportability/InstalledDependencies',
|
|
26
|
-
NODEJS_DEPENDENCIES: 'Supportability/InstalledDependencies/Nodejs',
|
|
27
26
|
NODEJS: 'Supportability/Nodejs',
|
|
28
27
|
REGISTRATION: 'Supportability/Registration',
|
|
29
28
|
EVENT_HARVEST: 'Supportability/EventHarvest',
|
|
@@ -7,19 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This class captures data needed to construct a web transaction from
|
|
10
|
-
*
|
|
10
|
+
* an API Gateway Lambda proxy request. This is to be used with the setWebRequest
|
|
11
11
|
* method.
|
|
12
12
|
*/
|
|
13
13
|
class LambdaProxyWebRequest {
|
|
14
14
|
constructor(event) {
|
|
15
|
-
|
|
15
|
+
const lowerCaseHeaders = normalizeHeaders(event, true)
|
|
16
|
+
|
|
17
|
+
this.headers = normalizeHeaders(event)
|
|
16
18
|
this.url = {
|
|
17
19
|
path: event.path,
|
|
18
|
-
port:
|
|
19
|
-
requestParameters: event
|
|
20
|
+
port: lowerCaseHeaders['x-forwarded-port'],
|
|
21
|
+
requestParameters: normalizeQueryStringParameters(event)
|
|
20
22
|
}
|
|
21
23
|
this.method = event.httpMethod
|
|
22
|
-
this.transportType =
|
|
24
|
+
this.transportType = lowerCaseHeaders['x-forwarded-proto']
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -30,11 +32,53 @@ class LambdaProxyWebRequest {
|
|
|
30
32
|
*/
|
|
31
33
|
class LambdaProxyWebResponse {
|
|
32
34
|
constructor(lambdaResponse) {
|
|
33
|
-
this.headers = lambdaResponse
|
|
35
|
+
this.headers = normalizeHeaders(lambdaResponse)
|
|
34
36
|
this.statusCode = lambdaResponse.statusCode
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
/**
|
|
41
|
+
* normalizes query string parameters either from multi value query string parameters or normal query string parameters to a
|
|
42
|
+
* key map with comma separated strings
|
|
43
|
+
*
|
|
44
|
+
* @param {object} event The event with query string to normalize
|
|
45
|
+
* @returns {Object<string, string>} The normalized query string map
|
|
46
|
+
*/
|
|
47
|
+
function normalizeQueryStringParameters(event) {
|
|
48
|
+
if (!event.multiValueQueryStringParameters) {
|
|
49
|
+
return event.queryStringParameters
|
|
50
|
+
}
|
|
51
|
+
return Object.fromEntries(
|
|
52
|
+
Object.entries(event.multiValueQueryStringParameters).map(([param, value]) => {
|
|
53
|
+
if (Array.isArray(value)) {
|
|
54
|
+
return [param, value.join(',')]
|
|
55
|
+
}
|
|
56
|
+
return [param, value]
|
|
57
|
+
})
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* normalizes headers either from multi value headers or normal headers to a
|
|
63
|
+
* lowercase key map with comma separated string
|
|
64
|
+
*
|
|
65
|
+
* @param {object} event The event with headers to normalize
|
|
66
|
+
* @param {boolean} lowerCaseKey Whether to lowercase the header names or not
|
|
67
|
+
* @returns {Object<string, string>} The normalized headers map
|
|
68
|
+
*/
|
|
69
|
+
function normalizeHeaders(event, lowerCaseKey = false) {
|
|
70
|
+
return Object.fromEntries(
|
|
71
|
+
Object.entries(event.multiValueHeaders ?? event.headers).map(([headerKey, headerValue]) => {
|
|
72
|
+
const newKey = lowerCaseKey ? headerKey.toLowerCase() : headerKey
|
|
73
|
+
|
|
74
|
+
if (Array.isArray(headerValue)) {
|
|
75
|
+
return [newKey, headerValue.join(',')]
|
|
76
|
+
}
|
|
77
|
+
return [newKey, headerValue]
|
|
78
|
+
})
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
38
82
|
/**
|
|
39
83
|
* Determines if Lambda event appears to be a valid Lambda Proxy event.
|
|
40
84
|
*
|
|
@@ -43,14 +87,13 @@ class LambdaProxyWebResponse {
|
|
|
43
87
|
* to create a web transaction.
|
|
44
88
|
*/
|
|
45
89
|
function isLambdaProxyEvent(event) {
|
|
46
|
-
return !!(event.path && event.headers && event.httpMethod)
|
|
90
|
+
return !!(event.path && (event.headers ?? event.multiValueHeaders) && event.httpMethod)
|
|
47
91
|
}
|
|
48
92
|
|
|
49
93
|
/**
|
|
50
94
|
* Determines if Lambda event appears to be a valid Lambda Proxy response.
|
|
51
95
|
*
|
|
52
|
-
* @param {object}
|
|
53
|
-
* @param response
|
|
96
|
+
* @param {object} response The response to inspect.
|
|
54
97
|
* @returns {boolean} Whether the given object contains fields necessary
|
|
55
98
|
* to create a web transaction.
|
|
56
99
|
*/
|
package/lib/shim/constants.js
CHANGED
|
@@ -32,5 +32,11 @@ exports.MODULE_TYPE = {
|
|
|
32
32
|
TRANSACTION: 'transaction',
|
|
33
33
|
|
|
34
34
|
/** Web server framework module, such as Express or Restify. */
|
|
35
|
-
WEB_FRAMEWORK: 'web-framework'
|
|
35
|
+
WEB_FRAMEWORK: 'web-framework',
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Used to load supportability metrics on installed verisions of packages
|
|
39
|
+
* that the Node.js agent does not instrument(i.e. - otel instrumentation or top logging libraries)
|
|
40
|
+
*/
|
|
41
|
+
TRACKING: 'tracking'
|
|
36
42
|
}
|
package/lib/shimmer.js
CHANGED
|
@@ -530,6 +530,13 @@ function instrumentPostLoad(agent, nodule, moduleName, resolvedName) {
|
|
|
530
530
|
NAMES.FEATURES.INSTRUMENTATION.ON_REQUIRE
|
|
531
531
|
)
|
|
532
532
|
|
|
533
|
+
// Tracking instrumentation is only used to add the supportability metrics
|
|
534
|
+
// that occur directly above this. No reason to attempt to load instrumentation
|
|
535
|
+
// as it does not exist.
|
|
536
|
+
if (instrumentation.type === MODULE_TYPE.TRACKING) {
|
|
537
|
+
return nodule
|
|
538
|
+
}
|
|
539
|
+
|
|
533
540
|
try {
|
|
534
541
|
if (instrumentation.onRequire(shim, nodule, moduleName) !== false) {
|
|
535
542
|
nodule = shim.getExport(nodule)
|
|
@@ -580,7 +587,6 @@ function _firstPartyInstrumentation(agent, fileName, shim, nodule, moduleName) {
|
|
|
580
587
|
|
|
581
588
|
function _postLoad(agent, nodule, name, resolvedName) {
|
|
582
589
|
const instrumentation = shimmer.getInstrumentationNameFromModuleName(name)
|
|
583
|
-
|
|
584
590
|
const registeredInstrumentation = shimmer.registeredInstrumentations[instrumentation]
|
|
585
591
|
const hasPostLoadInstrumentation =
|
|
586
592
|
registeredInstrumentation && registeredInstrumentation.onRequire
|
|
@@ -596,7 +602,6 @@ function _postLoad(agent, nodule, name, resolvedName) {
|
|
|
596
602
|
|
|
597
603
|
function _onResolveFileName(agent, requiredNameOrPath, resolvedFilepath) {
|
|
598
604
|
const instrumentation = shimmer.getInstrumentationNameFromModuleName(requiredNameOrPath)
|
|
599
|
-
|
|
600
605
|
const registeredInstrumentation = shimmer.registeredInstrumentations[instrumentation]
|
|
601
606
|
const hasResolvedFileInstrumentation =
|
|
602
607
|
registeredInstrumentation && registeredInstrumentation.onResolved
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
/* eslint sonarjs/cognitive-complexity: ["error", 19] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
9
|
|
|
10
10
|
const codec = require('../../util/codec')
|
|
11
|
+
const urltils = require('../../util/urltils')
|
|
11
12
|
const Segment = require('./segment')
|
|
12
13
|
const { Attributes, MAXIMUM_CUSTOM_ATTRIBUTES } = require('../../attributes')
|
|
13
14
|
const logger = require('../../logger').child({ component: 'trace' })
|
|
@@ -329,7 +330,9 @@ Trace.prototype._getRequestUri = function _getRequestUri() {
|
|
|
329
330
|
const canAddUri = this.attributes.hasValidDestination(DESTINATIONS.TRANS_TRACE, REQUEST_URI_KEY)
|
|
330
331
|
let requestUri = null // must be null if excluded
|
|
331
332
|
if (canAddUri) {
|
|
332
|
-
|
|
333
|
+
// obfuscate the path if config is set
|
|
334
|
+
const url = urltils.obfuscatePath(this.transaction.agent.config, this.transaction.url)
|
|
335
|
+
requestUri = url || UNKNOWN_URI_PLACEHOLDER
|
|
333
336
|
}
|
|
334
337
|
|
|
335
338
|
return requestUri
|
package/lib/util/urltils.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
8
|
const url = require('url')
|
|
9
|
+
const logger = require('../logger').child({ component: 'urltils' })
|
|
9
10
|
|
|
10
11
|
const LOCALHOST_NAMES = {
|
|
11
12
|
'localhost': true,
|
|
@@ -162,6 +163,29 @@ module.exports = {
|
|
|
162
163
|
}
|
|
163
164
|
},
|
|
164
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Obfuscates path parameters with regex from config
|
|
168
|
+
*
|
|
169
|
+
* @param {Config} config The configuration containing the regex
|
|
170
|
+
* @param {string} path The path to be obfuscated
|
|
171
|
+
* @returns {string} The obfuscated path or the original path
|
|
172
|
+
*/
|
|
173
|
+
obfuscatePath: function obfuscatePath(config, path) {
|
|
174
|
+
const { enabled, regex } = config.url_obfuscation
|
|
175
|
+
if (typeof path !== 'string' || !enabled || !regex) {
|
|
176
|
+
return path
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const { pattern, flags = '', replacement = '' } = regex
|
|
180
|
+
try {
|
|
181
|
+
const regexPattern = new RegExp(pattern, flags)
|
|
182
|
+
return path.replace(regexPattern, replacement)
|
|
183
|
+
} catch (e) {
|
|
184
|
+
logger.warn('Invalid regular expression for url_obfuscation.regex.pattern', pattern)
|
|
185
|
+
return path
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
|
|
165
189
|
/**
|
|
166
190
|
* Copy a set of request parameters from one object to another,
|
|
167
191
|
* but do not overwrite any existing parameters in destination,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.10.0",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -179,10 +179,10 @@
|
|
|
179
179
|
"newrelic-naming-rules": "./bin/test-naming-rules.js"
|
|
180
180
|
},
|
|
181
181
|
"dependencies": {
|
|
182
|
-
"@grpc/grpc-js": "^1.
|
|
183
|
-
"@grpc/proto-loader": "^0.7.
|
|
184
|
-
"@newrelic/aws-sdk": "^5.0.
|
|
185
|
-
"@newrelic/koa": "^7.
|
|
182
|
+
"@grpc/grpc-js": "^1.8.4",
|
|
183
|
+
"@grpc/proto-loader": "^0.7.4",
|
|
184
|
+
"@newrelic/aws-sdk": "^5.0.2",
|
|
185
|
+
"@newrelic/koa": "^7.1.1",
|
|
186
186
|
"@newrelic/superagent": "^6.0.0",
|
|
187
187
|
"@tyriar/fibonacci-heap": "^2.0.7",
|
|
188
188
|
"concat-stream": "^2.0.0",
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"@newrelic/native-metrics": "^9.0.0"
|
|
199
199
|
},
|
|
200
200
|
"devDependencies": {
|
|
201
|
-
"@newrelic/eslint-config": "^0.
|
|
201
|
+
"@newrelic/eslint-config": "^0.3.0",
|
|
202
202
|
"@newrelic/newrelic-oss-cli": "^0.1.2",
|
|
203
203
|
"@newrelic/proxy": "^2.0.0",
|
|
204
204
|
"@newrelic/test-utilities": "^7.2.0",
|
|
@@ -208,6 +208,7 @@
|
|
|
208
208
|
"async": "^3.2.4",
|
|
209
209
|
"c8": "^7.12.0",
|
|
210
210
|
"chai": "^4.1.2",
|
|
211
|
+
"clean-jsdoc-theme": "^4.2.4",
|
|
211
212
|
"commander": "^7.0.0",
|
|
212
213
|
"eslint": "^8.24.0",
|
|
213
214
|
"eslint-config-prettier": "^8.3.0",
|
|
@@ -216,16 +217,15 @@
|
|
|
216
217
|
"eslint-plugin-jsdoc": "^39.3.6",
|
|
217
218
|
"eslint-plugin-node": "^11.1.0",
|
|
218
219
|
"eslint-plugin-prettier": "^3.4.0",
|
|
219
|
-
"eslint-plugin-sonarjs": "^0.
|
|
220
|
+
"eslint-plugin-sonarjs": "^0.18.0",
|
|
220
221
|
"express": "*",
|
|
221
222
|
"glob": "^7.1.2",
|
|
222
223
|
"got": "^11.8.5",
|
|
223
224
|
"husky": "^6.0.0",
|
|
224
|
-
"jsdoc": "^
|
|
225
|
+
"jsdoc": "^4.0.0",
|
|
225
226
|
"lint-staged": "^11.0.0",
|
|
226
227
|
"lockfile-lint": "^4.9.6",
|
|
227
228
|
"memcached": ">=0.2.8",
|
|
228
|
-
"minami": "^1.2.3",
|
|
229
229
|
"nock": "11.8.0",
|
|
230
230
|
"prettier": "^2.3.2",
|
|
231
231
|
"proxyquire": "^1.8.0",
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
"rimraf": "^2.6.3",
|
|
235
235
|
"should": "*",
|
|
236
236
|
"sinon": "^4.5.0",
|
|
237
|
-
"tap": "^16.
|
|
237
|
+
"tap": "^16.3.4",
|
|
238
238
|
"temp": "^0.8.1",
|
|
239
239
|
"testdouble": "^3.16.6",
|
|
240
240
|
"when": "*"
|