newrelic 14.1.2 → 14.2.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.
@@ -149,10 +149,10 @@ defaultConfig.definition = () => {
149
149
  * agent management in container based environments.
150
150
  */
151
151
  agent_control: {
152
- /**
153
- * Indicates that the agent is being managed by Agent Control. Must be set
154
- * to true health monitoring.
155
- */
152
+ /**
153
+ * Indicates that the agent is being managed by Agent Control. Must be set
154
+ * to true health monitoring.
155
+ */
156
156
  enabled: {
157
157
  formatter: boolean,
158
158
  default: false
@@ -162,11 +162,11 @@ defaultConfig.definition = () => {
162
162
  * Settings specific to the health monitoring aspect of Agent Control.
163
163
  */
164
164
  health: {
165
- /**
166
- * A string file path to a directory that the agent is expected to write
167
- * health status files to. Must be set for health monitoring to be
168
- * enabled.
169
- */
165
+ /**
166
+ * A string file path to a directory that the agent is expected to write
167
+ * health status files to. Must be set for health monitoring to be
168
+ * enabled.
169
+ */
170
170
  delivery_location: {
171
171
  default: 'file:///newrelic/apm/health'
172
172
  },
@@ -220,10 +220,10 @@ defaultConfig.definition = () => {
220
220
  * the properties of an event or transaction.
221
221
  */
222
222
  attributes: {
223
- /**
224
- * If `true`, enables capture of attributes for all destinations.
225
- * If there are specific parameters you want ignored, use `attributes.exclude`.
226
- */
223
+ /**
224
+ * If `true`, enables capture of attributes for all destinations.
225
+ * If there are specific parameters you want ignored, use `attributes.exclude`.
226
+ */
227
227
  enabled: {
228
228
  formatter: boolean,
229
229
  default: true
@@ -281,14 +281,14 @@ defaultConfig.definition = () => {
281
281
  }
282
282
  },
283
283
  logging: {
284
- /**
285
- * Verbosity of the module's logging. This module uses bunyan
286
- * (https://github.com/trentm/node-bunyan) for its logging, and as such the
287
- * valid logging levels are 'fatal', 'error', 'warn', 'info', 'debug' and
288
- * 'trace'. Logging at levels 'info' and higher is very terse. For support
289
- * requests, attaching logs captured at 'trace' level are extremely helpful
290
- * in chasing down bugs.
291
- */
284
+ /**
285
+ * Verbosity of the module's logging. This module uses bunyan
286
+ * (https://github.com/trentm/node-bunyan) for its logging, and as such the
287
+ * valid logging levels are 'fatal', 'error', 'warn', 'info', 'debug' and
288
+ * 'trace'. Logging at levels 'info' and higher is very terse. For support
289
+ * requests, attaching logs captured at 'trace' level are extremely helpful
290
+ * in chasing down bugs.
291
+ */
292
292
  level: {
293
293
  default: 'info',
294
294
  env: 'NEW_RELIC_LOG_LEVEL'
@@ -322,11 +322,11 @@ defaultConfig.definition = () => {
322
322
  }
323
323
  },
324
324
  audit_log: {
325
- /**
326
- * Enables logging of out bound traffic from the Agent to the Collector.
327
- * This field is ignored if trace level logging is enabled.
328
- * With trace logging, all traffic is logged.
329
- */
325
+ /**
326
+ * Enables logging of out bound traffic from the Agent to the Collector.
327
+ * This field is ignored if trace level logging is enabled.
328
+ * With trace logging, all traffic is logged.
329
+ */
330
330
  enabled: {
331
331
  formatter: boolean,
332
332
  default: false
@@ -349,9 +349,9 @@ defaultConfig.definition = () => {
349
349
  */
350
350
  error_collector: {
351
351
  attributes: {
352
- /**
353
- * If `true`, the agent captures attributes from error collection.
354
- */
352
+ /**
353
+ * If `true`, the agent captures attributes from error collection.
354
+ */
355
355
  enabled: {
356
356
  formatter: boolean,
357
357
  default: true
@@ -451,10 +451,10 @@ defaultConfig.definition = () => {
451
451
  *
452
452
  */
453
453
  strip_exception_messages: {
454
- /**
455
- * When `true`, the agent will redact the messages of captured
456
- * errors.
457
- */
454
+ /**
455
+ * When `true`, the agent will redact the messages of captured
456
+ * errors.
457
+ */
458
458
  enabled: {
459
459
  formatter: boolean,
460
460
  default: false
@@ -462,9 +462,9 @@ defaultConfig.definition = () => {
462
462
  },
463
463
  cloud: {
464
464
  aws: {
465
- /**
466
- * The AWS account ID for the AWS account associated with this app.
467
- */
465
+ /**
466
+ * The AWS account ID for the AWS account associated with this app.
467
+ */
468
468
  account_id: {
469
469
  formatter: int,
470
470
  default: null
@@ -476,10 +476,10 @@ defaultConfig.definition = () => {
476
476
  * utilization based pricing scheme.
477
477
  */
478
478
  utilization: {
479
- /**
480
- * This flag dictates whether the agent attempts to reach out to AWS
481
- * to get info about the vm the process is running on.
482
- */
479
+ /**
480
+ * This flag dictates whether the agent attempts to reach out to AWS
481
+ * to get info about the vm the process is running on.
482
+ */
483
483
  detect_aws: {
484
484
  formatter: boolean,
485
485
  default: true
@@ -555,13 +555,26 @@ defaultConfig.definition = () => {
555
555
  gcp_use_instance_as_host: {
556
556
  default: true,
557
557
  formatter: boolean
558
+ },
559
+
560
+ gcp_cloud_run: {
561
+ /**
562
+ * When enabled, and `gcp_use_instance_as_host` is also enabled, the
563
+ * GCP Cloud Run revision (`K_REVISION`) will be prepended to the
564
+ * instance id when setting the hostname of the running application,
565
+ * resulting in a hostname of `${K_REVISION}-${instance_id}`.
566
+ */
567
+ include_revision_in_host: {
568
+ default: false,
569
+ formatter: boolean
570
+ }
558
571
  }
559
572
  },
560
573
  transaction_tracer: {
561
574
  attributes: {
562
- /**
563
- * If `true`, the agent captures attributes from transaction traces.
564
- */
575
+ /**
576
+ * If `true`, the agent captures attributes from transaction traces.
577
+ */
565
578
  enabled: {
566
579
  formatter: boolean,
567
580
  default: true
@@ -668,14 +681,14 @@ defaultConfig.definition = () => {
668
681
  * Rules for naming or ignoring transactions.
669
682
  */
670
683
  rules: {
671
- /**
672
- * A list of rules of the format {pattern: 'pattern', name: 'name'} for
673
- * matching incoming request URLs and naming the associated New Relic
674
- * transactions. Both pattern and name are required. Additional attributes
675
- * are ignored. Patterns may have capture groups (following JavaScript
676
- * conventions), and names will use $1-style replacement strings. See
677
- * the documentation for addNamingRule for important caveats.
678
- */
684
+ /**
685
+ * A list of rules of the format {pattern: 'pattern', name: 'name'} for
686
+ * matching incoming request URLs and naming the associated New Relic
687
+ * transactions. Both pattern and name are required. Additional attributes
688
+ * are ignored. Patterns may have capture groups (following JavaScript
689
+ * conventions), and names will use $1-style replacement strings. See
690
+ * the documentation for addNamingRule for important caveats.
691
+ */
679
692
  name: {
680
693
  formatter: objectList,
681
694
  default: [],
@@ -718,9 +731,9 @@ defaultConfig.definition = () => {
718
731
  */
719
732
  browser_monitoring: {
720
733
  attributes: {
721
- /**
722
- * If `true`, the agent captures attributes from browser monitoring.
723
- */
734
+ /**
735
+ * If `true`, the agent captures attributes from browser monitoring.
736
+ */
724
737
  enabled: {
725
738
  formatter: boolean,
726
739
  default: false
@@ -791,9 +804,9 @@ defaultConfig.definition = () => {
791
804
  * options are disabled when high-security mode is enabled.
792
805
  */
793
806
  api: {
794
- /**
795
- * Controls for the `API.addCustomAttribute` method.
796
- */
807
+ /**
808
+ * Controls for the `API.addCustomAttribute` method.
809
+ */
797
810
  custom_attributes_enabled: {
798
811
  formatter: boolean,
799
812
  default: true,
@@ -826,9 +839,9 @@ defaultConfig.definition = () => {
826
839
  */
827
840
  transaction_events: {
828
841
  attributes: {
829
- /**
830
- * If `true`, the agent captures attributes from transaction events.
831
- */
842
+ /**
843
+ * If `true`, the agent captures attributes from transaction events.
844
+ */
832
845
  enabled: {
833
846
  formatter: boolean,
834
847
  default: true
@@ -882,10 +895,10 @@ defaultConfig.definition = () => {
882
895
  * Read more here: http://newrelic.com/insights
883
896
  */
884
897
  custom_insights_events: {
885
- /**
886
- * If this is disabled, the agent does not collect, nor try to send, custom
887
- * event data.
888
- */
898
+ /**
899
+ * If this is disabled, the agent does not collect, nor try to send, custom
900
+ * event data.
901
+ */
889
902
  enabled: {
890
903
  formatter: boolean,
891
904
  default: true
@@ -910,9 +923,9 @@ defaultConfig.definition = () => {
910
923
  * This is used to configure properties about the user's host name.
911
924
  */
912
925
  process_host: {
913
- /**
914
- * Configurable display name for hosts
915
- */
926
+ /**
927
+ * Configurable display name for hosts
928
+ */
916
929
  display_name: '',
917
930
  /**
918
931
  * ip address preference when creating hostnames
@@ -958,9 +971,9 @@ defaultConfig.definition = () => {
958
971
  * nodes in transaction traces.
959
972
  */
960
973
  slow_sql: {
961
- /**
962
- * Enables and disables `slow_sql` recording.
963
- */
974
+ /**
975
+ * Enables and disables `slow_sql` recording.
976
+ */
964
977
  enabled: {
965
978
  formatter: boolean,
966
979
  default: false
@@ -1009,9 +1022,9 @@ defaultConfig.definition = () => {
1009
1022
  * Controls behavior of gRPC server instrumentation.
1010
1023
  */
1011
1024
  grpc: {
1012
- /**
1013
- * Enables recording of non-zero gRPC status codes. Default is `true`.
1014
- */
1025
+ /**
1026
+ * Enables recording of non-zero gRPC status codes. Default is `true`.
1027
+ */
1015
1028
  record_errors: {
1016
1029
  formatter: boolean,
1017
1030
  default: true
@@ -1036,18 +1049,18 @@ defaultConfig.definition = () => {
1036
1049
  * Controls the behavior of span events produced by the agent.
1037
1050
  */
1038
1051
  span_events: {
1039
- /**
1040
- * Enables/disables span event generation
1041
- */
1052
+ /**
1053
+ * Enables/disables span event generation
1054
+ */
1042
1055
  enabled: {
1043
1056
  formatter: boolean,
1044
1057
  default: true
1045
1058
  },
1046
1059
 
1047
1060
  attributes: {
1048
- /**
1049
- * If `true`, the agent captures attributes from span events.
1050
- */
1061
+ /**
1062
+ * If `true`, the agent captures attributes from span events.
1063
+ */
1051
1064
  enabled: {
1052
1065
  formatter: boolean,
1053
1066
  default: true
@@ -1083,9 +1096,9 @@ defaultConfig.definition = () => {
1083
1096
  */
1084
1097
  transaction_segments: {
1085
1098
  attributes: {
1086
- /**
1087
- * If `true`, the agent captures attributes from transaction segments.
1088
- */
1099
+ /**
1100
+ * If `true`, the agent captures attributes from transaction segments.
1101
+ */
1089
1102
  enabled: {
1090
1103
  formatter: boolean,
1091
1104
  default: true
@@ -1118,9 +1131,9 @@ defaultConfig.definition = () => {
1118
1131
  * Default is true.
1119
1132
  */
1120
1133
  distributed_tracing: {
1121
- /**
1122
- * Enables/disables distributed tracing.
1123
- */
1134
+ /**
1135
+ * Enables/disables distributed tracing.
1136
+ */
1124
1137
  enabled: {
1125
1138
  formatter: boolean,
1126
1139
  default: true
@@ -1189,9 +1202,9 @@ defaultConfig.definition = () => {
1189
1202
  */
1190
1203
  infinite_tracing: {
1191
1204
  trace_observer: {
1192
- /**
1193
- * The URI HOST of the observer. Setting this enables infinite tracing.
1194
- */
1205
+ /**
1206
+ * The URI HOST of the observer. Setting this enables infinite tracing.
1207
+ */
1195
1208
  host: '',
1196
1209
  /**
1197
1210
  * The URI PORT of the observer.
@@ -1209,9 +1222,9 @@ defaultConfig.definition = () => {
1209
1222
  },
1210
1223
  },
1211
1224
  span_events: {
1212
- /**
1213
- * The amount of spans to hold onto before dropping them
1214
- */
1225
+ /**
1226
+ * The amount of spans to hold onto before dropping them
1227
+ */
1215
1228
  queue_size: {
1216
1229
  formatter: int,
1217
1230
  default: 10000
@@ -1261,6 +1274,16 @@ defaultConfig.definition = () => {
1261
1274
  duration: {
1262
1275
  formatter: int,
1263
1276
  default: 0
1277
+ },
1278
+ source_mapping: {
1279
+ /**
1280
+ * When set to `true`, resolves profiler frames to their original
1281
+ * source files/lines using source maps, instead of the compiled output.
1282
+ */
1283
+ enabled: {
1284
+ formatter: boolean,
1285
+ default: false
1286
+ },
1264
1287
  }
1265
1288
  },
1266
1289
 
@@ -1284,10 +1307,10 @@ defaultConfig.definition = () => {
1284
1307
  }
1285
1308
  },
1286
1309
  plugins: {
1287
- /**
1288
- * Controls usage of the native metrics module which samples VM and event
1289
- * loop data.
1290
- */
1310
+ /**
1311
+ * Controls usage of the native metrics module which samples VM and event
1312
+ * loop data.
1313
+ */
1291
1314
  native_metrics: {
1292
1315
  enabled: {
1293
1316
  formatter: boolean,
@@ -1301,17 +1324,17 @@ defaultConfig.definition = () => {
1301
1324
  * Controls the behavior of Logs in Context within agent
1302
1325
  */
1303
1326
  application_logging: {
1304
- /**
1305
- * Toggles the ability for all application logging features to be enabled.
1306
- */
1327
+ /**
1328
+ * Toggles the ability for all application logging features to be enabled.
1329
+ */
1307
1330
  enabled: {
1308
1331
  formatter: boolean,
1309
1332
  default: true
1310
1333
  },
1311
1334
  forwarding: {
1312
- /**
1313
- * Toggles whether the agent gathers log records for sending to New Relic.
1314
- */
1335
+ /**
1336
+ * Toggles whether the agent gathers log records for sending to New Relic.
1337
+ */
1315
1338
  enabled: {
1316
1339
  formatter: boolean,
1317
1340
  default: true
@@ -1324,9 +1347,9 @@ defaultConfig.definition = () => {
1324
1347
  default: 10000
1325
1348
  },
1326
1349
  labels: {
1327
- /**
1328
- * If `true`, the agent attaches labels to log records.
1329
- */
1350
+ /**
1351
+ * If `true`, the agent attaches labels to log records.
1352
+ */
1330
1353
  enabled: {
1331
1354
  formatter: boolean,
1332
1355
  default: false
@@ -1341,18 +1364,18 @@ defaultConfig.definition = () => {
1341
1364
  }
1342
1365
  },
1343
1366
  metrics: {
1344
- /**
1345
- * Toggles whether the agent gathers logging metrics.
1346
- */
1367
+ /**
1368
+ * Toggles whether the agent gathers logging metrics.
1369
+ */
1347
1370
  enabled: {
1348
1371
  formatter: boolean,
1349
1372
  default: true
1350
1373
  }
1351
1374
  },
1352
1375
  local_decorating: {
1353
- /**
1354
- * Toggles whether the agent performs log decoration on standard log output.
1355
- */
1376
+ /**
1377
+ * Toggles whether the agent performs log decoration on standard log output.
1378
+ */
1356
1379
  enabled: {
1357
1380
  formatter: boolean,
1358
1381
  default: false
@@ -1389,18 +1412,18 @@ defaultConfig.definition = () => {
1389
1412
  * for transaction trace transaction details
1390
1413
  */
1391
1414
  url_obfuscation: {
1392
- /**
1393
- * Toggles whether to obfuscate URL parameters
1394
- */
1415
+ /**
1416
+ * Toggles whether to obfuscate URL parameters
1417
+ */
1395
1418
  enabled: {
1396
1419
  formatter: boolean,
1397
1420
  default: false
1398
1421
  },
1399
1422
 
1400
1423
  regex: {
1401
- /**
1402
- * A regular expression to match URL parameters to obfuscate
1403
- */
1424
+ /**
1425
+ * A regular expression to match URL parameters to obfuscate
1426
+ */
1404
1427
  pattern: {
1405
1428
  formatter: regex,
1406
1429
  default: null
@@ -1426,9 +1449,9 @@ defaultConfig.definition = () => {
1426
1449
  * Security agent configurations
1427
1450
  */
1428
1451
  security: {
1429
- /**
1430
- * Toggles the generation of security events by the security agent.
1431
- */
1452
+ /**
1453
+ * Toggles the generation of security events by the security agent.
1454
+ */
1432
1455
  enabled: {
1433
1456
  formatter: boolean,
1434
1457
  default: false
@@ -1493,10 +1516,10 @@ defaultConfig.definition = () => {
1493
1516
  * IAST scan controllers to get more control over IAST analysis
1494
1517
  */
1495
1518
  scan_controllers: {
1496
- /**
1497
- * The maximum number of analysis probes or requests
1498
- * that can be sent to the application in one minute.
1499
- */
1519
+ /**
1520
+ * The maximum number of analysis probes or requests
1521
+ * that can be sent to the application in one minute.
1522
+ */
1500
1523
  iast_scan_request_rate_limit: {
1501
1524
  formatter: int,
1502
1525
  default: 3600
@@ -1514,10 +1537,10 @@ defaultConfig.definition = () => {
1514
1537
  * Schedule start and stop of IAST scan
1515
1538
  */
1516
1539
  scan_schedule: {
1517
- /**
1518
- * The delay field specifies the time in minutes
1519
- * before an IAST scan begins after the application starts
1520
- */
1540
+ /**
1541
+ * The delay field specifies the time in minutes
1542
+ * before an IAST scan begins after the application starts
1543
+ */
1521
1544
  delay: {
1522
1545
  formatter: int,
1523
1546
  default: 0
@@ -1552,10 +1575,10 @@ defaultConfig.definition = () => {
1552
1575
  * vulnerability categories, and parameters from IAST analysis.
1553
1576
  */
1554
1577
  exclude_from_iast_scan: {
1555
- /**
1556
- * Ignore specific APIs from IAST analysis.
1557
- * The regex pattern should provide a full match for the URL without the endpoint.
1558
- */
1578
+ /**
1579
+ * Ignore specific APIs from IAST analysis.
1580
+ * The regex pattern should provide a full match for the URL without the endpoint.
1581
+ */
1559
1582
  api: {
1560
1583
  formatter: array,
1561
1584
  default: []
@@ -1658,9 +1681,9 @@ defaultConfig.definition = () => {
1658
1681
  * effect.
1659
1682
  */
1660
1683
  ai_monitoring: {
1661
- /**
1662
- * Toggles the generation of AI monitoring events by the agent.
1663
- */
1684
+ /**
1685
+ * Toggles the generation of AI monitoring events by the agent.
1686
+ */
1664
1687
  enabled: {
1665
1688
  formatter: boolean,
1666
1689
  default: false
@@ -1704,11 +1727,11 @@ defaultConfig.definition = () => {
1704
1727
  * feature set is in development.
1705
1728
  */
1706
1729
  opentelemetry: {
1707
- /**
1708
- * Global switch for the whole OpenTelemetry feature. If it is set to
1709
- * `false`, any other sub-feature, e.g. `traces`, will not be enabled
1710
- * regardless of that specific sub-feature setting.
1711
- */
1730
+ /**
1731
+ * Global switch for the whole OpenTelemetry feature. If it is set to
1732
+ * `false`, any other sub-feature, e.g. `traces`, will not be enabled
1733
+ * regardless of that specific sub-feature setting.
1734
+ */
1712
1735
  enabled: { default: false, formatter: boolean },
1713
1736
 
1714
1737
  /**
@@ -958,6 +958,27 @@ Config.prototype.getIPAddresses = function getIPAddresses() {
958
958
  return addresses
959
959
  }
960
960
 
961
+ /**
962
+ * Determines the GCP Cloud Run host name from the instance id. When
963
+ * `utilization.gcp_cloud_run.include_revision_in_host` is enabled and the
964
+ * `K_REVISION` env var is present, the revision is prepended to the instance
965
+ * id, resulting in a host name of `${K_REVISION}-${gcpId}`.
966
+ *
967
+ * @param {object} config agent config
968
+ * @param {string} gcpId GCP metadata ID
969
+ * @returns {string} host name
970
+ */
971
+ function getGcpHostname(config, gcpId) {
972
+ if (config.utilization.gcp_cloud_run?.include_revision_in_host && process.env.K_REVISION) {
973
+ const hostname = `${process.env.K_REVISION}-${gcpId}`
974
+ logger.info('Using GCP revision and instance ID for host name: %s', hostname)
975
+ return hostname
976
+ }
977
+
978
+ logger.info('Using GCP instance ID for host name: %s', gcpId)
979
+ return gcpId
980
+ }
981
+
961
982
  /**
962
983
  * Gets the system's host name. If that fails, it just returns ipv4/6
963
984
  * based on the user's process_host.ipv_preference setting.
@@ -991,8 +1012,7 @@ function getHostnameSafe(gcpId = null) {
991
1012
  _hostname = process.env.DYNO || os.hostname()
992
1013
  logger.info('Using Heroku dyno name for host name: %s', _hostname)
993
1014
  } else if (config.utilization.gcp_use_instance_as_host && process.env.K_SERVICE && gcpId) {
994
- _hostname = gcpId
995
- logger.info('Using GCP instance ID for host name: %s', _hostname)
1015
+ _hostname = getGcpHostname(config, gcpId)
996
1016
  } else {
997
1017
  _hostname = os.hostname()
998
1018
  logger.info('Using OS hostname for host name: %s', _hostname)
@@ -12,7 +12,6 @@ module.exports = function instrumentations() {
12
12
  return {
13
13
  '@prisma/client': { type: InstrumentationDescriptor.TYPE_DATASTORE },
14
14
  'aws-sdk': { module: './instrumentation/aws-sdk' },
15
- mongodb: { type: InstrumentationDescriptor.TYPE_DATASTORE },
16
15
  next: { module: './instrumentation/nextjs' },
17
16
  restify: { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK }
18
17
  }
@@ -12,6 +12,7 @@ class ProfilingManager {
12
12
  this.logger = logger
13
13
  this.metrics = agent.metrics
14
14
  this.config = agent.config.profiling
15
+ this.tracer = agent.tracer
15
16
  this.samplingInterval = samplingInterval
16
17
  this.profilers = new Map()
17
18
  this.startTime = null
@@ -25,7 +26,7 @@ class ProfilingManager {
25
26
 
26
27
  if (this.config.include.includes('cpu') && !this.profilers.has('CpuProfiler')) {
27
28
  const { CpuProfiler } = require('./profilers')
28
- this.profilers.set('CpuProfiler', new CpuProfiler({ logger: this.logger, samplingInterval: this.samplingInterval }))
29
+ this.profilers.set('CpuProfiler', new CpuProfiler({ logger: this.logger, samplingInterval: this.samplingInterval, tracer: this.tracer }))
29
30
  }
30
31
  }
31
32