newrelic 8.3.0 → 8.5.2

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 (134) hide show
  1. package/NEWS.md +76 -0
  2. package/README.md +7 -6
  3. package/THIRD_PARTY_NOTICES.md +95 -35
  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 +1 -1
  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 +12 -10
  15. package/lib/config/hsm.js +1 -1
  16. package/lib/config/index.js +82 -66
  17. package/lib/config/lasp.js +3 -3
  18. package/lib/config/merge-server-config.js +1 -1
  19. package/lib/db/parse-sql.js +8 -8
  20. package/lib/db/parsed-statement.js +9 -8
  21. package/lib/db/query-parsers/sql.js +7 -7
  22. package/lib/db/query-sample.js +9 -9
  23. package/lib/db/query-trace-aggregator.js +4 -4
  24. package/lib/db/statement-matcher.js +5 -5
  25. package/lib/db/utils.js +1 -1
  26. package/lib/environment.js +43 -43
  27. package/lib/errors/error-collector.js +2 -2
  28. package/lib/errors/error-trace-aggregator.js +1 -1
  29. package/lib/errors/helper.js +3 -3
  30. package/lib/errors/index.js +17 -17
  31. package/lib/feature_flags.js +7 -5
  32. package/lib/header-attributes.js +6 -6
  33. package/lib/header-processing.js +1 -1
  34. package/lib/instrumentation/amqplib.js +26 -26
  35. package/lib/instrumentation/bluebird.js +3 -3
  36. package/lib/instrumentation/cassandra-driver.js +7 -3
  37. package/lib/instrumentation/connect.js +4 -4
  38. package/lib/instrumentation/core/async_hooks.js +6 -6
  39. package/lib/instrumentation/core/domain.js +2 -2
  40. package/lib/instrumentation/core/globals.js +1 -1
  41. package/lib/instrumentation/core/http-outbound.js +15 -84
  42. package/lib/instrumentation/core/http.js +34 -67
  43. package/lib/instrumentation/core/inspector.js +2 -2
  44. package/lib/instrumentation/core/timers.js +7 -7
  45. package/lib/instrumentation/core/zlib.js +2 -2
  46. package/lib/instrumentation/director.js +4 -4
  47. package/lib/instrumentation/express.js +8 -8
  48. package/lib/instrumentation/fastify/spec-builders.js +57 -47
  49. package/lib/instrumentation/fastify.js +85 -24
  50. package/lib/instrumentation/generic-pool.js +1 -1
  51. package/lib/instrumentation/hapi/hapi-17.js +11 -11
  52. package/lib/instrumentation/hapi/shared.js +1 -1
  53. package/lib/instrumentation/hapi.js +22 -22
  54. package/lib/instrumentation/ioredis.js +7 -7
  55. package/lib/instrumentation/memcached.js +7 -7
  56. package/lib/instrumentation/mongodb/common.js +16 -5
  57. package/lib/instrumentation/mysql.js +19 -19
  58. package/lib/instrumentation/oracle.js +15 -15
  59. package/lib/instrumentation/pg.js +4 -4
  60. package/lib/instrumentation/promise.js +46 -46
  61. package/lib/instrumentation/q.js +2 -2
  62. package/lib/instrumentation/redis.js +11 -11
  63. package/lib/instrumentation/restify.js +1 -1
  64. package/lib/instrumentation/undici.js +242 -0
  65. package/lib/instrumentation/vision.js +4 -4
  66. package/lib/instrumentation/when.js +3 -3
  67. package/lib/instrumentations.js +2 -1
  68. package/lib/logger.js +5 -5
  69. package/lib/metrics/index.js +15 -15
  70. package/lib/metrics/mapper.js +7 -7
  71. package/lib/metrics/normalizer/rule.js +9 -9
  72. package/lib/metrics/normalizer/tx_segment.js +17 -17
  73. package/lib/metrics/normalizer.js +22 -22
  74. package/lib/metrics/recorders/custom.js +5 -5
  75. package/lib/metrics/recorders/generic.js +3 -3
  76. package/lib/metrics/recorders/http.js +7 -7
  77. package/lib/metrics/recorders/http_external.js +7 -7
  78. package/lib/metrics/recorders/message-transaction.js +5 -6
  79. package/lib/metrics/recorders/other.js +5 -5
  80. package/lib/parse-proc-cpuinfo.js +25 -19
  81. package/lib/parse-proc-meminfo.js +8 -2
  82. package/lib/prioritized-attributes.js +2 -2
  83. package/lib/priority-queue.js +10 -10
  84. package/lib/reservoir.js +3 -3
  85. package/lib/sampler.js +26 -26
  86. package/lib/serverless/aws-lambda.js +8 -2
  87. package/lib/shim/datastore-shim.js +35 -32
  88. package/lib/shim/index.js +2 -2
  89. package/lib/shim/message-shim.js +47 -47
  90. package/lib/shim/promise-shim.js +1 -1
  91. package/lib/shim/shim.js +61 -61
  92. package/lib/shim/specs/index.js +3 -3
  93. package/lib/shim/transaction-shim.js +44 -192
  94. package/lib/shim/webframework-shim.js +52 -52
  95. package/lib/spans/span-event.js +1 -1
  96. package/lib/spans/streaming-span-attributes.js +1 -1
  97. package/lib/stats/apdex.js +2 -2
  98. package/lib/stats/index.js +2 -2
  99. package/lib/system-info.js +23 -23
  100. package/lib/timer.js +5 -5
  101. package/lib/transaction/dt-payload.js +1 -1
  102. package/lib/transaction/index.js +40 -40
  103. package/lib/transaction/name-state.js +14 -14
  104. package/lib/transaction/trace/exclusive-time-calculator.js +6 -6
  105. package/lib/transaction/trace/index.js +14 -14
  106. package/lib/transaction/trace/segment.js +18 -18
  107. package/lib/transaction/tracecontext.js +1 -1
  108. package/lib/transaction/tracer/index.js +53 -49
  109. package/lib/uninstrumented.js +7 -7
  110. package/lib/util/arity.js +2 -2
  111. package/lib/util/byte-limit.js +4 -4
  112. package/lib/util/cat.js +269 -24
  113. package/lib/util/codec.js +2 -2
  114. package/lib/util/copy.js +2 -2
  115. package/lib/util/deep-equal.js +10 -10
  116. package/lib/util/flatten.js +4 -4
  117. package/lib/util/hashes.js +14 -14
  118. package/lib/util/label-parser.js +17 -17
  119. package/lib/util/logger.js +24 -24
  120. package/lib/util/process-version.js +2 -2
  121. package/lib/util/properties.js +4 -4
  122. package/lib/util/sql/obfuscate.js +15 -15
  123. package/lib/util/stream-sink.js +3 -3
  124. package/lib/util/unwrapped-core.js +2 -2
  125. package/lib/util/urltils.js +16 -16
  126. package/lib/utilization/aws-info.js +7 -7
  127. package/lib/utilization/azure-info.js +6 -6
  128. package/lib/utilization/common.js +13 -13
  129. package/lib/utilization/docker-info.js +11 -11
  130. package/lib/utilization/gcp-info.js +4 -4
  131. package/lib/utilization/index.js +5 -5
  132. package/lib/utilization/pcf-info.js +9 -9
  133. package/package.json +13 -6
  134. package/stub_api.js +8 -8
@@ -274,7 +274,7 @@ function _truncate(val) {
274
274
 
275
275
  function _filterNulls(obj) {
276
276
  const out = Object.create(null)
277
- for (let key in obj) {
277
+ for (const key in obj) {
278
278
  if (obj[key] != null) {
279
279
  out[key] = obj[key]
280
280
  }
@@ -55,7 +55,7 @@ class StreamingSpanAttributes {
55
55
  return
56
56
  }
57
57
 
58
- for (let [key, value] of Object.entries(attributes)) {
58
+ for (const [key, value] of Object.entries(attributes)) {
59
59
  this.addAttribute(key, value)
60
60
  }
61
61
  }
@@ -10,7 +10,7 @@
10
10
  * CONSTANTS
11
11
  *
12
12
  */
13
- var FROM_MILLIS = 1e-3
13
+ const FROM_MILLIS = 1e-3
14
14
 
15
15
  function ApdexStats(apdexT) {
16
16
  if (!apdexT && apdexT !== 0) {
@@ -24,7 +24,7 @@ function ApdexStats(apdexT) {
24
24
  }
25
25
 
26
26
  ApdexStats.prototype.recordValue = function recordValue(time, overrideApdex) {
27
- var apdexT = overrideApdex || this.apdexT
27
+ const apdexT = overrideApdex || this.apdexT
28
28
  if (time <= apdexT) {
29
29
  ++this.satisfying
30
30
  } else if (time <= 4 * apdexT) {
@@ -10,8 +10,8 @@
10
10
  * CONSTANTS
11
11
  *
12
12
  */
13
- var BYTES_PER_MB = 1024 * 1024
14
- var FROM_MILLIS = 1e-3
13
+ const BYTES_PER_MB = 1024 * 1024
14
+ const FROM_MILLIS = 1e-3
15
15
 
16
16
  /**
17
17
  * Simple container for tracking running statistics for a metric.
@@ -5,15 +5,15 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var exec = require('child_process').exec
9
- var readProc = require('./utilization/common').readProc
10
- var getBootId = require('./utilization/docker-info').getBootId
11
- var utilization = require('./utilization')
12
- var logger = require('./logger.js').child({ component: 'system-info' })
13
- var os = require('os')
14
- var parseCpuInfo = require('./parse-proc-cpuinfo')
15
- var parseMemInfo = require('./parse-proc-meminfo')
16
- var platform = os.platform()
8
+ const exec = require('child_process').exec
9
+ const readProc = require('./utilization/common').readProc
10
+ const getBootId = require('./utilization/docker-info').getBootId
11
+ const utilization = require('./utilization')
12
+ const logger = require('./logger.js').child({ component: 'system-info' })
13
+ const os = require('os')
14
+ const parseCpuInfo = require('./parse-proc-cpuinfo')
15
+ const parseMemInfo = require('./parse-proc-meminfo')
16
+ const platform = os.platform()
17
17
 
18
18
  module.exports = fetchSystemInfo
19
19
 
@@ -22,19 +22,19 @@ function isInteger(i) {
22
22
  }
23
23
 
24
24
  function fetchSystemInfo(agent, callback) {
25
- var config = agent.config
26
- var systemInfo = {
25
+ const config = agent.config
26
+ const systemInfo = {
27
27
  processorArch: os.arch()
28
28
  }
29
29
 
30
- var utilizationConfig = Object.create(null)
30
+ const utilizationConfig = Object.create(null)
31
31
  if (config.utilization) {
32
- var configProcessors = config.utilization.logical_processors
33
- var configRam = config.utilization.total_ram_mib
34
- var configHostname = config.utilization.billing_hostname
32
+ const configProcessors = config.utilization.logical_processors
33
+ const configRam = config.utilization.total_ram_mib
34
+ const configHostname = config.utilization.billing_hostname
35
35
 
36
36
  if (configProcessors) {
37
- var parsedConfigProcessors = parseFloat(configProcessors, 10)
37
+ const parsedConfigProcessors = parseFloat(configProcessors, 10)
38
38
  if (!isNaN(parsedConfigProcessors) && isInteger(parsedConfigProcessors)) {
39
39
  utilizationConfig.logical_processors = parsedConfigProcessors
40
40
  } else {
@@ -46,7 +46,7 @@ function fetchSystemInfo(agent, callback) {
46
46
  }
47
47
 
48
48
  if (configRam) {
49
- var parsedConfigRam = parseFloat(configRam, 10)
49
+ const parsedConfigRam = parseFloat(configRam, 10)
50
50
  if (!isNaN(parsedConfigRam) && isInteger(parsedConfigRam)) {
51
51
  utilizationConfig.total_ram_mib = parsedConfigRam
52
52
  } else {
@@ -73,8 +73,8 @@ function fetchSystemInfo(agent, callback) {
73
73
  }
74
74
  }
75
75
 
76
- var tasksDone = 0
77
- var numTasks = 5
76
+ let tasksDone = 0
77
+ const numTasks = 5
78
78
  function finishedResponse() {
79
79
  if (++tasksDone === numTasks) {
80
80
  callback(null, systemInfo)
@@ -111,7 +111,7 @@ function fetchSystemInfo(agent, callback) {
111
111
 
112
112
  // placed on module for mocking purposes in tests
113
113
  module.exports._getProcessorStats = function getProcessorStats(callback) {
114
- var processorStats = {
114
+ const processorStats = {
115
115
  logical: null,
116
116
  cores: null,
117
117
  packages: null
@@ -127,7 +127,7 @@ module.exports._getProcessorStats = function getProcessorStats(callback) {
127
127
  processorStats.cores = parseFloat(cores, 10)
128
128
  processorStats.packages = parseFloat(packages, 10)
129
129
 
130
- for (var key in processorStats) {
130
+ for (const key in processorStats) {
131
131
  if (!processorStats[key] || !isInteger(processorStats[key])) {
132
132
  processorStats[key] = null
133
133
  }
@@ -196,8 +196,8 @@ function getSysctlValue(names, callback) {
196
196
  if (!names) {
197
197
  return callback(null)
198
198
  }
199
- var returned = false
200
- var ran = 0
199
+ let returned = false
200
+ let ran = 0
201
201
  names.forEach(function sysctlName(name) {
202
202
  exec('sysctl -n ' + name, respond)
203
203
 
package/lib/timer.js CHANGED
@@ -16,9 +16,9 @@
16
16
  * are set, but the timer has not yet been harvested).
17
17
  * DEAD timer has been harvested and can only have its duration read.
18
18
  */
19
- var PENDING = 1
20
- var RUNNING = 2
21
- var STOPPED = 3
19
+ const PENDING = 1
20
+ const RUNNING = 2
21
+ const STOPPED = 3
22
22
 
23
23
  function hrToMillis(hr) {
24
24
  // process.hrTime gives you [second, nanosecond] duration pairs
@@ -209,8 +209,8 @@ Timer.prototype.toRange = function toRange() {
209
209
  */
210
210
  Timer.prototype.startedRelativeTo = function startedRelativeTo(other) {
211
211
  if (this.hrstart && other.hrstart) {
212
- var s = this.hrstart[0] - other.hrstart[0]
213
- var ns = this.hrstart[1] - other.hrstart[1]
212
+ const s = this.hrstart[0] - other.hrstart[0]
213
+ const ns = this.hrstart[1] - other.hrstart[1]
214
214
 
215
215
  return hrToMillis([s, ns])
216
216
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var logger = require('../logger').child({ component: 'distributedTracePayload' })
8
+ const logger = require('../logger').child({ component: 'distributedTracePayload' })
9
9
 
10
10
  const DT_VERSION_MAJOR = 0
11
11
  const DT_VERSION_MINOR = 1
@@ -6,16 +6,16 @@
6
6
  'use strict'
7
7
 
8
8
  const errorHelper = require('../errors/helper')
9
- var hashes = require('../util/hashes')
10
- var logger = require('../logger').child({ component: 'transaction' })
11
- var Metrics = require('../metrics')
12
- var NAMES = require('../metrics/names')
13
- var NameState = require('./name-state')
14
- var props = require('../util/properties')
15
- var Timer = require('../timer')
16
- var Trace = require('./trace')
17
- var url = require('url')
18
- var urltils = require('../util/urltils')
9
+ const hashes = require('../util/hashes')
10
+ const logger = require('../logger').child({ component: 'transaction' })
11
+ const Metrics = require('../metrics')
12
+ const NAMES = require('../metrics/names')
13
+ const NameState = require('./name-state')
14
+ const props = require('../util/properties')
15
+ const Timer = require('../timer')
16
+ const Trace = require('./trace')
17
+ const url = require('url')
18
+ const urltils = require('../util/urltils')
19
19
  const TraceContext = require('./tracecontext').TraceContext
20
20
 
21
21
  /*
@@ -270,11 +270,11 @@ Transaction.prototype.getResponseTimeInMillis = function getResponseTimeInMillis
270
270
  */
271
271
  Transaction.prototype._runUserNamingRules = function _runUserNamingRules(requestUrl) {
272
272
  // 1. user normalization rules (set in configuration)
273
- var normalized = this.agent.userNormalizer.normalize(requestUrl)
273
+ const normalized = this.agent.userNormalizer.normalize(requestUrl)
274
274
  if (normalized.matched) {
275
275
  // After applying user naming rule, apply server-side sent rules to
276
276
  // further squash possible MGIs
277
- var serverNormalized = this.agent.urlNormalizer.normalize(normalized.value)
277
+ const serverNormalized = this.agent.urlNormalizer.normalize(normalized.value)
278
278
  if (serverNormalized.ignore) {
279
279
  normalized.ignore = true
280
280
  }
@@ -294,7 +294,7 @@ Transaction.prototype._runUserNamingRules = function _runUserNamingRules(request
294
294
  * @param {string} requestUrl - The URL to normalize and apply to this transaction.
295
295
  */
296
296
  Transaction.prototype.applyUserNamingRules = function applyUserNamingRules(requestUrl) {
297
- var normalized = this._runUserNamingRules(requestUrl)
297
+ const normalized = this._runUserNamingRules(requestUrl)
298
298
  if (normalized.ignore) {
299
299
  this.ignore = normalized.ignore
300
300
  }
@@ -327,11 +327,11 @@ Transaction.prototype.setPartialName = function setPartialName(name) {
327
327
  */
328
328
  Transaction.prototype._partialNameFromUri = _partialNameFromUri
329
329
  function _partialNameFromUri(requestUrl, status) {
330
- var scrubbedUrl = urltils.scrub(requestUrl)
330
+ const scrubbedUrl = urltils.scrub(requestUrl)
331
331
 
332
332
  // 0. If there is a name in the name-state stack, use it.
333
- var partialName = this._partialName
334
- var ignore = false
333
+ let partialName = this._partialName
334
+ let ignore = false
335
335
  if (!this.nameState.isEmpty()) {
336
336
  partialName = this.nameState.getFullName()
337
337
  }
@@ -343,7 +343,7 @@ function _partialNameFromUri(requestUrl, status) {
343
343
 
344
344
  // 2. user normalization rules (set in configuration) can override transaction
345
345
  // naming from API
346
- var userNormalized = this._runUserNamingRules(scrubbedUrl)
346
+ const userNormalized = this._runUserNamingRules(scrubbedUrl)
347
347
  ignore = ignore || userNormalized.ignore
348
348
  if (userNormalized.matched) {
349
349
  partialName = userNormalized.value
@@ -358,7 +358,7 @@ function _partialNameFromUri(requestUrl, status) {
358
358
  if (statusName) {
359
359
  partialName = statusName
360
360
  } else {
361
- var normalized = this.agent.urlNormalizer.normalize(scrubbedUrl)
361
+ const normalized = this.agent.urlNormalizer.normalize(scrubbedUrl)
362
362
  ignore = ignore || normalized.ignore
363
363
  partialName = normalized.value
364
364
  }
@@ -421,7 +421,7 @@ function finalizeNameFromUri(requestURL, statusCode) {
421
421
  this.statusCode = statusCode
422
422
 
423
423
  // Derive the name from the request URL.
424
- var partialName = this._partialNameFromUri(requestURL, statusCode)
424
+ const partialName = this._partialNameFromUri(requestURL, statusCode)
425
425
  this._partialName = partialName.value
426
426
  if (partialName.ignore) {
427
427
  this.ignore = true
@@ -430,7 +430,7 @@ function finalizeNameFromUri(requestURL, statusCode) {
430
430
  // If a namestate stack exists, copy route parameters over to the trace.
431
431
  if (!this.nameState.isEmpty() && this.baseSegment) {
432
432
  this.nameState.forEachParams(function forEachRouteParams(params) {
433
- for (var key in params) {
433
+ for (const key in params) {
434
434
  if (props.hasOwn(params, key)) {
435
435
  this.trace.attributes.addAttribute(DESTS.NONE, 'request.parameters.' + key, params[key])
436
436
 
@@ -450,8 +450,8 @@ function finalizeNameFromUri(requestURL, statusCode) {
450
450
  }
451
451
 
452
452
  // Apply transaction name normalization rules (sent by server) to full name.
453
- var fullName = TYPE_METRICS[this.type] + '/' + this._partialName
454
- var normalized = this.agent.transactionNameNormalizer.normalize(fullName)
453
+ const fullName = TYPE_METRICS[this.type] + '/' + this._partialName
454
+ const normalized = this.agent.transactionNameNormalizer.normalize(fullName)
455
455
  if (normalized.ignore) {
456
456
  this.ignore = true
457
457
  }
@@ -499,8 +499,8 @@ Transaction.prototype._copyNameToActiveSpan = function _copyNameToActiveSpan(nam
499
499
  */
500
500
  Transaction.prototype._markAsWeb = function _markAsWeb(rawURL) {
501
501
  // Because we are assured we have the URL here, lets grab query params.
502
- var params = urltils.parseParameters(rawURL)
503
- for (var key in params) {
502
+ const params = urltils.parseParameters(rawURL)
503
+ for (const key in params) {
504
504
  if (props.hasOwn(params, key)) {
505
505
  this.trace.attributes.addAttribute(DESTS.NONE, 'request.parameters.' + key, params[key])
506
506
 
@@ -539,11 +539,11 @@ Transaction.prototype.finalizeName = function finalizeName(name) {
539
539
  return
540
540
  }
541
541
 
542
- var fullName = TYPE_METRICS[this.type] + '/' + this._partialName
542
+ const fullName = TYPE_METRICS[this.type] + '/' + this._partialName
543
543
 
544
544
  // Transaction normalizers run on the full metric name, not the user facing
545
545
  // transaction name.
546
- var normalized = this.agent.transactionNameNormalizer.normalize(fullName)
546
+ const normalized = this.agent.transactionNameNormalizer.normalize(fullName)
547
547
  if (normalized.ignore) {
548
548
  this.ignore = true
549
549
  }
@@ -589,7 +589,7 @@ Transaction.prototype.getName = function getName() {
589
589
  }
590
590
 
591
591
  Transaction.prototype.getFullName = function getFullName() {
592
- var name = null
592
+ let name = null
593
593
  if (this.forceName) {
594
594
  name = this.forceName
595
595
  } else if (this.name) {
@@ -601,7 +601,7 @@ Transaction.prototype.getFullName = function getFullName() {
601
601
  if (!name) {
602
602
  return null
603
603
  }
604
- var fullName = TYPE_METRICS[this.type] + '/' + name
604
+ const fullName = TYPE_METRICS[this.type] + '/' + name
605
605
  return this.agent.transactionNameNormalizer.normalize(fullName).value
606
606
  }
607
607
 
@@ -635,7 +635,7 @@ Transaction.prototype.getScrubbedUrl = function getScrubbedUrl() {
635
635
  this.parsedUrl = url.parse(this.url)
636
636
  }
637
637
 
638
- var scrubbedParsedUrl = Object.assign(Object.create(null), this.parsedUrl)
638
+ const scrubbedParsedUrl = Object.assign(Object.create(null), this.parsedUrl)
639
639
  scrubbedParsedUrl.search = null
640
640
  scrubbedParsedUrl.query = null
641
641
  scrubbedParsedUrl.href = null
@@ -670,8 +670,8 @@ Transaction.prototype.addRecorder = function addRecorder(recorder) {
670
670
  * and should be written to handle this.
671
671
  */
672
672
  Transaction.prototype.record = function record() {
673
- var name = this.name
674
- for (var i = 0, l = this._recorders.length; i < l; ++i) {
673
+ const name = this.name
674
+ for (let i = 0, l = this._recorders.length; i < l; ++i) {
675
675
  this._recorders[i](name)
676
676
  }
677
677
  }
@@ -700,7 +700,7 @@ Transaction.prototype.measure = function measure(name, scope, duration, exclusiv
700
700
  * (optional).
701
701
  */
702
702
  Transaction.prototype._setApdex = function _setApdex(name, duration, keyApdexInMillis) {
703
- var apdexStats = this.metrics.getOrCreateApdexMetric(name, null, keyApdexInMillis)
703
+ const apdexStats = this.metrics.getOrCreateApdexMetric(name, null, keyApdexInMillis)
704
704
 
705
705
  // if we have an error-like status code, and all the errors are
706
706
  // expected, we know the status code was caused by an expected
@@ -744,13 +744,13 @@ Transaction.prototype.includesOutboundRequests = function includesOutboundReques
744
744
  * current path hash.
745
745
  */
746
746
  Transaction.prototype.alternatePathHashes = function alternatePathHashes() {
747
- var curHash = hashes.calculatePathHash(
747
+ const curHash = hashes.calculatePathHash(
748
748
  this.agent.config.applications()[0],
749
749
  this.getFullName(),
750
750
  this.referringPathHash
751
751
  )
752
- var altHashes = this.pathHashes.slice()
753
- var curIndex = altHashes.indexOf(curHash)
752
+ const altHashes = this.pathHashes.slice()
753
+ const curIndex = altHashes.indexOf(curHash)
754
754
 
755
755
  if (curIndex !== -1) {
756
756
  altHashes.splice(curIndex, 1)
@@ -836,9 +836,9 @@ Transaction.prototype.hasIgnoredErrorStatusCode = function _hasIgnoredErrorStatu
836
836
  * considered to be an error.
837
837
  */
838
838
  Transaction.prototype.hasErrors = function _hasErrors() {
839
- var isErroredTransaction = urltils.isError(this.agent.config, this.statusCode)
840
- var transactionHasExceptions = this.exceptions.length > 0
841
- var transactionHasuserErrors = this.userErrors.length > 0
839
+ const isErroredTransaction = urltils.isError(this.agent.config, this.statusCode)
840
+ const transactionHasExceptions = this.exceptions.length > 0
841
+ const transactionHasuserErrors = this.userErrors.length > 0
842
842
  return transactionHasExceptions || transactionHasuserErrors || isErroredTransaction
843
843
  }
844
844
 
@@ -867,7 +867,7 @@ Transaction.prototype.hasOnlyExpectedErrors = function hasOnlyExpectedErrors() {
867
867
  */
868
868
  Transaction.prototype.getIntrinsicAttributes = function getIntrinsicAttributes() {
869
869
  if (!this._intrinsicAttributes.totalTime) {
870
- var config = this.agent.config
870
+ const config = this.agent.config
871
871
  this._intrinsicAttributes.totalTime = this.trace.getTotalTimeDurationInMillis() * FROM_MILLIS
872
872
 
873
873
  if (config.distributed_tracing.enabled) {
@@ -1295,7 +1295,7 @@ Transaction.prototype.addRequestParameters = addRequestParameters
1295
1295
  * @param {Object.<string, string>} requestParameters
1296
1296
  */
1297
1297
  function addRequestParameters(requestParameters) {
1298
- for (var key in requestParameters) {
1298
+ for (const key in requestParameters) {
1299
1299
  if (props.hasOwn(requestParameters, key)) {
1300
1300
  this.trace.attributes.addAttribute(
1301
1301
  DESTS.NONE,
@@ -5,11 +5,11 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var logger = require('../logger.js').child({ component: 'name-state' })
9
- var NAMES = require('../metrics/names')
8
+ const logger = require('../logger.js').child({ component: 'name-state' })
9
+ const NAMES = require('../metrics/names')
10
10
 
11
11
  // TODO: Figure out a way to phase out legacy transaction names.
12
- var LEGACY_NAMING = {
12
+ const LEGACY_NAMING = {
13
13
  Custom: true,
14
14
 
15
15
  Connect: true,
@@ -107,7 +107,7 @@ NameState.prototype.isEmpty = function isEmpty() {
107
107
  */
108
108
  NameState.prototype.appendPath = function appendPath(path, params) {
109
109
  if (!this._frozen && path != null) {
110
- var strPath = path instanceof RegExp ? path.source : String(path)
110
+ const strPath = path instanceof RegExp ? path.source : String(path)
111
111
  this.pathStack.push({ path: strPath, params: params || null })
112
112
 
113
113
  if (path !== '') {
@@ -141,7 +141,7 @@ NameState.prototype.popPath = function popPath(path) {
141
141
  }
142
142
 
143
143
  this._pathCache = null
144
- var pops = 0
144
+ let pops = 0
145
145
  if (path != null) {
146
146
  const idx = _findLastIndex(this.pathStack, (a) => a.path === path)
147
147
  if (idx !== -1) {
@@ -156,17 +156,17 @@ NameState.prototype.popPath = function popPath(path) {
156
156
  }
157
157
 
158
158
  NameState.prototype.getPath = function getPath() {
159
- var ps = !this.pathStack.length ? this.markedPath : this.pathStack
160
- var psLength = ps.length
159
+ const ps = !this.pathStack.length ? this.markedPath : this.pathStack
160
+ const psLength = ps.length
161
161
  if (this._pathCache) {
162
162
  return this._pathCache
163
163
  } else if (psLength === 0) {
164
164
  return null // nameState initialized but never set
165
165
  }
166
166
 
167
- var path = '/'
168
- for (var i = 0; i < psLength; ++i) {
169
- var a = ps[i].path
167
+ let path = '/'
168
+ for (let i = 0; i < psLength; ++i) {
169
+ let a = ps[i].path
170
170
  if (a && a !== '/') {
171
171
  if (a[0] !== '/' && path[path.length - 1] !== '/') {
172
172
  path += '/'
@@ -181,7 +181,7 @@ NameState.prototype.getPath = function getPath() {
181
181
  }
182
182
 
183
183
  NameState.prototype.getNameNotFound = function getNameNotFound() {
184
- var name = _getName(this, '(not found)')
184
+ const name = _getName(this, '(not found)')
185
185
  if (LEGACY_NAMING.hasOwnProperty(this.prefix)) {
186
186
  return name
187
187
  }
@@ -189,7 +189,7 @@ NameState.prototype.getNameNotFound = function getNameNotFound() {
189
189
  }
190
190
 
191
191
  NameState.prototype.getName = function getName() {
192
- var path = this.getPath()
192
+ const path = this.getPath()
193
193
  if (path === null) {
194
194
  return null
195
195
  }
@@ -198,7 +198,7 @@ NameState.prototype.getName = function getName() {
198
198
  }
199
199
 
200
200
  NameState.prototype.getFullName = function getFullName() {
201
- var name = this.getName()
201
+ const name = this.getName()
202
202
  if (LEGACY_NAMING.hasOwnProperty(this.prefix)) {
203
203
  return name
204
204
  }
@@ -234,7 +234,7 @@ NameState.prototype.reset = function reset() {
234
234
  }
235
235
 
236
236
  function _getName(nameState, path) {
237
- var verb = nameState.verb ? '/' + nameState.verb : ''
237
+ const verb = nameState.verb ? '/' + nameState.verb : ''
238
238
  return (nameState.prefix || '') + verb + (nameState.delimiter || '') + path
239
239
  }
240
240
 
@@ -36,7 +36,7 @@ class ExclusiveCalculator {
36
36
  segment: segment,
37
37
  childPairs: []
38
38
  })
39
- for (var i = children.length - 1; i >= 0; --i) {
39
+ for (let i = children.length - 1; i >= 0; --i) {
40
40
  this.toProcess.push(children[i])
41
41
  }
42
42
  }
@@ -103,17 +103,17 @@ function merge(first, second) {
103
103
  }
104
104
 
105
105
  const res = []
106
- var resIdx = 0
107
- var firstIdx = 0
108
- var secondIdx = 0
106
+ let resIdx = 0
107
+ let firstIdx = 0
108
+ let secondIdx = 0
109
109
  // N.B. this is destructive, it will be updating the end times for range arrays in
110
110
  // the input arrays. If we need to reuse these arrays for anything, this behavior
111
111
  // must be changed.
112
- var currInterval =
112
+ let currInterval =
113
113
  first[firstIdx][0] < second[secondIdx][0] ? first[firstIdx++] : second[secondIdx++]
114
114
 
115
115
  while (firstIdx < first.length && secondIdx < second.length) {
116
- var next = first[firstIdx][0] < second[secondIdx][0] ? first[firstIdx++] : second[secondIdx++]
116
+ const next = first[firstIdx][0] < second[secondIdx][0] ? first[firstIdx++] : second[secondIdx++]
117
117
  if (next[0] <= currInterval[1]) {
118
118
  // if the segment overlaps, update the end of the current merged segment
119
119
  currInterval[1] = Math.max(next[1], currInterval[1])
@@ -5,13 +5,13 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var codec = require('../../util/codec')
9
- var Segment = require('./segment')
10
- var { Attributes, MAXIMUM_CUSTOM_ATTRIBUTES } = require('../../attributes')
11
- var logger = require('../../logger').child({ component: 'trace' })
8
+ const codec = require('../../util/codec')
9
+ const Segment = require('./segment')
10
+ const { Attributes, MAXIMUM_CUSTOM_ATTRIBUTES } = require('../../attributes')
11
+ const logger = require('../../logger').child({ component: 'trace' })
12
12
 
13
- var { DESTINATIONS } = require('../../config/attribute-filter')
14
- var FROM_MILLIS = 1e-3
13
+ const { DESTINATIONS } = require('../../config/attribute-filter')
14
+ const FROM_MILLIS = 1e-3
15
15
  const ATTRIBUTE_SCOPE = 'transaction'
16
16
 
17
17
  const REQUEST_URI_KEY = 'request.uri'
@@ -41,8 +41,8 @@ function Trace(transaction) {
41
41
  this.attributes = new Attributes(ATTRIBUTE_SCOPE)
42
42
 
43
43
  // sending displayName if set by user
44
- var displayName = transaction.agent.config.getDisplayHost()
45
- var hostName = transaction.agent.config.getHostnameSafe()
44
+ const displayName = transaction.agent.config.getDisplayHost()
45
+ const hostName = transaction.agent.config.getHostnameSafe()
46
46
  if (displayName !== hostName) {
47
47
  this.attributes.addAttribute(DESTINATIONS.TRANS_COMMON, 'host.displayName', displayName)
48
48
 
@@ -82,7 +82,7 @@ Trace.prototype.generateSpanEvents = function generateSpanEvents() {
82
82
  config.span_events.enabled &&
83
83
  config.distributed_tracing.enabled
84
84
  ) {
85
- let toProcess = []
85
+ const toProcess = []
86
86
 
87
87
  // Root segment does not become a span, so we need to process it separately.
88
88
  const spanAggregator = this.transaction.agent.spanEventAggregator
@@ -113,8 +113,8 @@ Trace.prototype.generateSpanEvents = function generateSpanEvents() {
113
113
  }
114
114
 
115
115
  while (toProcess.length) {
116
- let segmentInfo = toProcess.pop()
117
- let segment = segmentInfo.segment
116
+ const segmentInfo = toProcess.pop()
117
+ const segment = segmentInfo.segment
118
118
 
119
119
  // Even though at some point we might want to stop adding events because all the priorities
120
120
  // should be the same, we need to count the spans as seen.
@@ -209,11 +209,11 @@ Trace.prototype.getTotalTimeDurationInMillis = function getTotalTimeDurationInMi
209
209
  if (this.root.children.length === 0) {
210
210
  return 0
211
211
  }
212
- var segments = this.root.getChildren()
213
- var totalTimeInMillis = 0
212
+ let segments = this.root.getChildren()
213
+ let totalTimeInMillis = 0
214
214
 
215
215
  while (segments.length !== 0) {
216
- var segment = segments.pop()
216
+ const segment = segments.pop()
217
217
  totalTimeInMillis += segment.getExclusiveDurationInMillis()
218
218
  segments = segments.concat(segment.getChildren())
219
219
  }