newrelic 8.11.1 → 8.13.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 +24 -0
- package/THIRD_PARTY_NOTICES.md +33 -212
- package/api.js +12 -31
- package/lib/agent.js +70 -0
- package/lib/aggregators/log-aggregator.js +26 -2
- package/lib/collector/api.js +18 -14
- package/lib/collector/remote-method.js +37 -3
- package/lib/instrumentation/nr-winston-transport.js +108 -0
- package/lib/instrumentation/pino/nr-hooks.js +19 -0
- package/lib/instrumentation/pino/pino.js +156 -0
- package/lib/instrumentation/winston.js +87 -46
- package/lib/instrumentations.js +1 -0
- package/lib/metrics/index.js +19 -17
- package/lib/metrics/metric-aggregator.js +15 -11
- package/lib/metrics/names.js +14 -0
- package/lib/stats/index.js +13 -5
- package/lib/util/application-logging.js +97 -0
- package/package.json +5 -5
package/NEWS.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
### v8.13.0 (2022-05-26)
|
|
2
|
+
|
|
3
|
+
* Moved log forwarding logic to a transport so customer transports are not polluted with NR linking metadata and timestamp and error manipulations.
|
|
4
|
+
|
|
5
|
+
* Prevented transmitting logs when application level logging has been disabled.
|
|
6
|
+
|
|
7
|
+
### v8.12.0 (2022-05-24)
|
|
8
|
+
|
|
9
|
+
* Added instrumentation to pino to support application logging use cases: forwarding, local decorating, and metrics.
|
|
10
|
+
|
|
11
|
+
* Added supportability metrics about the data usage bytes of harvested data to the collector endpoints.
|
|
12
|
+
|
|
13
|
+
* Added an optional way to avoid wrapping browser agent script with <script> tag when using `api.getBrowserTimingHeader`. This will ease usage with Component based libraries like React.
|
|
14
|
+
|
|
15
|
+
Thanks to @github-dd-nicolas for the contribution. 🎉
|
|
16
|
+
|
|
17
|
+
* Upgraded `@grpc/proto-loader` to fix a [CVE](https://security.snyk.io/vuln/SNYK-JS-PROTOBUFJS-2441248) with `protobufjs`.
|
|
18
|
+
|
|
19
|
+
* Upgraded `@newrelic/test-utilities` to resolve a dev-only audit warning.
|
|
20
|
+
|
|
21
|
+
### v8.11.2 (2022-05-23)
|
|
22
|
+
|
|
23
|
+
* Fixed winston instrumentation to no longer coerce every log line to be json.
|
|
24
|
+
|
|
1
25
|
### v8.11.1 (2022-05-13)
|
|
2
26
|
|
|
3
27
|
* Fixed an issue with winston instrumentation that caused agent to crash when creating a winston logger from an existing instantiated logger.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -19,7 +19,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
19
19
|
* [@newrelic/aws-sdk](#newrelicaws-sdk)
|
|
20
20
|
* [@newrelic/koa](#newrelickoa)
|
|
21
21
|
* [@newrelic/superagent](#newrelicsuperagent)
|
|
22
|
-
* [@newrelic/winston-enricher](#newrelicwinston-enricher)
|
|
23
22
|
* [@tyriar/fibonacci-heap](#tyriarfibonacci-heap)
|
|
24
23
|
* [async](#async)
|
|
25
24
|
* [concat-stream](#concat-stream)
|
|
@@ -27,6 +26,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
|
|
|
27
26
|
* [json-stringify-safe](#json-stringify-safe)
|
|
28
27
|
* [readable-stream](#readable-stream)
|
|
29
28
|
* [semver](#semver)
|
|
29
|
+
* [winston-transport](#winston-transport)
|
|
30
30
|
|
|
31
31
|
**[devDependencies](#devDependencies)**
|
|
32
32
|
|
|
@@ -296,7 +296,7 @@ This product includes source derived from [@grpc/grpc-js](https://github.com/grp
|
|
|
296
296
|
|
|
297
297
|
### @grpc/proto-loader
|
|
298
298
|
|
|
299
|
-
This product includes source derived from [@grpc/proto-loader](https://github.com/grpc/grpc-node) ([v0.6.
|
|
299
|
+
This product includes source derived from [@grpc/proto-loader](https://github.com/grpc/grpc-node) ([v0.6.12](https://github.com/grpc/grpc-node/tree/v0.6.12)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/blob/v0.6.12/LICENSE):
|
|
300
300
|
|
|
301
301
|
```
|
|
302
302
|
Apache License
|
|
@@ -1129,215 +1129,6 @@ This product includes source derived from [@newrelic/superagent](https://github.
|
|
|
1129
1129
|
|
|
1130
1130
|
```
|
|
1131
1131
|
|
|
1132
|
-
### @newrelic/winston-enricher
|
|
1133
|
-
|
|
1134
|
-
This product includes source derived from [@newrelic/winston-enricher](https://github.com/newrelic/newrelic-node-log-extensions) ([v3.1.1](https://github.com/newrelic/newrelic-node-log-extensions/tree/v3.1.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/newrelic-node-log-extensions/blob/v3.1.1/LICENSE):
|
|
1135
|
-
|
|
1136
|
-
```
|
|
1137
|
-
Apache License
|
|
1138
|
-
Version 2.0, January 2004
|
|
1139
|
-
http://www.apache.org/licenses/
|
|
1140
|
-
|
|
1141
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
1142
|
-
|
|
1143
|
-
1. Definitions.
|
|
1144
|
-
|
|
1145
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
1146
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
1147
|
-
|
|
1148
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
1149
|
-
the copyright owner that is granting the License.
|
|
1150
|
-
|
|
1151
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
1152
|
-
other entities that control, are controlled by, or are under common
|
|
1153
|
-
control with that entity. For the purposes of this definition,
|
|
1154
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
1155
|
-
direction or management of such entity, whether by contract or
|
|
1156
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
1157
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
1158
|
-
|
|
1159
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
1160
|
-
exercising permissions granted by this License.
|
|
1161
|
-
|
|
1162
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
1163
|
-
including but not limited to software source code, documentation
|
|
1164
|
-
source, and configuration files.
|
|
1165
|
-
|
|
1166
|
-
"Object" form shall mean any form resulting from mechanical
|
|
1167
|
-
transformation or translation of a Source form, including but
|
|
1168
|
-
not limited to compiled object code, generated documentation,
|
|
1169
|
-
and conversions to other media types.
|
|
1170
|
-
|
|
1171
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
1172
|
-
Object form, made available under the License, as indicated by a
|
|
1173
|
-
copyright notice that is included in or attached to the work
|
|
1174
|
-
(an example is provided in the Appendix below).
|
|
1175
|
-
|
|
1176
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
1177
|
-
form, that is based on (or derived from) the Work and for which the
|
|
1178
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
1179
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
1180
|
-
of this License, Derivative Works shall not include works that remain
|
|
1181
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
1182
|
-
the Work and Derivative Works thereof.
|
|
1183
|
-
|
|
1184
|
-
"Contribution" shall mean any work of authorship, including
|
|
1185
|
-
the original version of the Work and any modifications or additions
|
|
1186
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
1187
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
1188
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
1189
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
1190
|
-
means any form of electronic, verbal, or written communication sent
|
|
1191
|
-
to the Licensor or its representatives, including but not limited to
|
|
1192
|
-
communication on electronic mailing lists, source code control systems,
|
|
1193
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
1194
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
1195
|
-
excluding communication that is conspicuously marked or otherwise
|
|
1196
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
1197
|
-
|
|
1198
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
1199
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
1200
|
-
subsequently incorporated within the Work.
|
|
1201
|
-
|
|
1202
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
1203
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
1204
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
1205
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
1206
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
1207
|
-
Work and such Derivative Works in Source or Object form.
|
|
1208
|
-
|
|
1209
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
1210
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
1211
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
1212
|
-
(except as stated in this section) patent license to make, have made,
|
|
1213
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
1214
|
-
where such license applies only to those patent claims licensable
|
|
1215
|
-
by such Contributor that are necessarily infringed by their
|
|
1216
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
1217
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
1218
|
-
institute patent litigation against any entity (including a
|
|
1219
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
1220
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
1221
|
-
or contributory patent infringement, then any patent licenses
|
|
1222
|
-
granted to You under this License for that Work shall terminate
|
|
1223
|
-
as of the date such litigation is filed.
|
|
1224
|
-
|
|
1225
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
1226
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
1227
|
-
modifications, and in Source or Object form, provided that You
|
|
1228
|
-
meet the following conditions:
|
|
1229
|
-
|
|
1230
|
-
(a) You must give any other recipients of the Work or
|
|
1231
|
-
Derivative Works a copy of this License; and
|
|
1232
|
-
|
|
1233
|
-
(b) You must cause any modified files to carry prominent notices
|
|
1234
|
-
stating that You changed the files; and
|
|
1235
|
-
|
|
1236
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
1237
|
-
that You distribute, all copyright, patent, trademark, and
|
|
1238
|
-
attribution notices from the Source form of the Work,
|
|
1239
|
-
excluding those notices that do not pertain to any part of
|
|
1240
|
-
the Derivative Works; and
|
|
1241
|
-
|
|
1242
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
1243
|
-
distribution, then any Derivative Works that You distribute must
|
|
1244
|
-
include a readable copy of the attribution notices contained
|
|
1245
|
-
within such NOTICE file, excluding those notices that do not
|
|
1246
|
-
pertain to any part of the Derivative Works, in at least one
|
|
1247
|
-
of the following places: within a NOTICE text file distributed
|
|
1248
|
-
as part of the Derivative Works; within the Source form or
|
|
1249
|
-
documentation, if provided along with the Derivative Works; or,
|
|
1250
|
-
within a display generated by the Derivative Works, if and
|
|
1251
|
-
wherever such third-party notices normally appear. The contents
|
|
1252
|
-
of the NOTICE file are for informational purposes only and
|
|
1253
|
-
do not modify the License. You may add Your own attribution
|
|
1254
|
-
notices within Derivative Works that You distribute, alongside
|
|
1255
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
1256
|
-
that such additional attribution notices cannot be construed
|
|
1257
|
-
as modifying the License.
|
|
1258
|
-
|
|
1259
|
-
You may add Your own copyright statement to Your modifications and
|
|
1260
|
-
may provide additional or different license terms and conditions
|
|
1261
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
1262
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
1263
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
1264
|
-
the conditions stated in this License.
|
|
1265
|
-
|
|
1266
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
1267
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
1268
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
1269
|
-
this License, without any additional terms or conditions.
|
|
1270
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
1271
|
-
the terms of any separate license agreement you may have executed
|
|
1272
|
-
with Licensor regarding such Contributions.
|
|
1273
|
-
|
|
1274
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
1275
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
1276
|
-
except as required for reasonable and customary use in describing the
|
|
1277
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
1278
|
-
|
|
1279
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
1280
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
1281
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
1282
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
1283
|
-
implied, including, without limitation, any warranties or conditions
|
|
1284
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
1285
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
1286
|
-
appropriateness of using or redistributing the Work and assume any
|
|
1287
|
-
risks associated with Your exercise of permissions under this License.
|
|
1288
|
-
|
|
1289
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
1290
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
1291
|
-
unless required by applicable law (such as deliberate and grossly
|
|
1292
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
1293
|
-
liable to You for damages, including any direct, indirect, special,
|
|
1294
|
-
incidental, or consequential damages of any character arising as a
|
|
1295
|
-
result of this License or out of the use or inability to use the
|
|
1296
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
1297
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
1298
|
-
other commercial damages or losses), even if such Contributor
|
|
1299
|
-
has been advised of the possibility of such damages.
|
|
1300
|
-
|
|
1301
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
1302
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
1303
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
1304
|
-
or other liability obligations and/or rights consistent with this
|
|
1305
|
-
License. However, in accepting such obligations, You may act only
|
|
1306
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
1307
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
1308
|
-
defend, and hold each Contributor harmless for any liability
|
|
1309
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
1310
|
-
of your accepting any such warranty or additional liability.
|
|
1311
|
-
|
|
1312
|
-
END OF TERMS AND CONDITIONS
|
|
1313
|
-
|
|
1314
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
1315
|
-
|
|
1316
|
-
To apply the Apache License to your work, attach the following
|
|
1317
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
1318
|
-
replaced with your own identifying information. (Don't include
|
|
1319
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
1320
|
-
comment syntax for the file format. We also recommend that a
|
|
1321
|
-
file or class name and description of purpose be included on the
|
|
1322
|
-
same "printed page" as the copyright notice for easier
|
|
1323
|
-
identification within third-party archives.
|
|
1324
|
-
|
|
1325
|
-
Copyright 2019 New Relic, Inc.
|
|
1326
|
-
|
|
1327
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1328
|
-
you may not use this file except in compliance with the License.
|
|
1329
|
-
You may obtain a copy of the License at
|
|
1330
|
-
|
|
1331
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
1332
|
-
|
|
1333
|
-
Unless required by applicable law or agreed to in writing, software
|
|
1334
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1335
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1336
|
-
See the License for the specific language governing permissions and
|
|
1337
|
-
limitations under the License.
|
|
1338
|
-
|
|
1339
|
-
```
|
|
1340
|
-
|
|
1341
1132
|
### @tyriar/fibonacci-heap
|
|
1342
1133
|
|
|
1343
1134
|
This product includes source derived from [@tyriar/fibonacci-heap](https://github.com/gwtw/ts-fibonacci-heap) ([v2.0.9](https://github.com/gwtw/ts-fibonacci-heap/tree/v2.0.9)), distributed under the [MIT License](https://github.com/gwtw/ts-fibonacci-heap/blob/v2.0.9/LICENSE):
|
|
@@ -1540,6 +1331,36 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
1540
1331
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
1541
1332
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
1542
1333
|
|
|
1334
|
+
```
|
|
1335
|
+
|
|
1336
|
+
### winston-transport
|
|
1337
|
+
|
|
1338
|
+
This product includes source derived from [winston-transport](https://github.com/winstonjs/winston-transport) ([v4.5.0](https://github.com/winstonjs/winston-transport/tree/v4.5.0)), distributed under the [MIT License](https://github.com/winstonjs/winston-transport/blob/v4.5.0/LICENSE):
|
|
1339
|
+
|
|
1340
|
+
```
|
|
1341
|
+
The MIT License (MIT)
|
|
1342
|
+
|
|
1343
|
+
Copyright (c) 2015 Charlie Robbins & the contributors.
|
|
1344
|
+
|
|
1345
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1346
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1347
|
+
in the Software without restriction, including without limitation the rights
|
|
1348
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1349
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1350
|
+
furnished to do so, subject to the following conditions:
|
|
1351
|
+
|
|
1352
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1353
|
+
copies or substantial portions of the Software.
|
|
1354
|
+
|
|
1355
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1356
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1357
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1358
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1359
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1360
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1361
|
+
SOFTWARE.
|
|
1362
|
+
|
|
1363
|
+
|
|
1543
1364
|
```
|
|
1544
1365
|
|
|
1545
1366
|
|
|
@@ -1980,7 +1801,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
1980
1801
|
|
|
1981
1802
|
### @newrelic/test-utilities
|
|
1982
1803
|
|
|
1983
|
-
This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v6.5.
|
|
1804
|
+
This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v6.5.3](https://github.com/newrelic/node-test-utilities/tree/v6.5.3)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v6.5.3/LICENSE):
|
|
1984
1805
|
|
|
1985
1806
|
```
|
|
1986
1807
|
Apache License
|
package/api.js
CHANGED
|
@@ -27,8 +27,8 @@ const NAMES = require('./lib/metrics/names')
|
|
|
27
27
|
* CONSTANTS
|
|
28
28
|
*
|
|
29
29
|
*/
|
|
30
|
-
const RUM_STUB =
|
|
31
|
-
|
|
30
|
+
const RUM_STUB = 'window.NREUM||(NREUM={});NREUM.info = %s;'
|
|
31
|
+
const RUM_STUB_SHELL = `<script type='text/javascript' %s>${RUM_STUB} %s</script>`
|
|
32
32
|
|
|
33
33
|
// these messages are used in the _gracefail() method below in getBrowserTimingHeader
|
|
34
34
|
const RUM_ISSUES = [
|
|
@@ -150,32 +150,7 @@ API.prototype.getLinkingMetadata = function getLinkingMetadata(omitSupportabilit
|
|
|
150
150
|
metric.incrementCallCount()
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const segment = agent.tracer.getSegment()
|
|
156
|
-
const config = agent.config
|
|
157
|
-
|
|
158
|
-
const linkingMetadata = {
|
|
159
|
-
'entity.name': config.applications()[0],
|
|
160
|
-
'entity.type': 'SERVICE',
|
|
161
|
-
'hostname': config.getHostnameSafe()
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (config.distributed_tracing.enabled && segment) {
|
|
165
|
-
linkingMetadata['trace.id'] = segment.transaction.traceId
|
|
166
|
-
const spanId = segment.getSpanId()
|
|
167
|
-
if (spanId) {
|
|
168
|
-
linkingMetadata['span.id'] = spanId
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
171
|
-
logger.debug('getLinkingMetadata with no active transaction')
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (config.entity_guid) {
|
|
175
|
-
linkingMetadata['entity.guid'] = config.entity_guid
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return linkingMetadata
|
|
153
|
+
return this.agent.getLinkingMetadata()
|
|
179
154
|
}
|
|
180
155
|
|
|
181
156
|
/**
|
|
@@ -514,19 +489,24 @@ API.prototype.addIgnoringRule = function addIgnoringRule(pattern) {
|
|
|
514
489
|
}
|
|
515
490
|
|
|
516
491
|
/**
|
|
517
|
-
* Get the
|
|
492
|
+
* Get the script header necessary for Browser Monitoring
|
|
518
493
|
* This script must be manually injected into your templates, as high as possible
|
|
519
494
|
* in the header, but _after_ any X-UA-COMPATIBLE HTTP-EQUIV meta tags.
|
|
520
495
|
* Otherwise you may hurt IE!
|
|
521
496
|
*
|
|
497
|
+
* By default this method will return a script wrapped by `<script>` tags, but with
|
|
498
|
+
* option `hasToRemoveScriptWrapper` it can send back only the script content
|
|
499
|
+
* without the `<script>` wrapper. Useful for React component based frontend.
|
|
500
|
+
*
|
|
522
501
|
* This method must be called _during_ a transaction, and must be called every
|
|
523
502
|
* time you want to generate the headers.
|
|
524
503
|
*
|
|
525
504
|
* Do *not* reuse the headers between users, or even between requests.
|
|
526
505
|
*
|
|
527
506
|
* @param {string} [options.nonce] - Nonce to inject into `<script>` header.
|
|
507
|
+
* @param {boolean} [options.hasToRemoveScriptWrapper] - Used to import agent script without `<script>` tag wrapper.
|
|
528
508
|
* @param options
|
|
529
|
-
* @returns {string} The
|
|
509
|
+
* @returns {string} The script content to be injected in `<head>` or put inside `<script>` tag (depending on options)
|
|
530
510
|
*/
|
|
531
511
|
API.prototype.getBrowserTimingHeader = function getBrowserTimingHeader(options) {
|
|
532
512
|
const metric = this.agent.metrics.getOrCreateMetric(
|
|
@@ -675,9 +655,10 @@ API.prototype.getBrowserTimingHeader = function getBrowserTimingHeader(options)
|
|
|
675
655
|
|
|
676
656
|
// set nonce attribute if passed in options
|
|
677
657
|
const nonce = options && options.nonce ? 'nonce="' + options.nonce + '"' : ''
|
|
658
|
+
const script = options && options.hasToRemoveScriptWrapper ? RUM_STUB : RUM_STUB_SHELL
|
|
678
659
|
|
|
679
660
|
// the complete header to be written to the browser
|
|
680
|
-
const out = util.format(
|
|
661
|
+
const out = util.format(script, nonce, json, jsAgentLoader)
|
|
681
662
|
|
|
682
663
|
logger.trace('generating RUM header', out)
|
|
683
664
|
|
package/lib/agent.js
CHANGED
|
@@ -923,6 +923,76 @@ Agent.prototype._listenForConfigChanges = function _listenForConfigChanges() {
|
|
|
923
923
|
})
|
|
924
924
|
}
|
|
925
925
|
|
|
926
|
+
/**
|
|
927
|
+
* This method returns an object with the following keys/data:
|
|
928
|
+
* - `trace.id`: The current trace ID
|
|
929
|
+
* - `span.id`: The current span ID
|
|
930
|
+
* - `entity.name`: The application name specified in the connect request as
|
|
931
|
+
* app_name. If multiple application names are specified this will only be
|
|
932
|
+
* the first name
|
|
933
|
+
* - `entity.type`: The string "SERVICE"
|
|
934
|
+
* - `entity.guid`: The entity ID returned in the connect reply as entity_guid
|
|
935
|
+
* - `hostname`: The hostname as specified in the connect request as
|
|
936
|
+
* utilization.full_hostname. If utilization.full_hostname is null or empty,
|
|
937
|
+
* this will be the hostname specified in the connect request as host.
|
|
938
|
+
*
|
|
939
|
+
* @returns {LinkingMetadata} The linking object with the data above
|
|
940
|
+
*/
|
|
941
|
+
Agent.prototype.getLinkingMetadata = function getLinkingMetadata() {
|
|
942
|
+
const segment = this.tracer.getSegment()
|
|
943
|
+
const config = this.config
|
|
944
|
+
|
|
945
|
+
const linkingMetadata = {
|
|
946
|
+
'entity.name': config.applications()[0],
|
|
947
|
+
'entity.type': 'SERVICE',
|
|
948
|
+
'hostname': config.getHostnameSafe()
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
if (config.distributed_tracing.enabled && segment) {
|
|
952
|
+
linkingMetadata['trace.id'] = segment.transaction.traceId
|
|
953
|
+
const spanId = segment.getSpanId()
|
|
954
|
+
if (spanId) {
|
|
955
|
+
linkingMetadata['span.id'] = spanId
|
|
956
|
+
}
|
|
957
|
+
} else {
|
|
958
|
+
logger.debug('getLinkingMetadata with no active transaction')
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
if (config.entity_guid) {
|
|
962
|
+
linkingMetadata['entity.guid'] = config.entity_guid
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
return linkingMetadata
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Formats the NR-LINKING blob that matches the spec
|
|
970
|
+
*
|
|
971
|
+
* @returns {string} formatted NR-LINKING string
|
|
972
|
+
*/
|
|
973
|
+
Agent.prototype.getNRLinkingMetadata = function getNRLinkingMetadata() {
|
|
974
|
+
const metadata = this.getLinkingMetadata()
|
|
975
|
+
const nrLinkingMeta = [
|
|
976
|
+
getValue('entity.guid'),
|
|
977
|
+
getValue('hostname'),
|
|
978
|
+
getValue('trace.id'),
|
|
979
|
+
getValue('span.id'),
|
|
980
|
+
encodeURIComponent(getValue('entity.name'))
|
|
981
|
+
]
|
|
982
|
+
|
|
983
|
+
return ` NR-LINKING|${nrLinkingMeta.join('|')}|`
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Retries value for a given key but defaults to `` if falsey
|
|
987
|
+
*
|
|
988
|
+
* @param {string} key in linking metadata
|
|
989
|
+
* @returns {string}
|
|
990
|
+
*/
|
|
991
|
+
function getValue(key) {
|
|
992
|
+
return metadata[key] || ''
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
926
996
|
function generateEventHarvestSupportMetrics(agent, harvestConfig) {
|
|
927
997
|
const harvestLimits = harvestConfig.harvest_limits
|
|
928
998
|
|
|
@@ -34,8 +34,21 @@ class LogAggregator extends EventAggregator {
|
|
|
34
34
|
return
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
const logs = events.toArray()
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Due to logging library implementation details
|
|
41
|
+
* some log lines are already JSON. We must de-serialize
|
|
42
|
+
* so it can be serialized in RemoteMethod. I know, this sucks.
|
|
43
|
+
*/
|
|
44
|
+
const formattedLogs = logs.map((logLine) => {
|
|
45
|
+
if (typeof logLine === 'string') {
|
|
46
|
+
return JSON.parse(logLine)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return logLine
|
|
50
|
+
})
|
|
51
|
+
return [{ logs: formattedLogs }]
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
add(logLine) {
|
|
@@ -52,6 +65,17 @@ class LogAggregator extends EventAggregator {
|
|
|
52
65
|
super.add(logLine, priority)
|
|
53
66
|
})
|
|
54
67
|
}
|
|
68
|
+
|
|
69
|
+
reconfigure(config) {
|
|
70
|
+
const oldLimit = this.limit
|
|
71
|
+
super.reconfigure(config)
|
|
72
|
+
if (this.limit <= 0 && oldLimit > 0) {
|
|
73
|
+
logger.debug('This New Relic account has disabled APM logs.')
|
|
74
|
+
this.clear()
|
|
75
|
+
} else if (oldLimit <= 0 && this.limit > 0) {
|
|
76
|
+
logger.debug('This New Relic account has re-enabled APM logs.')
|
|
77
|
+
}
|
|
78
|
+
}
|
|
55
79
|
}
|
|
56
80
|
|
|
57
81
|
module.exports = LogAggregator
|
package/lib/collector/api.js
CHANGED
|
@@ -68,20 +68,24 @@ function CollectorAPI(agent) {
|
|
|
68
68
|
/* RemoteMethods can be reused and have little per-object state, so why not
|
|
69
69
|
* save some GC time?
|
|
70
70
|
*/
|
|
71
|
-
this._methods = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
this._methods = {}
|
|
72
|
+
for (const [accessor, name] of [
|
|
73
|
+
['preconnect', 'preconnect'],
|
|
74
|
+
['connect', 'connect'],
|
|
75
|
+
['settings', 'agent_settings'],
|
|
76
|
+
['errors', 'error_data'],
|
|
77
|
+
['metrics', 'metric_data'],
|
|
78
|
+
['traces', 'transaction_sample_data'],
|
|
79
|
+
['shutdown', 'shutdown'],
|
|
80
|
+
['events', 'analytic_event_data'],
|
|
81
|
+
['customEvents', 'custom_event_data'],
|
|
82
|
+
['queryData', 'sql_trace_data'],
|
|
83
|
+
['errorEvents', 'error_event_data'],
|
|
84
|
+
['spanEvents', 'span_event_data'],
|
|
85
|
+
['logEvents', 'log_event_data']
|
|
86
|
+
]) {
|
|
87
|
+
const method = new RemoteMethod(name, agent, initialEndpoint)
|
|
88
|
+
this._methods[accessor] = method
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
|
|
@@ -16,6 +16,11 @@ const Sink = require('../util/stream-sink')
|
|
|
16
16
|
const agents = require('./http-agents')
|
|
17
17
|
const certificates = require('./ssl/certificates')
|
|
18
18
|
const isValidLength = require('../util/byte-limit').isValidLength
|
|
19
|
+
const { DATA_USAGE } = require('../metrics/names')
|
|
20
|
+
|
|
21
|
+
function getMetricName(name) {
|
|
22
|
+
return `${DATA_USAGE.PREFIX}/${name}/${DATA_USAGE.SUFFIX}`
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
/*
|
|
21
26
|
*
|
|
@@ -29,13 +34,17 @@ const USER_AGENT_FORMAT = 'NewRelic-NodeAgent/%s (nodejs %s %s-%s)'
|
|
|
29
34
|
const ENCODING_HEADER = 'CONTENT-ENCODING'
|
|
30
35
|
const DEFAULT_ENCODING = 'identity'
|
|
31
36
|
|
|
32
|
-
function RemoteMethod(name,
|
|
37
|
+
function RemoteMethod(name, agent, endpoint) {
|
|
33
38
|
if (!name) {
|
|
34
39
|
throw new TypeError('Must include name of method to invoke on collector.')
|
|
35
40
|
}
|
|
41
|
+
if (!agent) {
|
|
42
|
+
throw new TypeError('Must include an agent instance.')
|
|
43
|
+
}
|
|
36
44
|
|
|
37
45
|
this.name = name
|
|
38
|
-
this._config = config
|
|
46
|
+
this._config = agent.config
|
|
47
|
+
this._agent = agent
|
|
39
48
|
this._protocolVersion = 17
|
|
40
49
|
|
|
41
50
|
this.endpoint = endpoint
|
|
@@ -62,6 +71,21 @@ RemoteMethod.prototype.serialize = function serialize(payload, callback) {
|
|
|
62
71
|
return callback(null, res)
|
|
63
72
|
}
|
|
64
73
|
|
|
74
|
+
/**
|
|
75
|
+
* This records the amount of data usage per function call and sends
|
|
76
|
+
* it to the metrics.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} sent The serialized object we sent
|
|
79
|
+
* @param {object} received The raw object we got back as a response
|
|
80
|
+
*/
|
|
81
|
+
RemoteMethod.prototype._reportDataUsage = function reportDataUsage(sent, received) {
|
|
82
|
+
const payloadByteLength = byteLength(sent)
|
|
83
|
+
const responseByteLength = received ? byteLength(JSON.stringify(received)) : 0
|
|
84
|
+
const measurement = [payloadByteLength, responseByteLength, true]
|
|
85
|
+
this._agent.metrics.measureBytes(DATA_USAGE.COLLECTOR, ...measurement)
|
|
86
|
+
this._agent.metrics.measureBytes(getMetricName(this.name), ...measurement)
|
|
87
|
+
}
|
|
88
|
+
|
|
65
89
|
/**
|
|
66
90
|
* The primary operation on RemoteMethod objects. If you're calling anything on
|
|
67
91
|
* RemoteMethod objects aside from invoke (and you're not writing test code),
|
|
@@ -88,7 +112,14 @@ RemoteMethod.prototype.invoke = function invoke(payload, nrHeaders, callback) {
|
|
|
88
112
|
if (err) {
|
|
89
113
|
return callback(err)
|
|
90
114
|
}
|
|
91
|
-
this._post(
|
|
115
|
+
this._post(
|
|
116
|
+
serialized,
|
|
117
|
+
nrHeaders,
|
|
118
|
+
function onResponse(error, res) {
|
|
119
|
+
this._reportDataUsage(serialized, res && res.payload)
|
|
120
|
+
callback(error, res)
|
|
121
|
+
}.bind(this)
|
|
122
|
+
)
|
|
92
123
|
}.bind(this)
|
|
93
124
|
)
|
|
94
125
|
}
|
|
@@ -251,6 +282,7 @@ RemoteMethod.prototype._safeRequest = function _safeRequest(options) {
|
|
|
251
282
|
* original callback given to .send).
|
|
252
283
|
* @param {Function} options.onResponse Response handler for this request (created by
|
|
253
284
|
* ._post).
|
|
285
|
+
* @param options
|
|
254
286
|
*/
|
|
255
287
|
RemoteMethod.prototype._request = function _request(options) {
|
|
256
288
|
const requestOptions = {
|
|
@@ -375,6 +407,8 @@ RemoteMethod.prototype._headers = function _headers(options) {
|
|
|
375
407
|
* load on the collector down.
|
|
376
408
|
*
|
|
377
409
|
* FIXME: come up with a better heuristic
|
|
410
|
+
*
|
|
411
|
+
* @param data
|
|
378
412
|
*/
|
|
379
413
|
RemoteMethod.prototype._shouldCompress = function _shouldCompress(data) {
|
|
380
414
|
return data && byteLength(data) > 65536
|