newrelic 8.10.0 → 8.11.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 +61 -24
- package/THIRD_PARTY_NOTICES.md +212 -2
- package/lib/agent.js +62 -0
- package/lib/aggregators/log-aggregator.js +57 -0
- package/lib/collector/api.js +71 -2
- package/lib/collector/facts.js +41 -1
- package/lib/collector/serverless.js +23 -3
- package/lib/config/default.js +50 -10
- package/lib/config/env.js +20 -2
- package/lib/config/hsm.js +5 -0
- package/lib/config/index.js +2 -1
- package/lib/instrumentation/@node-redis/client.js +61 -0
- package/lib/instrumentation/@redis/client.js +7 -0
- package/lib/instrumentation/core/child_process.js +1 -1
- package/lib/instrumentation/winston.js +58 -0
- package/lib/instrumentations.js +4 -1
- package/lib/metrics/names.js +25 -2
- package/lib/transaction/index.js +16 -11
- package/lib/transaction/logs.js +46 -0
- package/newrelic.js +8 -16
- package/package.json +3 -2
package/NEWS.md
CHANGED
|
@@ -1,28 +1,65 @@
|
|
|
1
|
-
### v8.
|
|
2
|
-
|
|
3
|
-
* Added
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
### v8.11.0 (2022-05-11)
|
|
2
|
+
|
|
3
|
+
* Added application logging for Winston in the Node.js agent
|
|
4
|
+
|
|
5
|
+
* Ability to forward logs, send log metrics, and perform local log decoration
|
|
6
|
+
|
|
7
|
+
* Added application log aggregator to collect logs with adaptive sampling and appropriate max samples stored.
|
|
8
|
+
|
|
9
|
+
* Added `application_logging` configuration and env vars with appropriate defaults.
|
|
10
|
+
|
|
11
|
+
* Added `application_logging.enabled` configuration value, defaulting to true.
|
|
12
|
+
|
|
13
|
+
* Set `application_logging.forwarding.enabled` to false when High Security Mode (HSM) is set.
|
|
14
|
+
|
|
15
|
+
* Enabled log forwarding by default in the example config.
|
|
16
|
+
|
|
17
|
+
* Added sent, seen and dropped metrics that collected on every harvest cycle around log lines.
|
|
18
|
+
|
|
19
|
+
* Added supportability metrics for some popular logging frameworks.
|
|
20
|
+
|
|
21
|
+
* Added supportability metrics to record if the logging features are enabled.
|
|
22
|
+
|
|
23
|
+
* Added a storage mechanisms to transactions to keep logs until transaction ends.
|
|
24
|
+
|
|
25
|
+
* Removed distributed tracing setting from example config
|
|
26
|
+
|
|
27
|
+
* Fixed a typo in lib/instrumentation/core/child_process.js
|
|
28
|
+
Thanks to Eito Katagiri (@eitoball) for the contribution
|
|
29
|
+
|
|
30
|
+
* Support automatic instrumentation of Redis v4
|
|
31
|
+
|
|
32
|
+
* Bumped [moment](https://github.com/moment/moment) from 2.29.1 to 2.29.2.
|
|
33
|
+
|
|
34
|
+
* Bumped `tap` to 16.x.
|
|
35
|
+
|
|
36
|
+
* Updated `ansi-regex` to resolve a dev dependency audit warning.
|
|
37
|
+
|
|
38
|
+
### v8.10.0 (2022-04-18)
|
|
39
|
+
|
|
40
|
+
* Added instrumentation for `mysql2/promise`.
|
|
41
|
+
* This previously only existed in our standalone `@newrelic/mysql`, but now gives feature partiy between the two.
|
|
42
|
+
|
|
43
|
+
* Removed unused native CPU metric sampler. This logic was no longer getting touched if running Node.js > 6.1.0.
|
|
44
|
+
|
|
45
|
+
* Fixed promise interceptor from re-throwing errors.
|
|
46
|
+
|
|
47
|
+
* Added transaction naming documentation ported from a discussion forum post: https://discuss.newrelic.com/t/relic-solution-the-philosophy-of-naming-your-node-agent-transactions/.
|
|
48
|
+
|
|
49
|
+
* Added `promises.tap.js` to mysql2 versioned tests.
|
|
50
|
+
|
|
14
51
|
* Updated @newrelic/test-utilities to latest.
|
|
15
|
-
* Removed unused test file in restify versioned tests.
|
|
16
|
-
* Added `--strict` flag to versioned test runner to properly fail CI runs when test files are not included.
|
|
17
|
-
|
|
18
|
-
### v8.9.1 (2022-03-22)
|
|
19
|
-
|
|
20
|
-
* Fixed `shim.wrapReturn` to call `Reflect.construct` in construct Proxy trap. Also including `newTarget` to work with inherited classes.
|
|
21
|
-
|
|
22
|
-
* Added link to New Relic Node.js Examples repository.
|
|
23
|
-
|
|
24
|
-
* Excluded installing dependencies in `versioned-external` folders when running integration tests.
|
|
25
|
-
|
|
52
|
+
* Removed unused test file in restify versioned tests.
|
|
53
|
+
* Added `--strict` flag to versioned test runner to properly fail CI runs when test files are not included.
|
|
54
|
+
|
|
55
|
+
### v8.9.1 (2022-03-22)
|
|
56
|
+
|
|
57
|
+
* Fixed `shim.wrapReturn` to call `Reflect.construct` in construct Proxy trap. Also including `newTarget` to work with inherited classes.
|
|
58
|
+
|
|
59
|
+
* Added link to New Relic Node.js Examples repository.
|
|
60
|
+
|
|
61
|
+
* Excluded installing dependencies in `versioned-external` folders when running integration tests.
|
|
62
|
+
|
|
26
63
|
### v8.9.0 (2022-03-15)
|
|
27
64
|
|
|
28
65
|
* Added support for `initializeUnorderedBulkOp`, and `initializeOrderedBulkOp` in mongodb v3 instrumentation.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -19,6 +19,7 @@ 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)
|
|
22
23
|
* [@tyriar/fibonacci-heap](#tyriarfibonacci-heap)
|
|
23
24
|
* [async](#async)
|
|
24
25
|
* [concat-stream](#concat-stream)
|
|
@@ -1128,6 +1129,215 @@ This product includes source derived from [@newrelic/superagent](https://github.
|
|
|
1128
1129
|
|
|
1129
1130
|
```
|
|
1130
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
|
+
|
|
1131
1341
|
### @tyriar/fibonacci-heap
|
|
1132
1342
|
|
|
1133
1343
|
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):
|
|
@@ -3292,12 +3502,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
3292
3502
|
|
|
3293
3503
|
### tap
|
|
3294
3504
|
|
|
3295
|
-
This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([
|
|
3505
|
+
This product includes source derived from [tap](https://github.com/tapjs/node-tap) ([v16.0.1](https://github.com/tapjs/node-tap/tree/v16.0.1)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v16.0.1/LICENSE):
|
|
3296
3506
|
|
|
3297
3507
|
```
|
|
3298
3508
|
The ISC License
|
|
3299
3509
|
|
|
3300
|
-
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
3510
|
+
Copyright (c) 2011-2022 Isaac Z. Schlueter and Contributors
|
|
3301
3511
|
|
|
3302
3512
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
3303
3513
|
purpose with or without fee is hereby granted, provided that the above
|
package/lib/agent.js
CHANGED
|
@@ -16,6 +16,7 @@ const ErrorEventAggregator = require('./errors/error-event-aggregator')
|
|
|
16
16
|
const EventEmitter = require('events').EventEmitter
|
|
17
17
|
const hashes = require('./util/hashes')
|
|
18
18
|
const logger = require('./logger')
|
|
19
|
+
const LogAggregator = require('./aggregators/log-aggregator')
|
|
19
20
|
const MetricMapper = require('./metrics/mapper')
|
|
20
21
|
const MetricNormalizer = require('./metrics/normalizer')
|
|
21
22
|
const MetricAggregator = require('./metrics/metric-aggregator')
|
|
@@ -137,6 +138,16 @@ function Agent(config) {
|
|
|
137
138
|
this.metrics
|
|
138
139
|
)
|
|
139
140
|
|
|
141
|
+
this.logs = new LogAggregator(
|
|
142
|
+
{
|
|
143
|
+
periodMs: config.event_harvest_config.report_period_ms,
|
|
144
|
+
limit: config.event_harvest_config.harvest_limits.log_event_data
|
|
145
|
+
},
|
|
146
|
+
this.collector,
|
|
147
|
+
this.metrics,
|
|
148
|
+
this
|
|
149
|
+
)
|
|
150
|
+
|
|
140
151
|
this.errors = new ErrorCollector(config, errorTraceAggregator, errorEventAggregator, this.metrics)
|
|
141
152
|
|
|
142
153
|
this._contextManager = createContextManager(this.config)
|
|
@@ -366,6 +377,20 @@ Agent.prototype.forceHarvestAll = function forceHarvestAll(callback) {
|
|
|
366
377
|
promises.push(errorEventPromise)
|
|
367
378
|
}
|
|
368
379
|
|
|
380
|
+
if (
|
|
381
|
+
agent.config.application_logging.enabled &&
|
|
382
|
+
agent.config.application_logging.forwarding.enabled
|
|
383
|
+
) {
|
|
384
|
+
const logEventPromise = new Promise((resolve) => {
|
|
385
|
+
agent.logs.once('finished log_event_data data send.', function onLogEventsFinished() {
|
|
386
|
+
resolve()
|
|
387
|
+
})
|
|
388
|
+
agent.logs.send()
|
|
389
|
+
})
|
|
390
|
+
|
|
391
|
+
promises.push(logEventPromise)
|
|
392
|
+
}
|
|
393
|
+
|
|
369
394
|
Promise.all(promises).then(() => {
|
|
370
395
|
// Get out of the promise so callback errors aren't treated as
|
|
371
396
|
// promise rejections.
|
|
@@ -381,6 +406,7 @@ Agent.prototype.stopAggregators = function stopAggregators() {
|
|
|
381
406
|
this.spanEventAggregator.stop()
|
|
382
407
|
this.transactionEventAggregator.stop()
|
|
383
408
|
this.customEventAggregator.stop()
|
|
409
|
+
this.logs.stop()
|
|
384
410
|
}
|
|
385
411
|
|
|
386
412
|
Agent.prototype.startStreaming = function startStreaming() {
|
|
@@ -415,6 +441,13 @@ Agent.prototype.startAggregators = function startAggregators() {
|
|
|
415
441
|
if (this.config.custom_insights_events.enabled) {
|
|
416
442
|
this.customEventAggregator.start()
|
|
417
443
|
}
|
|
444
|
+
|
|
445
|
+
if (
|
|
446
|
+
this.config.application_logging.enabled &&
|
|
447
|
+
this.config.application_logging.forwarding.enabled
|
|
448
|
+
) {
|
|
449
|
+
this.logs.start()
|
|
450
|
+
}
|
|
418
451
|
}
|
|
419
452
|
|
|
420
453
|
/**
|
|
@@ -427,6 +460,8 @@ Agent.prototype.startAggregators = function startAggregators() {
|
|
|
427
460
|
Agent.prototype.onConnect = function onConnect(shouldImmediatelyHarvest, callback) {
|
|
428
461
|
this._reconfigureAggregators(this.config)
|
|
429
462
|
|
|
463
|
+
generateLoggingSupportMetrics(this)
|
|
464
|
+
|
|
430
465
|
if (this.config.certificates && this.config.certificates.length > 0) {
|
|
431
466
|
this.metrics.getOrCreateMetric(NAMES.FEATURES.CERTIFICATES).incrementCallCount()
|
|
432
467
|
}
|
|
@@ -444,6 +479,7 @@ Agent.prototype._reconfigureAggregators = function _reconfigureAggregators(confi
|
|
|
444
479
|
this.spanEventAggregator.reconfigure(config)
|
|
445
480
|
this.transactionEventAggregator.reconfigure(config)
|
|
446
481
|
this.customEventAggregator.reconfigure(config)
|
|
482
|
+
this.logs.reconfigure(config)
|
|
447
483
|
}
|
|
448
484
|
|
|
449
485
|
Agent.prototype._scheduleHarvests = function _scheduleHarvests(shouldImmediatelyHarvest, callback) {
|
|
@@ -587,6 +623,7 @@ Agent.prototype.harvestSync = function harvestSync() {
|
|
|
587
623
|
this.spanEventAggregator.send()
|
|
588
624
|
this.transactionEventAggregator.send()
|
|
589
625
|
this.customEventAggregator.send()
|
|
626
|
+
this.logs.send()
|
|
590
627
|
|
|
591
628
|
// Write serverless output
|
|
592
629
|
collector.flushPayloadSync()
|
|
@@ -918,6 +955,31 @@ function generateEventHarvestSupportMetrics(agent, harvestConfig) {
|
|
|
918
955
|
const spanLimitMetric = agent.metrics.getOrCreateMetric(harvestLimitNames.SPAN)
|
|
919
956
|
spanLimitMetric.recordValue(spanLimit)
|
|
920
957
|
}
|
|
958
|
+
|
|
959
|
+
const logLimit = harvestLimits.log_event_data
|
|
960
|
+
if (logLimit) {
|
|
961
|
+
const logLimitMetric = agent.metrics.getOrCreateMetric(harvestLimitNames.LOG)
|
|
962
|
+
logLimitMetric.recordValue(logLimit)
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Increments the call counts of application logging supportability metrics
|
|
968
|
+
* on every connect cycle
|
|
969
|
+
*
|
|
970
|
+
* @param {Agent} agent
|
|
971
|
+
*/
|
|
972
|
+
function generateLoggingSupportMetrics(agent) {
|
|
973
|
+
const loggingConfig = agent.config.application_logging
|
|
974
|
+
const logNames = NAMES.LOGGING
|
|
975
|
+
|
|
976
|
+
const configKeys = ['metrics', 'forwarding', 'local_decorating']
|
|
977
|
+
configKeys.forEach((configValue) => {
|
|
978
|
+
const configFlag =
|
|
979
|
+
loggingConfig.enabled && loggingConfig[`${configValue}`].enabled ? 'enabled' : 'disabled'
|
|
980
|
+
const metricName = logNames[`${configValue.toUpperCase()}`]
|
|
981
|
+
agent.metrics.getOrCreateMetric(`${metricName}${configFlag}`).incrementCallCount()
|
|
982
|
+
})
|
|
921
983
|
}
|
|
922
984
|
|
|
923
985
|
module.exports = Agent
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 New Relic Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict'
|
|
7
|
+
|
|
8
|
+
const logger = require('../logger').child({ component: 'logs_aggregator' })
|
|
9
|
+
const EventAggregator = require('./event-aggregator')
|
|
10
|
+
|
|
11
|
+
const NAMES = require('../metrics/names')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Aggregates log events up to a certain limit.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
* @class
|
|
18
|
+
*/
|
|
19
|
+
class LogAggregator extends EventAggregator {
|
|
20
|
+
constructor(opts, collector, metrics, agent) {
|
|
21
|
+
opts = opts || {}
|
|
22
|
+
opts.method = opts.method || 'log_event_data'
|
|
23
|
+
opts.metricNames = NAMES.LOGGING
|
|
24
|
+
|
|
25
|
+
super(opts, collector, metrics)
|
|
26
|
+
this.agent = agent
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_toPayloadSync() {
|
|
30
|
+
const events = this.events
|
|
31
|
+
|
|
32
|
+
if (events.length === 0) {
|
|
33
|
+
logger.debug('No log events to send.')
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const eventData = events.toArray()
|
|
38
|
+
return [{ logs: eventData }]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
add(logLine) {
|
|
42
|
+
const transaction = this.agent.getTransaction()
|
|
43
|
+
if (transaction) {
|
|
44
|
+
transaction.logs.add(logLine)
|
|
45
|
+
} else {
|
|
46
|
+
super.add(logLine)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
addBatch(logs, priority) {
|
|
51
|
+
logs.forEach((logLine) => {
|
|
52
|
+
super.add(logLine, priority)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = LogAggregator
|
package/lib/collector/api.js
CHANGED
|
@@ -35,6 +35,10 @@ const FAILURE_DISCARD_DATA = new Set([400, 403, 404, 405, 407, 411, 413, 414, 41
|
|
|
35
35
|
|
|
36
36
|
const AGENT_RUN_BEHAVIOR = CollectorResponse.AGENT_RUN_BEHAVIOR
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @param errors
|
|
40
|
+
* @param name
|
|
41
|
+
*/
|
|
38
42
|
function dumpErrors(errors, name) {
|
|
39
43
|
let index = 1
|
|
40
44
|
|
|
@@ -49,6 +53,9 @@ function dumpErrors(errors, name) {
|
|
|
49
53
|
})
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @param agent
|
|
58
|
+
*/
|
|
52
59
|
function CollectorAPI(agent) {
|
|
53
60
|
this._agent = agent
|
|
54
61
|
this._reqHeadersMap = null
|
|
@@ -73,13 +80,16 @@ function CollectorAPI(agent) {
|
|
|
73
80
|
customEvents: new RemoteMethod('custom_event_data', agent.config, initialEndpoint),
|
|
74
81
|
queryData: new RemoteMethod('sql_trace_data', agent.config, initialEndpoint),
|
|
75
82
|
errorEvents: new RemoteMethod('error_event_data', agent.config, initialEndpoint),
|
|
76
|
-
spanEvents: new RemoteMethod('span_event_data', agent.config, initialEndpoint)
|
|
83
|
+
spanEvents: new RemoteMethod('span_event_data', agent.config, initialEndpoint),
|
|
84
|
+
logEvents: new RemoteMethod('log_event_data', agent.config, initialEndpoint)
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
/**
|
|
81
89
|
* Updates all methods except preconnect w/ new host/port pairs sent down from server
|
|
82
90
|
* during preconnect (via redirect_host). Preconnect does not update.
|
|
91
|
+
*
|
|
92
|
+
* @param endpoint
|
|
83
93
|
*/
|
|
84
94
|
CollectorAPI.prototype._updateEndpoints = function _updateEndpoints(endpoint) {
|
|
85
95
|
logger.trace('Updating endpoints to: ', endpoint)
|
|
@@ -121,7 +131,7 @@ CollectorAPI.prototype.connect = function connect(callback) {
|
|
|
121
131
|
* fix the misconfiguration by setting `proxy` to a fully qualified URL
|
|
122
132
|
*
|
|
123
133
|
* @param {Error} error
|
|
124
|
-
* @returns {
|
|
134
|
+
* @returns {boolean}
|
|
125
135
|
*/
|
|
126
136
|
function isProxyMisconfigured(error) {
|
|
127
137
|
const config = api._agent.config
|
|
@@ -134,6 +144,10 @@ CollectorAPI.prototype.connect = function connect(callback) {
|
|
|
134
144
|
)
|
|
135
145
|
}
|
|
136
146
|
|
|
147
|
+
/**
|
|
148
|
+
* @param error
|
|
149
|
+
* @param response
|
|
150
|
+
*/
|
|
137
151
|
function retry(error, response) {
|
|
138
152
|
metric.incrementCallCount()
|
|
139
153
|
|
|
@@ -205,6 +219,10 @@ CollectorAPI.prototype._login = function _login(callback) {
|
|
|
205
219
|
|
|
206
220
|
methods.preconnect.invoke(payload, onPreConnect)
|
|
207
221
|
|
|
222
|
+
/**
|
|
223
|
+
* @param error
|
|
224
|
+
* @param response
|
|
225
|
+
*/
|
|
208
226
|
function onPreConnect(error, response) {
|
|
209
227
|
if (error || !SUCCESS.has(response.status)) {
|
|
210
228
|
return callback(error, response)
|
|
@@ -276,6 +294,10 @@ CollectorAPI.prototype._connect = function _connect(env, callback) {
|
|
|
276
294
|
|
|
277
295
|
methods.connect.invoke(env, onConnect)
|
|
278
296
|
|
|
297
|
+
/**
|
|
298
|
+
* @param error
|
|
299
|
+
* @param res
|
|
300
|
+
*/
|
|
279
301
|
function onConnect(error, res) {
|
|
280
302
|
if (error || !SUCCESS.has(res.status)) {
|
|
281
303
|
return callback(error, res)
|
|
@@ -371,6 +393,10 @@ CollectorAPI.prototype.error_event_data = function errorEvents(events, callback)
|
|
|
371
393
|
}
|
|
372
394
|
|
|
373
395
|
CollectorAPI.prototype.analytic_event_data = transactionEvents
|
|
396
|
+
/**
|
|
397
|
+
* @param events
|
|
398
|
+
* @param callback
|
|
399
|
+
*/
|
|
374
400
|
function transactionEvents(events, callback) {
|
|
375
401
|
if (!callback) {
|
|
376
402
|
throw new TypeError('callback is required')
|
|
@@ -467,6 +493,10 @@ CollectorAPI.prototype.span_event_data = function spanEvents(events, callback) {
|
|
|
467
493
|
* @param {Function} callback The continuation / error handler.
|
|
468
494
|
*/
|
|
469
495
|
CollectorAPI.prototype.transaction_sample_data = transactionSampleData
|
|
496
|
+
/**
|
|
497
|
+
* @param traces
|
|
498
|
+
* @param callback
|
|
499
|
+
*/
|
|
470
500
|
function transactionSampleData(traces, callback) {
|
|
471
501
|
if (!callback) {
|
|
472
502
|
throw new TypeError('callback is required')
|
|
@@ -478,11 +508,36 @@ function transactionSampleData(traces, callback) {
|
|
|
478
508
|
this._sendData(this._methods.traces, traces, callback)
|
|
479
509
|
}
|
|
480
510
|
|
|
511
|
+
/**
|
|
512
|
+
* Send already-formatted log data by calling log_event_data. For
|
|
513
|
+
* performance reasons, the API methods do no validation, but the
|
|
514
|
+
* collector expects data in an exact format. It expects a JSON array
|
|
515
|
+
* containing the following 2 elements:
|
|
516
|
+
*
|
|
517
|
+
* 1. An array of logs.
|
|
518
|
+
* 2. A list of common attributes(optional).
|
|
519
|
+
*
|
|
520
|
+
* @param {Array} logsRecords The encoded log entries.
|
|
521
|
+
* @param logRecords
|
|
522
|
+
* @param {Function} callback The continuation / error handler.
|
|
523
|
+
*/
|
|
524
|
+
CollectorAPI.prototype.log_event_data = function errorData(logRecords, callback) {
|
|
525
|
+
if (!callback) {
|
|
526
|
+
throw new TypeError('callback is required')
|
|
527
|
+
}
|
|
528
|
+
if (!logRecords) {
|
|
529
|
+
return callback(new TypeError('must pass logRecords to send'))
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
this._sendData(this._methods.logEvents, logRecords, callback)
|
|
533
|
+
}
|
|
534
|
+
|
|
481
535
|
/**
|
|
482
536
|
* Sends no data aside from the message itself. Clears the run ID, which
|
|
483
537
|
* effectively disconnects the agent from the collector.
|
|
484
538
|
*
|
|
485
539
|
* @param Function callback Runs after the run ID has been cleared.
|
|
540
|
+
* @param callback
|
|
486
541
|
*/
|
|
487
542
|
CollectorAPI.prototype.shutdown = function shutdown(callback) {
|
|
488
543
|
if (!callback) {
|
|
@@ -494,6 +549,10 @@ CollectorAPI.prototype.shutdown = function shutdown(callback) {
|
|
|
494
549
|
const agent = this._agent
|
|
495
550
|
this._methods.shutdown.invoke(null, this._reqHeadersMap, onShutdown)
|
|
496
551
|
|
|
552
|
+
/**
|
|
553
|
+
* @param error
|
|
554
|
+
* @param response
|
|
555
|
+
*/
|
|
497
556
|
function onShutdown(error, response) {
|
|
498
557
|
if (error) {
|
|
499
558
|
dumpErrors([error], 'shutdown')
|
|
@@ -613,6 +672,11 @@ CollectorAPI.prototype.isConnected = function isConnected() {
|
|
|
613
672
|
* @param {Function} cb - CollectorAPI method invocation callback
|
|
614
673
|
*/
|
|
615
674
|
CollectorAPI.prototype._handleResponseCode = _handleResponseCode
|
|
675
|
+
/**
|
|
676
|
+
* @param response
|
|
677
|
+
* @param endpoint
|
|
678
|
+
* @param cb
|
|
679
|
+
*/
|
|
616
680
|
function _handleResponseCode(response, endpoint, cb) {
|
|
617
681
|
const code = response.status
|
|
618
682
|
|
|
@@ -648,6 +712,11 @@ function _handleResponseCode(response, endpoint, cb) {
|
|
|
648
712
|
return setImmediate(cb, null, CollectorResponse.discard(null))
|
|
649
713
|
}
|
|
650
714
|
|
|
715
|
+
/**
|
|
716
|
+
* @param endpoint
|
|
717
|
+
* @param code
|
|
718
|
+
* @param action
|
|
719
|
+
*/
|
|
651
720
|
function logFailure(endpoint, code, action) {
|
|
652
721
|
logger.error('Agent endpoint %s returned %s status. %s.', endpoint, code, action)
|
|
653
722
|
}
|