newrelic 9.7.5 → 9.8.1
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 +31 -14
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/api.js +136 -96
- package/lib/instrumentation/winston.js +46 -12
- package/lib/utilization/gcp-info.js +5 -2
- package/package.json +2 -1
package/NEWS.md
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
|
-
### v9.
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
### v9.8.1 (2023-01-25)
|
|
2
|
+
|
|
3
|
+
* Changed GCP metadata parsing to use `json-bigint` to avoid loss of precision from numerical instance ID.
|
|
4
|
+
|
|
5
|
+
* Instrumented `winston.loggers.add` so it works like `winston.createLogger`.
|
|
6
|
+
|
|
7
|
+
### v9.8.0 (2023-01-17)
|
|
8
|
+
|
|
9
|
+
* Updated `getBrowserTimingHeader` to allow Browser Agent to be generated even when not in a Transaction by adding `allowTransactionlessInjection` to function options. `allowTransactionlessInjection` is a boolean option, and when set to `true`, will allow injection of the Browser Agent when not in a transaction. This is intended to be used in frameworks that build Static Site Generation(SSG). Note that if you are using this option, you may need to wait until the Node agent has established a connection before calling `getBrowserTimingHeader`. To wait until the agent is connected, you can add the following check to your code:
|
|
10
|
+
```js
|
|
11
|
+
if (!newrelic.agent.collector.isConnected()) {
|
|
12
|
+
await new Promise((resolve) => {
|
|
13
|
+
newrelic.agent.on('connected', resolve)
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### v9.7.5 (2023-01-03)
|
|
19
|
+
|
|
20
|
+
* Added a check to the code level metrics utility to ensure filePath was set before adding the `code.*` attributes.
|
|
21
|
+
|
|
22
|
+
* Updated to latest version of `@newrelic/test-utilities`
|
|
23
|
+
|
|
24
|
+
* Fixed issue where listing of dependencies and packages from symlinked nested directories created an infinite loop which caused the agent to never connect.
|
|
25
|
+
|
|
26
|
+
### v9.7.4 (2022-12-15)
|
|
27
|
+
|
|
28
|
+
* Fixed system info gathering to prevent unhandled promise rejection when an error occurs reading `/proc` information.
|
|
29
|
+
|
|
13
30
|
### v9.7.3 (2022-12-12)
|
|
14
31
|
|
|
15
32
|
* Added support for Code Level Metrics on API methods: `startSegment`, `startBackgroundTransaction`, and `startWebTransaction`.
|
|
@@ -3157,7 +3174,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
|
|
|
3157
3174
|
used for instrumenting web frameworks like `restify` or `express`.
|
|
3158
3175
|
|
|
3159
3176
|
Documentation and tutorials for the new API can be found on our GitHub
|
|
3160
|
-
documentation page: http://newrelic.github.io/node-newrelic/
|
|
3177
|
+
documentation page: http://newrelic.github.io/node-newrelic/
|
|
3161
3178
|
|
|
3162
3179
|
* Rewrote built-in instrumentation using the new `Shim` classes.
|
|
3163
3180
|
|
|
@@ -3246,7 +3263,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
|
|
|
3246
3263
|
meaning every instrumentation will create Middleware metrics for your server.
|
|
3247
3264
|
|
|
3248
3265
|
Tutorials on using the new instrumentation shim can be found on our API docs:
|
|
3249
|
-
http://newrelic.github.io/node-newrelic
|
|
3266
|
+
http://newrelic.github.io/node-newrelic/.
|
|
3250
3267
|
|
|
3251
3268
|
* Removed `express_segments` feature flag.
|
|
3252
3269
|
|
package/README.md
CHANGED
|
@@ -199,7 +199,7 @@ Here are some resources for learning more about the agent:
|
|
|
199
199
|
|
|
200
200
|
- [New Relic's official Node.js agent documentation](https://docs.newrelic.com/docs/agents/nodejs-agent)
|
|
201
201
|
|
|
202
|
-
- [Developer docs](http://newrelic.github.io/node-newrelic/
|
|
202
|
+
- [Developer docs](http://newrelic.github.io/node-newrelic/)
|
|
203
203
|
|
|
204
204
|
- [Configuring the agent using `newrelic.js` or environment variables](https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration)
|
|
205
205
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -22,6 +22,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
22
22
|
* [@tyriar/fibonacci-heap](#tyriarfibonacci-heap)
|
|
23
23
|
* [concat-stream](#concat-stream)
|
|
24
24
|
* [https-proxy-agent](#https-proxy-agent)
|
|
25
|
+
* [json-bigint](#json-bigint)
|
|
25
26
|
* [json-stringify-safe](#json-stringify-safe)
|
|
26
27
|
* [readable-stream](#readable-stream)
|
|
27
28
|
* [semver](#semver)
|
|
@@ -1202,6 +1203,34 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
1202
1203
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1203
1204
|
```
|
|
1204
1205
|
|
|
1206
|
+
### json-bigint
|
|
1207
|
+
|
|
1208
|
+
This product includes source derived from [json-bigint](https://github.com/sidorares/json-bigint) ([v1.0.0](https://github.com/sidorares/json-bigint/tree/v1.0.0)), distributed under the [MIT License](https://github.com/sidorares/json-bigint/blob/v1.0.0/LICENSE):
|
|
1209
|
+
|
|
1210
|
+
```
|
|
1211
|
+
The MIT License (MIT)
|
|
1212
|
+
|
|
1213
|
+
Copyright (c) 2013 Andrey Sidorov
|
|
1214
|
+
|
|
1215
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
1216
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
1217
|
+
the Software without restriction, including without limitation the rights to
|
|
1218
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
1219
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
1220
|
+
subject to the following conditions:
|
|
1221
|
+
|
|
1222
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1223
|
+
copies or substantial portions of the Software.
|
|
1224
|
+
|
|
1225
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1226
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
1227
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
1228
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
1229
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
1230
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1231
|
+
|
|
1232
|
+
```
|
|
1233
|
+
|
|
1205
1234
|
### json-stringify-safe
|
|
1206
1235
|
|
|
1207
1236
|
This product includes source derived from [json-stringify-safe](https://github.com/isaacs/json-stringify-safe) ([v5.0.1](https://github.com/isaacs/json-stringify-safe/tree/v5.0.1)), distributed under the [ISC License](https://github.com/isaacs/json-stringify-safe/blob/v5.0.1/LICENSE):
|
package/api.js
CHANGED
|
@@ -40,7 +40,7 @@ const RUM_STUB_SHELL_WITH_NONCE_PARAM = `<script type='text/javascript' %s>${RUM
|
|
|
40
40
|
// these messages are used in the _gracefail() method below in getBrowserTimingHeader
|
|
41
41
|
const RUM_ISSUES = [
|
|
42
42
|
'NREUM: no browser monitoring headers generated; disabled',
|
|
43
|
-
'NREUM: transaction
|
|
43
|
+
'NREUM: transaction ignored while generating browser monitoring headers',
|
|
44
44
|
'NREUM: config.browser_monitoring missing, something is probably wrong',
|
|
45
45
|
'NREUM: browser_monitoring headers need a transaction name',
|
|
46
46
|
'NREUM: browser_monitoring requires valid application_id',
|
|
@@ -640,144 +640,180 @@ function _generateRUMHeader(options = {}, metadata, loader) {
|
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
/**
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* in the header, but _after_ any X-UA-COMPATIBLE HTTP-EQUIV meta tags.
|
|
646
|
-
* Otherwise you may hurt IE!
|
|
647
|
-
*
|
|
648
|
-
* By default this method will return a script wrapped by `<script>` tags, but with
|
|
649
|
-
* option `hasToRemoveScriptWrapper` it can send back only the script content
|
|
650
|
-
* without the `<script>` wrapper. Useful for React component based frontend.
|
|
651
|
-
*
|
|
652
|
-
* This method must be called _during_ a transaction, and must be called every
|
|
653
|
-
* time you want to generate the headers.
|
|
643
|
+
* Helper method for determining if we have the minimum required
|
|
644
|
+
* information to generate our Browser Agent script tag
|
|
654
645
|
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
* @param {
|
|
658
|
-
* @
|
|
659
|
-
* @param {boolean} [options.hasToRemoveScriptWrapper] - Used to import agent script without `<script>` tag wrapper.
|
|
660
|
-
* @returns {string} The script content to be injected in `<head>` or put inside `<script>` tag (depending on options)
|
|
646
|
+
* @param {object} config agent configuration settings
|
|
647
|
+
* @param {Transaction} transaction the active transaction or null
|
|
648
|
+
* @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?: number, quietMode?: boolean }} object containing validation results
|
|
661
650
|
*/
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
const browserMonitoring = config.browser_monitoring
|
|
671
|
-
|
|
672
|
-
// config.browser_monitoring should always exist, but we don't want the agent
|
|
673
|
-
// to bail here if something goes wrong
|
|
674
|
-
if (!browserMonitoring) {
|
|
675
|
-
return _gracefail(2)
|
|
651
|
+
function validateBrowserMonitoring(config, transaction, allowTransactionlessInjection) {
|
|
652
|
+
/*
|
|
653
|
+
* config.browser_monitoring should always exist, but we don't want the agent
|
|
654
|
+
* to bail here if something goes wrong
|
|
655
|
+
*/
|
|
656
|
+
if (!config.browser_monitoring) {
|
|
657
|
+
return { isValidConfig: false, failureIdx: 2 }
|
|
676
658
|
}
|
|
677
659
|
|
|
678
|
-
/*
|
|
660
|
+
/*
|
|
661
|
+
* Can control header generation with configuration this setting is only
|
|
679
662
|
* available in the newrelic.js config file, it is not ever set by the
|
|
680
663
|
* server.
|
|
681
664
|
*/
|
|
682
|
-
if (!
|
|
665
|
+
if (!config.browser_monitoring.enable) {
|
|
683
666
|
// It has been disabled by the user; no need to warn them about their own
|
|
684
667
|
// settings so fail quietly and gracefully.
|
|
685
|
-
return
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
const trans = this.agent.getTransaction()
|
|
689
|
-
|
|
690
|
-
// bail gracefully outside a transaction
|
|
691
|
-
if (!trans || trans.isIgnored()) {
|
|
692
|
-
return _gracefail(1)
|
|
668
|
+
return { isValidConfig: false, failureIdx: 0, quietMode: true }
|
|
693
669
|
}
|
|
694
670
|
|
|
695
|
-
const name = trans.getFullName()
|
|
696
|
-
|
|
697
|
-
/* If we're in an unnamed transaction, add a friendly warning this is to
|
|
698
|
-
* avoid people going crazy, trying to figure out why browser monitoring is
|
|
699
|
-
* not working when they're missing a transaction name.
|
|
700
|
-
*/
|
|
701
|
-
if (!name) {
|
|
702
|
-
return _gracefail(3)
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
const time = trans.timer.getDurationInMillis()
|
|
706
|
-
|
|
707
671
|
/*
|
|
708
|
-
*
|
|
709
|
-
* the transaction name.
|
|
710
|
-
*/
|
|
711
|
-
const key = config.license_key.substr(0, 13)
|
|
712
|
-
const appid = config.application_id
|
|
713
|
-
|
|
714
|
-
/* This is only going to work if the agent has successfully handshaked with
|
|
672
|
+
* This is only going to work if the agent has successfully handshaked with
|
|
715
673
|
* the collector. If the networks is bad, or there is no license key set in
|
|
716
674
|
* newrelic.js, there will be no application_id set. We bail instead of
|
|
717
675
|
* outputting null/undefined configuration values.
|
|
718
676
|
*/
|
|
719
|
-
if (!
|
|
720
|
-
return
|
|
677
|
+
if (!config.application_id) {
|
|
678
|
+
return { isValidConfig: false, failureIdx: 4 }
|
|
721
679
|
}
|
|
722
680
|
|
|
723
|
-
/*
|
|
681
|
+
/*
|
|
682
|
+
* If there is no browser_key, the server has likely decided to disable
|
|
724
683
|
* browser monitoring.
|
|
725
684
|
*/
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
return _gracefail(5)
|
|
685
|
+
if (!config.browser_monitoring.browser_key) {
|
|
686
|
+
return { isValidConfig: false, failureIdx: 5 }
|
|
729
687
|
}
|
|
730
688
|
|
|
731
|
-
/*
|
|
689
|
+
/*
|
|
690
|
+
* If there is no agent_loader script, there is no point
|
|
732
691
|
* in setting the rum data
|
|
733
692
|
*/
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
return _gracefail(6)
|
|
693
|
+
if (!config.browser_monitoring.js_agent_loader) {
|
|
694
|
+
return { isValidConfig: false, failureIdx: 6 }
|
|
737
695
|
}
|
|
738
696
|
|
|
739
|
-
/*
|
|
697
|
+
/*
|
|
698
|
+
* If rum is enabled, but then later disabled on the server,
|
|
740
699
|
* this is the only parameter that gets updated.
|
|
741
700
|
*
|
|
742
701
|
* This condition should only be met if rum is disabled during
|
|
743
702
|
* the lifetime of an application, and it should be picked up
|
|
744
703
|
* on the next ForceRestart by the collector.
|
|
745
704
|
*/
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
return _gracefail(7)
|
|
705
|
+
if (config.browser_monitoring.loader === 'none') {
|
|
706
|
+
return { isValidConfig: false, failureIdx: 7 }
|
|
749
707
|
}
|
|
750
708
|
|
|
709
|
+
if (!allowTransactionlessInjection && !transaction) {
|
|
710
|
+
return { isValidConfig: false, failureIdx: 1 }
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return { isValidConfig: true }
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Get the script header necessary for Browser Monitoring
|
|
718
|
+
* This script must be manually injected into your templates, as high as possible
|
|
719
|
+
* in the header, but _after_ any X-UA-COMPATIBLE HTTP-EQUIV meta tags.
|
|
720
|
+
* Otherwise you may hurt IE!
|
|
721
|
+
*
|
|
722
|
+
* By default this method will return a script wrapped by `<script>` tags, but with
|
|
723
|
+
* option `hasToRemoveScriptWrapper` it can send back only the script content
|
|
724
|
+
* without the `<script>` wrapper. Useful for React component based frontend.
|
|
725
|
+
*
|
|
726
|
+
* This method must be called every time you want to generate the headers.
|
|
727
|
+
*
|
|
728
|
+
* Do *not* reuse the headers between users, or even between requests.
|
|
729
|
+
*
|
|
730
|
+
* @param {object} options configuration options
|
|
731
|
+
* @param {string} [options.nonce] - Nonce to inject into `<script>` header.
|
|
732
|
+
* @param {boolean} [options.hasToRemoveScriptWrapper] - Used to import agent script without `<script>` tag wrapper.
|
|
733
|
+
* @param {options} [options.allowTransactionlessInjection] Whether or not to allow the Browser Agent to be injected when there is no active transaction
|
|
734
|
+
* @returns {string} The script content to be injected in `<head>` or put inside `<script>` tag (depending on options)
|
|
735
|
+
*/
|
|
736
|
+
API.prototype.getBrowserTimingHeader = function getBrowserTimingHeader(options = {}) {
|
|
737
|
+
const metric = this.agent.metrics.getOrCreateMetric(
|
|
738
|
+
NAMES.SUPPORTABILITY.API + '/getBrowserTimingHeader'
|
|
739
|
+
)
|
|
740
|
+
metric.incrementCallCount()
|
|
741
|
+
|
|
742
|
+
const trans = this.agent.getTransaction()
|
|
743
|
+
|
|
744
|
+
const { isValidConfig, failureIdx, quietMode } = validateBrowserMonitoring(
|
|
745
|
+
this.agent.config,
|
|
746
|
+
trans,
|
|
747
|
+
options.allowTransactionlessInjection
|
|
748
|
+
)
|
|
749
|
+
|
|
750
|
+
if (!isValidConfig) {
|
|
751
|
+
return _gracefail(failureIdx, quietMode)
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
const config = this.agent.config
|
|
755
|
+
|
|
751
756
|
// This hash gets written directly into the browser.
|
|
752
757
|
const rumHash = {
|
|
753
|
-
agent:
|
|
754
|
-
beacon:
|
|
755
|
-
errorBeacon:
|
|
756
|
-
licenseKey:
|
|
757
|
-
applicationID:
|
|
758
|
-
applicationTime: time,
|
|
759
|
-
transactionName: hashes.obfuscateNameUsingKey(name, key),
|
|
760
|
-
queueTime: trans.queueTime,
|
|
761
|
-
ttGuid: trans.id,
|
|
758
|
+
agent: config.browser_monitoring.js_agent_file,
|
|
759
|
+
beacon: config.browser_monitoring.beacon,
|
|
760
|
+
errorBeacon: config.browser_monitoring.error_beacon,
|
|
761
|
+
licenseKey: config.browser_monitoring.browser_key,
|
|
762
|
+
applicationID: config.application_id,
|
|
762
763
|
|
|
763
764
|
// we don't use these parameters yet
|
|
764
765
|
agentToken: null
|
|
765
766
|
}
|
|
766
767
|
|
|
767
|
-
const
|
|
768
|
+
const hasActiveTransaction = trans !== null
|
|
768
769
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
770
|
+
if (hasActiveTransaction) {
|
|
771
|
+
// bail gracefully outside an ignored transaction
|
|
772
|
+
if (trans.isIgnored()) {
|
|
773
|
+
return _gracefail(1)
|
|
774
|
+
}
|
|
773
775
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
776
|
+
/* If we're in an unnamed transaction, add a friendly warning this is to
|
|
777
|
+
* avoid people going crazy, trying to figure out why browser monitoring is
|
|
778
|
+
* not working when they're missing a transaction name.
|
|
779
|
+
*/
|
|
780
|
+
const name = trans.getFullName()
|
|
781
|
+
if (!name) {
|
|
782
|
+
return _gracefail(3)
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
const time = trans.timer.getDurationInMillis()
|
|
786
|
+
rumHash.applicationTime = time
|
|
787
|
+
|
|
788
|
+
/*
|
|
789
|
+
* Only the first 13 chars of the license should be used for hashing with
|
|
790
|
+
* the transaction name.
|
|
791
|
+
*/
|
|
792
|
+
const key = config.license_key.substr(0, 13)
|
|
793
|
+
rumHash.transactionName = hashes.obfuscateNameUsingKey(name, key)
|
|
778
794
|
|
|
779
|
-
|
|
780
|
-
rumHash.
|
|
795
|
+
rumHash.queueTime = trans.queueTime
|
|
796
|
+
rumHash.ttGuid = trans.id
|
|
797
|
+
|
|
798
|
+
const attrs = Object.create(null)
|
|
799
|
+
|
|
800
|
+
const customAttrs = trans.trace.custom.get(ATTR_DEST.BROWSER_EVENT)
|
|
801
|
+
if (!properties.isEmpty(customAttrs)) {
|
|
802
|
+
attrs.u = customAttrs
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
const agentAttrs = trans.trace.attributes.get(ATTR_DEST.BROWSER_EVENT)
|
|
806
|
+
if (!properties.isEmpty(agentAttrs)) {
|
|
807
|
+
attrs.a = agentAttrs
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
if (!properties.isEmpty(attrs)) {
|
|
811
|
+
rumHash.atts = hashes.obfuscateNameUsingKey(JSON.stringify(attrs), key)
|
|
812
|
+
}
|
|
813
|
+
} else {
|
|
814
|
+
logger.debug(
|
|
815
|
+
'No transaction detected when generating RUM header, continuing without transaction info'
|
|
816
|
+
)
|
|
781
817
|
}
|
|
782
818
|
|
|
783
819
|
// if debugging, do pretty format of JSON
|
|
@@ -785,7 +821,11 @@ API.prototype.getBrowserTimingHeader = function getBrowserTimingHeader(options)
|
|
|
785
821
|
const json = JSON.stringify(rumHash, null, tabs)
|
|
786
822
|
|
|
787
823
|
// the complete header to be written to the browser
|
|
788
|
-
const out = _generateRUMHeader(
|
|
824
|
+
const out = _generateRUMHeader(
|
|
825
|
+
{ nonce: options.nonce, hasToRemoveScriptWrapper: options.hasToRemoveScriptWrapper },
|
|
826
|
+
json,
|
|
827
|
+
config.browser_monitoring.js_agent_loader
|
|
828
|
+
)
|
|
789
829
|
|
|
790
830
|
logger.trace('generating RUM header', out)
|
|
791
831
|
|
|
@@ -27,28 +27,62 @@ module.exports = function instrument(agent, winston, _, shim) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
shim.wrap(winston, 'createLogger', function wrapCreate(shim, createLogger) {
|
|
30
|
-
return function
|
|
30
|
+
return function wrappedCreateLogger() {
|
|
31
31
|
const args = shim.argsToArray.apply(shim, arguments)
|
|
32
32
|
const opts = args[0] || {}
|
|
33
33
|
if (isStream(opts)) {
|
|
34
34
|
return createLogger.apply(this, args)
|
|
35
35
|
}
|
|
36
|
+
return performInstrumentation({
|
|
37
|
+
obj: this,
|
|
38
|
+
args,
|
|
39
|
+
opts,
|
|
40
|
+
agent,
|
|
41
|
+
winston,
|
|
42
|
+
registerLogger: createLogger
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
})
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
shim.wrap(winston.loggers, 'add', function wrapAdd(shim, add) {
|
|
48
|
+
return function wrappedAdd() {
|
|
49
|
+
const args = shim.argsToArray.apply(shim, arguments)
|
|
50
|
+
const id = args[0]
|
|
51
|
+
const opts = args[1] || {}
|
|
52
|
+
// add does nothing if the logger has already been added, so we
|
|
53
|
+
// have to do the same nothingness here.
|
|
54
|
+
const alreadyAdded = this.loggers.has(id)
|
|
55
|
+
if (alreadyAdded || isStream(opts)) {
|
|
56
|
+
return add.apply(this, args)
|
|
41
57
|
}
|
|
58
|
+
return performInstrumentation({
|
|
59
|
+
obj: this,
|
|
60
|
+
args,
|
|
61
|
+
opts,
|
|
62
|
+
agent,
|
|
63
|
+
winston,
|
|
64
|
+
registerLogger: add
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function performInstrumentation({ obj, args, opts, agent, winston, registerLogger }) {
|
|
71
|
+
const config = agent.config
|
|
42
72
|
|
|
43
|
-
|
|
73
|
+
createModuleUsageMetric('winston', agent.metrics)
|
|
44
74
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
75
|
+
if (isLocalDecoratingEnabled(config) || isMetricsEnabled(config)) {
|
|
76
|
+
registerFormatter({ opts, agent, winston })
|
|
77
|
+
}
|
|
48
78
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
const winstonLogger = registerLogger.apply(obj, args)
|
|
80
|
+
|
|
81
|
+
if (isLogForwardingEnabled(config, agent)) {
|
|
82
|
+
winstonLogger.add(new NrTransport({ agent }))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return winstonLogger
|
|
52
86
|
}
|
|
53
87
|
|
|
54
88
|
/**
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const logger = require('../logger.js').child({ component: 'gcp-info' })
|
|
9
9
|
const common = require('./common')
|
|
10
10
|
const NAMES = require('../metrics/names.js')
|
|
11
|
+
const JSONbig = require('json-bigint')({ useNativeBigInt: true })
|
|
11
12
|
let resultDict = null
|
|
12
13
|
|
|
13
14
|
module.exports = fetchGCPInfo
|
|
@@ -37,9 +38,11 @@ function fetchGCPInfo(agent, callback) {
|
|
|
37
38
|
if (err) {
|
|
38
39
|
return callback(err)
|
|
39
40
|
}
|
|
40
|
-
|
|
41
41
|
try {
|
|
42
|
-
data =
|
|
42
|
+
data = JSONbig.parse(data)
|
|
43
|
+
if (typeof data.id !== 'string') {
|
|
44
|
+
data.id = data.id.toString()
|
|
45
|
+
}
|
|
43
46
|
} catch (e) {
|
|
44
47
|
logger.debug(e, 'Failed to parse GCP metadata.')
|
|
45
48
|
data = null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newrelic",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.1",
|
|
4
4
|
"author": "New Relic Node.js agent team <nodejs@newrelic.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"contributors": [
|
|
@@ -187,6 +187,7 @@
|
|
|
187
187
|
"@tyriar/fibonacci-heap": "^2.0.7",
|
|
188
188
|
"concat-stream": "^2.0.0",
|
|
189
189
|
"https-proxy-agent": "^5.0.0",
|
|
190
|
+
"json-bigint": "^1.0.0",
|
|
190
191
|
"json-stringify-safe": "^5.0.0",
|
|
191
192
|
"readable-stream": "^3.6.0",
|
|
192
193
|
"semver": "^5.3.0",
|