newrelic 8.9.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 CHANGED
@@ -1,3 +1,65 @@
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
+
51
+ * Updated @newrelic/test-utilities to latest.
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
+
1
63
  ### v8.9.0 (2022-03-15)
2
64
 
3
65
  * Added support for `initializeUnorderedBulkOp`, and `initializeOrderedBulkOp` in mongodb v3 instrumentation.
package/README.md CHANGED
@@ -145,6 +145,8 @@ Here are some resources for learning more about the agent:
145
145
 
146
146
  - [The changelog](https://github.com/newrelic/node-newrelic/blob/main/NEWS.md)
147
147
 
148
+ - [Example applications](https://github.com/newrelic/newrelic-node-examples) - Working examples of New Relic features in Node.js.
149
+
148
150
  ## Support
149
151
 
150
152
  Should you need assistance with New Relic products, you are in good hands with several support channels.
@@ -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)
@@ -712,7 +713,7 @@ This product includes source derived from [@newrelic/aws-sdk](https://github.com
712
713
 
713
714
  ### @newrelic/koa
714
715
 
715
- This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v6.1.0](https://github.com/newrelic/node-newrelic-koa/tree/v6.1.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v6.1.0/LICENSE):
716
+ This product includes source derived from [@newrelic/koa](https://github.com/newrelic/node-newrelic-koa) ([v6.1.1](https://github.com/newrelic/node-newrelic-koa/tree/v6.1.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic-koa/blob/v6.1.1/LICENSE):
716
717
 
717
718
  ```
718
719
  Apache License
@@ -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):
@@ -1770,7 +1980,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
1770
1980
 
1771
1981
  ### @newrelic/test-utilities
1772
1982
 
1773
- This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v6.3.0](https://github.com/newrelic/node-test-utilities/tree/v6.3.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v6.3.0/LICENSE):
1983
+ This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v6.5.2](https://github.com/newrelic/node-test-utilities/tree/v6.5.2)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v6.5.2/LICENSE):
1774
1984
 
1775
1985
  ```
1776
1986
  Apache License
@@ -2456,7 +2666,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
2456
2666
 
2457
2667
  ### glob
2458
2668
 
2459
- This product includes source derived from [glob](https://github.com/isaacs/node-glob) ([v7.1.7](https://github.com/isaacs/node-glob/tree/v7.1.7)), distributed under the [ISC License](https://github.com/isaacs/node-glob/blob/v7.1.7/LICENSE):
2669
+ This product includes source derived from [glob](https://github.com/isaacs/node-glob) ([v7.2.0](https://github.com/isaacs/node-glob/tree/v7.2.0)), distributed under the [ISC License](https://github.com/isaacs/node-glob/blob/v7.2.0/LICENSE):
2460
2670
 
2461
2671
  ```
2462
2672
  The ISC 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) ([v15.1.6](https://github.com/tapjs/node-tap/tree/v15.1.6)), distributed under the [ISC License](https://github.com/tapjs/node-tap/blob/v15.1.6/LICENSE):
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
@@ -3377,7 +3587,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3377
3587
 
3378
3588
  ### @newrelic/native-metrics
3379
3589
 
3380
- This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v7.1.1](https://github.com/newrelic/node-native-metrics/tree/v7.1.1)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v7.1.1/LICENSE):
3590
+ This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v8.0.0](https://github.com/newrelic/node-native-metrics/tree/v8.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v8.0.0/LICENSE):
3381
3591
 
3382
3592
  ```
3383
3593
  Apache License
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