newrelic 8.2.0 → 8.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/NEWS.md +5061 -4963
  2. package/README.md +7 -6
  3. package/THIRD_PARTY_NOTICES.md +95 -68
  4. package/api.js +74 -68
  5. package/bin/test-naming-rules.js +22 -22
  6. package/lib/agent.js +4 -4
  7. package/lib/attributes.js +2 -2
  8. package/lib/collector/api.js +12 -12
  9. package/lib/collector/facts.js +2 -3
  10. package/lib/collector/http-agents.js +12 -11
  11. package/lib/collector/key-parser.js +1 -1
  12. package/lib/collector/remote-method.js +27 -26
  13. package/lib/config/attribute-filter.js +23 -23
  14. package/lib/config/default.js +26 -9
  15. package/lib/config/env.js +14 -4
  16. package/lib/config/hsm.js +1 -1
  17. package/lib/config/index.js +90 -69
  18. package/lib/config/lasp.js +3 -3
  19. package/lib/config/merge-server-config.js +1 -1
  20. package/lib/db/parse-sql.js +8 -8
  21. package/lib/db/parsed-statement.js +9 -8
  22. package/lib/db/query-parsers/sql.js +7 -7
  23. package/lib/db/query-sample.js +9 -9
  24. package/lib/db/query-trace-aggregator.js +4 -4
  25. package/lib/db/statement-matcher.js +5 -5
  26. package/lib/db/utils.js +1 -1
  27. package/lib/environment.js +43 -43
  28. package/lib/errors/error-collector.js +2 -2
  29. package/lib/errors/error-trace-aggregator.js +1 -1
  30. package/lib/errors/helper.js +3 -3
  31. package/lib/errors/index.js +17 -17
  32. package/lib/feature_flags.js +7 -5
  33. package/lib/header-attributes.js +6 -6
  34. package/lib/header-processing.js +1 -1
  35. package/lib/instrumentation/amqplib.js +26 -26
  36. package/lib/instrumentation/bluebird.js +3 -3
  37. package/lib/instrumentation/cassandra-driver.js +7 -3
  38. package/lib/instrumentation/connect.js +4 -4
  39. package/lib/instrumentation/core/async_hooks.js +6 -6
  40. package/lib/instrumentation/core/domain.js +2 -2
  41. package/lib/instrumentation/core/globals.js +1 -1
  42. package/lib/instrumentation/core/http-outbound.js +15 -84
  43. package/lib/instrumentation/core/http.js +34 -67
  44. package/lib/instrumentation/core/inspector.js +2 -2
  45. package/lib/instrumentation/core/timers.js +7 -7
  46. package/lib/instrumentation/core/zlib.js +2 -2
  47. package/lib/instrumentation/director.js +4 -4
  48. package/lib/instrumentation/express.js +8 -8
  49. package/lib/instrumentation/fastify/spec-builders.js +57 -47
  50. package/lib/instrumentation/fastify.js +111 -28
  51. package/lib/instrumentation/generic-pool.js +1 -1
  52. package/lib/instrumentation/hapi/hapi-17.js +11 -11
  53. package/lib/instrumentation/hapi/shared.js +1 -1
  54. package/lib/instrumentation/hapi.js +22 -22
  55. package/lib/instrumentation/ioredis.js +7 -7
  56. package/lib/instrumentation/memcached.js +7 -7
  57. package/lib/instrumentation/mongodb/common.js +73 -23
  58. package/lib/instrumentation/mongodb/v3-mongo.js +20 -1
  59. package/lib/instrumentation/mongodb/v4-mongo.js +6 -7
  60. package/lib/instrumentation/mysql.js +19 -19
  61. package/lib/instrumentation/oracle.js +15 -15
  62. package/lib/instrumentation/pg.js +4 -4
  63. package/lib/instrumentation/promise.js +46 -46
  64. package/lib/instrumentation/q.js +2 -2
  65. package/lib/instrumentation/redis.js +11 -11
  66. package/lib/instrumentation/restify.js +1 -1
  67. package/lib/instrumentation/undici.js +242 -0
  68. package/lib/instrumentation/vision.js +4 -4
  69. package/lib/instrumentation/when.js +3 -3
  70. package/lib/instrumentations.js +2 -1
  71. package/lib/logger.js +5 -5
  72. package/lib/metrics/index.js +15 -15
  73. package/lib/metrics/mapper.js +7 -7
  74. package/lib/metrics/names.js +6 -3
  75. package/lib/metrics/normalizer/rule.js +9 -9
  76. package/lib/metrics/normalizer/tx_segment.js +17 -17
  77. package/lib/metrics/normalizer.js +22 -22
  78. package/lib/metrics/recorders/custom.js +5 -5
  79. package/lib/metrics/recorders/generic.js +3 -3
  80. package/lib/metrics/recorders/http.js +7 -7
  81. package/lib/metrics/recorders/http_external.js +7 -7
  82. package/lib/metrics/recorders/message-transaction.js +5 -6
  83. package/lib/metrics/recorders/other.js +5 -5
  84. package/lib/parse-proc-cpuinfo.js +25 -19
  85. package/lib/parse-proc-meminfo.js +8 -2
  86. package/lib/prioritized-attributes.js +2 -2
  87. package/lib/priority-queue.js +10 -10
  88. package/lib/reservoir.js +3 -3
  89. package/lib/sampler.js +26 -26
  90. package/lib/shim/datastore-shim.js +35 -32
  91. package/lib/shim/index.js +2 -2
  92. package/lib/shim/message-shim.js +47 -47
  93. package/lib/shim/promise-shim.js +1 -1
  94. package/lib/shim/shim.js +61 -61
  95. package/lib/shim/specs/index.js +3 -3
  96. package/lib/shim/transaction-shim.js +44 -192
  97. package/lib/shim/webframework-shim.js +52 -52
  98. package/lib/spans/span-event-aggregator.js +62 -10
  99. package/lib/spans/span-event.js +1 -1
  100. package/lib/spans/streaming-span-attributes.js +1 -1
  101. package/lib/stats/apdex.js +2 -2
  102. package/lib/stats/index.js +2 -2
  103. package/lib/system-info.js +23 -23
  104. package/lib/timer.js +5 -5
  105. package/lib/transaction/dt-payload.js +1 -1
  106. package/lib/transaction/index.js +40 -40
  107. package/lib/transaction/name-state.js +14 -14
  108. package/lib/transaction/trace/exclusive-time-calculator.js +6 -6
  109. package/lib/transaction/trace/index.js +14 -14
  110. package/lib/transaction/trace/segment.js +18 -18
  111. package/lib/transaction/tracecontext.js +1 -1
  112. package/lib/transaction/tracer/index.js +53 -49
  113. package/lib/uninstrumented.js +7 -7
  114. package/lib/util/arity.js +2 -2
  115. package/lib/util/byte-limit.js +4 -4
  116. package/lib/util/cat.js +269 -24
  117. package/lib/util/codec.js +2 -2
  118. package/lib/util/copy.js +2 -2
  119. package/lib/util/deep-equal.js +10 -10
  120. package/lib/util/flatten.js +4 -4
  121. package/lib/util/hashes.js +14 -14
  122. package/lib/util/label-parser.js +17 -17
  123. package/lib/util/logger.js +24 -24
  124. package/lib/util/process-version.js +2 -2
  125. package/lib/util/properties.js +4 -4
  126. package/lib/util/sql/obfuscate.js +15 -15
  127. package/lib/util/stream-sink.js +3 -3
  128. package/lib/util/unwrapped-core.js +2 -2
  129. package/lib/util/urltils.js +16 -16
  130. package/lib/utilization/aws-info.js +7 -7
  131. package/lib/utilization/azure-info.js +6 -6
  132. package/lib/utilization/common.js +13 -13
  133. package/lib/utilization/docker-info.js +11 -11
  134. package/lib/utilization/gcp-info.js +4 -4
  135. package/lib/utilization/index.js +5 -5
  136. package/lib/utilization/pcf-info.js +9 -9
  137. package/package.json +13 -7
  138. package/stub_api.js +8 -8
@@ -28,7 +28,7 @@ class QueryTraceAggregator extends Aggregator {
28
28
 
29
29
  removeShortest() {
30
30
  let shortest = null
31
- for (let sample of this.samples.values()) {
31
+ for (const sample of this.samples.values()) {
32
32
  const trace = sample.trace
33
33
  if (!shortest || shortest.duration > trace.duration) {
34
34
  shortest = trace
@@ -39,8 +39,8 @@ class QueryTraceAggregator extends Aggregator {
39
39
  }
40
40
 
41
41
  _merge(samples) {
42
- for (let sample of samples.values()) {
43
- let ownSample = this.samples.get(sample.trace.normalized)
42
+ for (const sample of samples.values()) {
43
+ const ownSample = this.samples.get(sample.trace.normalized)
44
44
  if (ownSample) {
45
45
  ownSample.merge(sample)
46
46
  } else {
@@ -55,7 +55,7 @@ class QueryTraceAggregator extends Aggregator {
55
55
  // If DT is enabled and the segment is part of a sampled transaction
56
56
  // (i.e. we are creating a span event for this segment), then we need
57
57
  // to collect the sql trace.
58
- var slowQuery
58
+ let slowQuery
59
59
  switch (ttConfig.record_sql) {
60
60
  case 'raw':
61
61
  slowQuery = new SlowQuery(segment, type, query, trace)
@@ -6,7 +6,7 @@
6
6
  'use strict'
7
7
 
8
8
  // ( ` database` . ` table ` )
9
- var CLEANER = /^\(?(?:([`'"]?)(.*?)\1\.)?([`'"]?)(.*?)\3\)?$/
9
+ const CLEANER = /^\(?(?:([`'"]?)(.*?)\1\.)?([`'"]?)(.*?)\3\)?$/
10
10
 
11
11
  function StatementMatcher(operation, operationPattern) {
12
12
  this.operation = operation
@@ -20,16 +20,16 @@ StatementMatcher.prototype.getParsedStatement = function getParsedStatement(sql)
20
20
  CLEANER.lastIndex = 0
21
21
 
22
22
  if (this.matcher.test(sql)) {
23
- var queryMatch = this.operationPattern.exec(sql)
24
- var collection = queryMatch ? queryMatch[1] : 'unknown'
25
- var database = null
23
+ const queryMatch = this.operationPattern.exec(sql)
24
+ let collection = queryMatch ? queryMatch[1] : 'unknown'
25
+ let database = null
26
26
 
27
27
  // If the cleaner can match this collection, pull out the cleaned up names
28
28
  // from there. The spec doesn't want the database names in the collection
29
29
  // name, but for legacy reasons we keep it.
30
30
  // TODO: Either update the spec (and CATs) to accept database name in the
31
31
  // collection name or remove it here.
32
- var cleanerMatch = CLEANER.exec(collection)
32
+ const cleanerMatch = CLEANER.exec(collection)
33
33
  if (cleanerMatch && cleanerMatch[4]) {
34
34
  collection = cleanerMatch[4]
35
35
  if (cleanerMatch[2]) {
package/lib/db/utils.js CHANGED
@@ -10,6 +10,6 @@ module.exports.extractDatabaseChangeFromUse = extractDatabaseChangeFromUse
10
10
  function extractDatabaseChangeFromUse(sql) {
11
11
  // The character ranges for this were pulled from
12
12
  // http://dev.mysql.com/doc/refman/5.7/en/identifiers.html
13
- var match = /^\s*use[^\w`]+([\w$_\u0080-\uFFFF]+|`[^`]+`)[\s;]*$/i.exec(sql)
13
+ const match = /^\s*use[^\w`]+([\w$_\u0080-\uFFFF]+|`[^`]+`)[\s;]*$/i.exec(sql)
14
14
  return (match && match[1]) || null
15
15
  }
@@ -5,16 +5,16 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var a = require('async')
9
- var path = require('path')
10
- var fs = require('./util/unwrapped-core').fs
11
- var os = require('os')
12
- var logger = require('./logger').child({ component: 'environment' })
13
- var stringify = require('json-stringify-safe')
8
+ const a = require('async')
9
+ const path = require('path')
10
+ const fs = require('./util/unwrapped-core').fs
11
+ const os = require('os')
12
+ const logger = require('./logger').child({ component: 'environment' })
13
+ const stringify = require('json-stringify-safe')
14
14
 
15
15
  // As of 1.7.0 you can no longer dynamically link v8
16
16
  // https://github.com/nodejs/io.js/commit/d726a177ed
17
- var remapping = {
17
+ const remapping = {
18
18
  node_install_npm: 'npm installed?',
19
19
  node_install_waf: 'WAF build system installed?',
20
20
  node_use_openssl: 'OpenSSL support?',
@@ -25,7 +25,7 @@ var remapping = {
25
25
  node_use_etw: 'Event Tracing for Windows (ETW) support?'
26
26
  }
27
27
 
28
- var settings = Object.create(null)
28
+ let settings = Object.create(null)
29
29
 
30
30
  /**
31
31
  * Fetches the setting of the given name, defaulting to an empty array.
@@ -112,7 +112,7 @@ function listPackages(root, packages, callback) {
112
112
  }
113
113
 
114
114
  // Read the package and pull out the name and version of it.
115
- var pkg = path.resolve(root, dir, 'package.json')
115
+ const pkg = path.resolve(root, dir, 'package.json')
116
116
  fs.readFile(pkg, function onPackageRead(err, pkgFile) {
117
117
  _log('Read package at %s', pkg)
118
118
  if (err) {
@@ -120,10 +120,10 @@ function listPackages(root, packages, callback) {
120
120
  return cb()
121
121
  }
122
122
 
123
- var name = null
124
- var version = null
123
+ let name = null
124
+ let version = null
125
125
  try {
126
- var pkgData = JSON.parse(pkgFile)
126
+ const pkgData = JSON.parse(pkgFile)
127
127
  name = pkgData.name
128
128
  version = pkgData.version
129
129
  } catch (e) {
@@ -186,7 +186,7 @@ function listDependencies(root, children, visited, callback) {
186
186
  function forEachEntry(entry, cb) {
187
187
  _log('Checking dependencies in %s (%s)', entry, root)
188
188
 
189
- var candidate = path.resolve(root, entry, 'node_modules')
189
+ const candidate = path.resolve(root, entry, 'node_modules')
190
190
  fs.realpath(candidate, function realPathCb(err, realCandidate) {
191
191
  _log('Resolved %s to real path %s', candidate, realCandidate)
192
192
  if (err) {
@@ -230,10 +230,10 @@ function listDependencies(root, children, visited, callback) {
230
230
  * appropriate names.
231
231
  */
232
232
  function getLocalPackages(callback) {
233
- var packages = []
234
- var dependencies = []
235
- var candidate = process.cwd()
236
- var visited = Object.create(null)
233
+ const packages = []
234
+ const dependencies = []
235
+ let candidate = process.cwd()
236
+ const visited = Object.create(null)
237
237
  _log('Getting local packages')
238
238
 
239
239
  a.whilst(
@@ -242,7 +242,7 @@ function getLocalPackages(callback) {
242
242
  },
243
243
  function iterate(cb) {
244
244
  _log('Checking for local packages in %s', candidate)
245
- var root = path.resolve(candidate, 'node_modules')
245
+ const root = path.resolve(candidate, 'node_modules')
246
246
  a.series(
247
247
  [
248
248
  a.apply(listPackages, root, packages),
@@ -250,7 +250,7 @@ function getLocalPackages(callback) {
250
250
  ],
251
251
  function onListComplete(err) {
252
252
  _log('Done checking for local packages in %s', candidate)
253
- var last = candidate
253
+ const last = candidate
254
254
  candidate = path.dirname(candidate)
255
255
  if (last === candidate) {
256
256
  candidate = null
@@ -280,8 +280,8 @@ function getLocalPackages(callback) {
280
280
  * appropriate names.
281
281
  */
282
282
  function getPackages(root, cb) {
283
- var packages = []
284
- var dependencies = []
283
+ const packages = []
284
+ const dependencies = []
285
285
  _log('Getting packages from %s', root)
286
286
 
287
287
  a.series(
@@ -307,9 +307,9 @@ function getPackages(root, cb) {
307
307
  function getGlobalPackages(cb) {
308
308
  _log('Getting global packages')
309
309
  if (process.config && process.config.variables) {
310
- var prefix = process.config.variables.node_prefix
310
+ const prefix = process.config.variables.node_prefix
311
311
  if (prefix) {
312
- var root = path.resolve(prefix, 'lib', 'node_modules')
312
+ const root = path.resolve(prefix, 'lib', 'node_modules')
313
313
  _log('Getting global packages from %s', root)
314
314
  return getPackages(root, cb)
315
315
  }
@@ -328,10 +328,10 @@ function getGlobalPackages(cb) {
328
328
  * @return {Array.<string[]>} Sorted list of [name, version] pairs.
329
329
  */
330
330
  function flattenVersions(packages) {
331
- var info = Object.create(null)
331
+ const info = Object.create(null)
332
332
  packages.forEach((pair) => {
333
- var p = pair[0]
334
- var v = pair[1]
333
+ const p = pair[0]
334
+ const v = pair[1]
335
335
 
336
336
  if (info[p]) {
337
337
  if (info[p].indexOf(v) < 0) {
@@ -365,10 +365,10 @@ function flattenVersions(packages) {
365
365
  */
366
366
  function remapConfigSettings() {
367
367
  if (process.config && process.config.variables) {
368
- var variables = process.config.variables
368
+ const variables = process.config.variables
369
369
  Object.keys(variables).forEach((key) => {
370
370
  if (remapping[key]) {
371
- var value = variables[key]
371
+ let value = variables[key]
372
372
 
373
373
  if (value === true || value === 1) {
374
374
  value = 'yes'
@@ -385,13 +385,13 @@ function remapConfigSettings() {
385
385
 
386
386
  function getOtherPackages(callback) {
387
387
  _log('Getting other packages')
388
- var other = { packages: [], dependencies: [] }
388
+ const other = { packages: [], dependencies: [] }
389
389
 
390
390
  if (!process.env.NODE_PATH) {
391
391
  return callback(null, other)
392
392
  }
393
393
 
394
- var paths
394
+ let paths
395
395
  if (process.platform === 'win32') {
396
396
  // why. WHY.
397
397
  paths = process.env.NODE_PATH.split(';')
@@ -425,7 +425,7 @@ function getOtherPackages(callback) {
425
425
  }
426
426
 
427
427
  function getHomePackages(cb) {
428
- var homeDir = null
428
+ let homeDir = null
429
429
  if (process.platform === 'win32') {
430
430
  if (process.env.USERDIR) {
431
431
  homeDir = process.env.USERDIR
@@ -477,11 +477,11 @@ function findPackages(cb) {
477
477
  return cb(err)
478
478
  }
479
479
 
480
- var packages = data.local.packages
480
+ const packages = data.local.packages
481
481
  packages.push.apply(packages, data.global.packages)
482
482
  packages.push.apply(packages, data.other.packages)
483
483
 
484
- var dependencies = data.local.dependencies
484
+ const dependencies = data.local.dependencies
485
485
  dependencies.push.apply(dependencies, data.global.dependencies)
486
486
  dependencies.push.apply(dependencies, data.other.dependencies)
487
487
 
@@ -504,12 +504,12 @@ function findPackages(cb) {
504
504
  }
505
505
 
506
506
  function time(fn) {
507
- var name = fn.name
507
+ const name = fn.name
508
508
  return function timeWrapper(cb) {
509
- var start = Date.now()
509
+ const start = Date.now()
510
510
  logger.trace('Starting %s', name)
511
511
  return fn(function wrappedCb() {
512
- var end = Date.now()
512
+ const end = Date.now()
513
513
  logger.trace('Finished %s in %dms', name, end - start)
514
514
  cb.apply(this, arguments)
515
515
  })
@@ -533,9 +533,9 @@ function gatherEnv() {
533
533
 
534
534
  function refreshSyncOnly() {
535
535
  // gather persisted settings
536
- var framework = getSetting('Framework')
537
- var dispatcher = getSetting('Dispatcher')
538
- var dispatcherVersion = getSetting('Dispatcher Version')
536
+ const framework = getSetting('Framework')
537
+ const dispatcher = getSetting('Dispatcher')
538
+ const dispatcherVersion = getSetting('Dispatcher Version')
539
539
 
540
540
  // clearing and rebuilding a global variable
541
541
  settings = Object.create(null)
@@ -569,8 +569,8 @@ function refresh(cb) {
569
569
  _log('Refreshing environment settings')
570
570
  refreshSyncOnly()
571
571
 
572
- var packages = getSetting('Packages')
573
- var dependencies = getSetting('Dependencies')
572
+ const packages = getSetting('Packages')
573
+ const dependencies = getSetting('Dependencies')
574
574
 
575
575
  if (packages.length && dependencies.length) {
576
576
  settings.Packages = packages
@@ -599,7 +599,7 @@ function getJSON(cb) {
599
599
  return
600
600
  }
601
601
 
602
- var items = []
602
+ const items = []
603
603
  Object.keys(settings).forEach(function settingKeysForEach(key) {
604
604
  settings[key].forEach(function settingsValuesForEach(setting) {
605
605
  items.push([key, setting])
@@ -613,7 +613,7 @@ function getJSON(cb) {
613
613
  // At startup, do the synchronous environment scanning stuff.
614
614
  refreshSyncOnly()
615
615
 
616
- var userSetDispatcher = false
616
+ let userSetDispatcher = false
617
617
  module.exports = {
618
618
  setFramework: function setFramework(framework) {
619
619
  addSetting('Framework', framework)
@@ -82,7 +82,7 @@ class ErrorCollector {
82
82
  this.seenObjectsByTransaction[txId] = new WeakSet()
83
83
  }
84
84
 
85
- var seenObjects = this.seenObjectsByTransaction[txId]
85
+ const seenObjects = this.seenObjectsByTransaction[txId]
86
86
  if (seenObjects.has(exception)) {
87
87
  return true
88
88
  }
@@ -97,7 +97,7 @@ class ErrorCollector {
97
97
  this.seenStringsByTransaction[txId] = Object.create(null)
98
98
  }
99
99
 
100
- var seenStrings = this.seenStringsByTransaction[txId]
100
+ const seenStrings = this.seenStringsByTransaction[txId]
101
101
  if (seenStrings[exception]) {
102
102
  return true
103
103
  }
@@ -50,7 +50,7 @@ class ErrorTraceAggregator extends TraceAggregator {
50
50
  const len = Math.min(errors.length, this.limit - this.errors.length)
51
51
  logger.warn('Merging %s (of %s) errors for next delivery.', len, errors.length)
52
52
 
53
- for (var i = 0; i < len; i++) {
53
+ for (let i = 0; i < len; i++) {
54
54
  this.errors.push(errors[i])
55
55
  }
56
56
  }
@@ -37,7 +37,7 @@ module.exports = {
37
37
  return false
38
38
  },
39
39
  isExpectedException: function isExpectedException(transaction, exception, config, urltils) {
40
- let { type, message } = this.extractErrorInformation(transaction, exception, config, urltils)
40
+ const { type, message } = this.extractErrorInformation(transaction, exception, config, urltils)
41
41
 
42
42
  return (
43
43
  this.isExpectedErrorClass(config, type) || this.isExpectedErrorMessage(config, type, message)
@@ -93,7 +93,7 @@ module.exports = {
93
93
 
94
94
  shouldIgnoreError: function shouldIgnoreError(transaction, error, config) {
95
95
  // extract _just_ the error information, not transaction stuff
96
- let errorInfo = this.extractErrorInformation(null, error, config, null)
96
+ const errorInfo = this.extractErrorInformation(null, error, config, null)
97
97
 
98
98
  return (
99
99
  this.shouldIgnoreErrorClass(errorInfo, config) ||
@@ -118,7 +118,7 @@ module.exports = {
118
118
  },
119
119
 
120
120
  shouldIgnoreErrorMessage: function shouldIgnoreErrorMessage(errorInfo, config) {
121
- let configIgnoreMessages = config.error_collector.ignore_messages[errorInfo.type]
121
+ const configIgnoreMessages = config.error_collector.ignore_messages[errorInfo.type]
122
122
  if (!configIgnoreMessages) {
123
123
  return false
124
124
  }
@@ -5,10 +5,10 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var DESTINATIONS = require('../config/attribute-filter').DESTINATIONS
9
- var NAMES = require('../metrics/names')
10
- var props = require('../util/properties')
11
- var urltils = require('../util/urltils')
8
+ const DESTINATIONS = require('../config/attribute-filter').DESTINATIONS
9
+ const NAMES = require('../metrics/names')
10
+ const props = require('../util/properties')
11
+ const urltils = require('../util/urltils')
12
12
  const errorHelper = require('../errors/helper')
13
13
 
14
14
  class Exception {
@@ -51,14 +51,14 @@ class Exception {
51
51
  */
52
52
  function createError(transaction, exception, config) {
53
53
  const error = exception.error
54
- let { name, message, type } = errorHelper.extractErrorInformation(
54
+ const { name, message, type } = errorHelper.extractErrorInformation(
55
55
  transaction,
56
56
  error,
57
57
  config,
58
58
  urltils
59
59
  )
60
60
 
61
- let params = {
61
+ const params = {
62
62
  userAttributes: Object.create(null),
63
63
  agentAttributes: Object.create(null),
64
64
  intrinsics: Object.create(null)
@@ -83,7 +83,7 @@ function createError(transaction, exception, config) {
83
83
 
84
84
  const customAttributes = exception.customAttributes
85
85
  if (!config.high_security && config.api.custom_attributes_enabled && customAttributes) {
86
- for (let key in customAttributes) {
86
+ for (const key in customAttributes) {
87
87
  if (props.hasOwn(customAttributes, key)) {
88
88
  const dest = config.attributeFilter.filterTransaction(DESTINATIONS.ERROR_EVENT, key)
89
89
  if (dest & DESTINATIONS.ERROR_EVENT) {
@@ -106,7 +106,7 @@ function createError(transaction, exception, config) {
106
106
  params.intrinsics['error.expected'] = true
107
107
  }
108
108
 
109
- let res = [0, name, message, type, params]
109
+ const res = [0, name, message, type, params]
110
110
  if (transaction) {
111
111
  res.transaction = transaction.id
112
112
  }
@@ -118,11 +118,11 @@ function createError(transaction, exception, config) {
118
118
  * The error parameter is an output of the createError() function for a given exception.
119
119
  */
120
120
  function createEvent(transaction, error, timestamp, config) {
121
- var message = error[2]
122
- var errorClass = error[3]
123
- var errorParams = error[4]
121
+ const message = error[2]
122
+ const errorClass = error[3]
123
+ const errorParams = error[4]
124
124
 
125
- var intrinsicAttributes = _getErrorEventIntrinsicAttrs(
125
+ const intrinsicAttributes = _getErrorEventIntrinsicAttrs(
126
126
  transaction,
127
127
  errorClass,
128
128
  message,
@@ -133,10 +133,10 @@ function createEvent(transaction, error, timestamp, config) {
133
133
 
134
134
  // the error structure created by createError() already performs filtering of custom
135
135
  // and agent attributes, so it is ok to just copy them
136
- var userAttributes = Object.assign(Object.create(null), errorParams.userAttributes)
137
- var agentAttributes = Object.assign(Object.create(null), errorParams.agentAttributes)
136
+ const userAttributes = Object.assign(Object.create(null), errorParams.userAttributes)
137
+ const agentAttributes = Object.assign(Object.create(null), errorParams.agentAttributes)
138
138
 
139
- var errorEvent = [intrinsicAttributes, userAttributes, agentAttributes]
139
+ const errorEvent = [intrinsicAttributes, userAttributes, agentAttributes]
140
140
 
141
141
  return errorEvent
142
142
  }
@@ -148,7 +148,7 @@ function _getErrorEventIntrinsicAttrs(transaction, errorClass, message, expected
148
148
  timestamp = timestamp / 1000
149
149
  }
150
150
 
151
- var attributes = {
151
+ const attributes = {
152
152
  'type': 'TransactionError',
153
153
  'error.class': errorClass,
154
154
  'error.message': conf.high_security ? '' : message,
@@ -160,7 +160,7 @@ function _getErrorEventIntrinsicAttrs(transaction, errorClass, message, expected
160
160
  attributes.transactionName = transaction.getFullName()
161
161
  attributes.duration = transaction.timer.getDurationInMillis() / 1000
162
162
 
163
- var metric = transaction.metrics.getMetric(NAMES.QUEUETIME)
163
+ let metric = transaction.metrics.getMetric(NAMES.QUEUETIME)
164
164
  if (metric) {
165
165
  attributes.queueDuration = metric.total
166
166
  }
@@ -7,13 +7,14 @@
7
7
 
8
8
  // unreleased flags gating an active feature
9
9
  exports.prerelease = {
10
- express5: false,
11
10
  await_support: true,
12
- promise_segments: false,
13
- reverse_naming_rules: false,
14
- fastify_instrumentation: false,
15
11
  certificate_bundle: false,
12
+ express5: false,
16
13
  new_promise_tracking: false,
14
+ promise_segments: false,
15
+ reverse_naming_rules: false,
16
+ undici_instrumentation: false,
17
+ undici_async_tracking: true,
17
18
  unresolved_promise_cleanup: true
18
19
  }
19
20
 
@@ -29,7 +30,8 @@ exports.released = [
29
30
  'serverless_mode',
30
31
  'send_request_uri_attribute',
31
32
  'synthetics',
32
- 'dt_format_w3c'
33
+ 'dt_format_w3c',
34
+ 'fastify_instrumentation'
33
35
  ]
34
36
 
35
37
  // flags that are no longer used for unreleased features
@@ -111,25 +111,25 @@ function _collectHeaders(headers, nameMap, prefix, transaction) {
111
111
  }, {})
112
112
  }
113
113
 
114
- var headerKeys = !transaction.agent.config.allow_all_headers
114
+ const headerKeys = !transaction.agent.config.allow_all_headers
115
115
  ? COLLECTED_REQUEST_HEADERS
116
116
  : Object.keys(headers)
117
117
 
118
118
  const segment = transaction.agent.tracer.getSegment()
119
119
 
120
- for (var i = 0; i < headerKeys.length; i++) {
121
- var headerKey = headerKeys[i]
122
- var header = headers[headerKey]
120
+ for (let i = 0; i < headerKeys.length; i++) {
121
+ const headerKey = headerKeys[i]
122
+ let header = headers[headerKey]
123
123
  if (header !== undefined) {
124
124
  // If any more processing of the headers is required consider refactoring this.
125
125
  if (headerKey === 'referer' && typeof header === 'string') {
126
- var queryParamIndex = header.indexOf('?')
126
+ const queryParamIndex = header.indexOf('?')
127
127
  if (queryParamIndex !== -1) {
128
128
  header = header.substring(0, queryParamIndex)
129
129
  }
130
130
  }
131
131
 
132
- var attributeName = nameMap[headerKey] || prefix + _headerToCamelCase(headerKey)
132
+ const attributeName = nameMap[headerKey] || prefix + _headerToCamelCase(headerKey)
133
133
  transaction.trace.attributes.addAttribute(DESTS.TRANS_COMMON, attributeName, header)
134
134
 
135
135
  segment.addSpanAttribute(attributeName, header)
@@ -65,7 +65,7 @@ function convertUnit(time) {
65
65
  * @param {*} headers
66
66
  */
67
67
  function getContentLengthFromHeaders(headers) {
68
- let contentLength = -1
68
+ const contentLength = -1
69
69
  for (const [headerName, headerValue] of Object.entries(headers)) {
70
70
  if (CONTENT_LENGTH_REGEX.test(headerName)) {
71
71
  return headerValue