newrelic 8.3.0 → 8.4.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.
Files changed (128) hide show
  1. package/NEWS.md +34 -0
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/api.js +74 -68
  4. package/bin/test-naming-rules.js +22 -22
  5. package/lib/agent.js +4 -4
  6. package/lib/attributes.js +2 -2
  7. package/lib/collector/api.js +12 -12
  8. package/lib/collector/facts.js +1 -1
  9. package/lib/collector/http-agents.js +12 -11
  10. package/lib/collector/key-parser.js +1 -1
  11. package/lib/collector/remote-method.js +27 -26
  12. package/lib/config/attribute-filter.js +23 -23
  13. package/lib/config/default.js +12 -10
  14. package/lib/config/hsm.js +1 -1
  15. package/lib/config/index.js +82 -66
  16. package/lib/config/lasp.js +3 -3
  17. package/lib/config/merge-server-config.js +1 -1
  18. package/lib/db/parse-sql.js +8 -8
  19. package/lib/db/parsed-statement.js +9 -8
  20. package/lib/db/query-parsers/sql.js +7 -7
  21. package/lib/db/query-sample.js +9 -9
  22. package/lib/db/query-trace-aggregator.js +4 -4
  23. package/lib/db/statement-matcher.js +5 -5
  24. package/lib/db/utils.js +1 -1
  25. package/lib/environment.js +43 -43
  26. package/lib/errors/error-collector.js +2 -2
  27. package/lib/errors/error-trace-aggregator.js +1 -1
  28. package/lib/errors/helper.js +3 -3
  29. package/lib/errors/index.js +17 -17
  30. package/lib/header-attributes.js +6 -6
  31. package/lib/header-processing.js +1 -1
  32. package/lib/instrumentation/amqplib.js +26 -26
  33. package/lib/instrumentation/bluebird.js +3 -3
  34. package/lib/instrumentation/cassandra-driver.js +7 -3
  35. package/lib/instrumentation/connect.js +4 -4
  36. package/lib/instrumentation/core/async_hooks.js +6 -6
  37. package/lib/instrumentation/core/domain.js +2 -2
  38. package/lib/instrumentation/core/globals.js +1 -1
  39. package/lib/instrumentation/core/http-outbound.js +14 -83
  40. package/lib/instrumentation/core/http.js +34 -67
  41. package/lib/instrumentation/core/inspector.js +2 -2
  42. package/lib/instrumentation/core/timers.js +7 -7
  43. package/lib/instrumentation/core/zlib.js +2 -2
  44. package/lib/instrumentation/director.js +4 -4
  45. package/lib/instrumentation/express.js +8 -8
  46. package/lib/instrumentation/generic-pool.js +1 -1
  47. package/lib/instrumentation/hapi/hapi-17.js +11 -11
  48. package/lib/instrumentation/hapi/shared.js +1 -1
  49. package/lib/instrumentation/hapi.js +22 -22
  50. package/lib/instrumentation/ioredis.js +7 -7
  51. package/lib/instrumentation/memcached.js +7 -7
  52. package/lib/instrumentation/mongodb/common.js +4 -1
  53. package/lib/instrumentation/mysql.js +19 -19
  54. package/lib/instrumentation/oracle.js +15 -15
  55. package/lib/instrumentation/pg.js +4 -4
  56. package/lib/instrumentation/promise.js +46 -46
  57. package/lib/instrumentation/q.js +2 -2
  58. package/lib/instrumentation/redis.js +11 -11
  59. package/lib/instrumentation/restify.js +1 -1
  60. package/lib/instrumentation/vision.js +4 -4
  61. package/lib/instrumentation/when.js +3 -3
  62. package/lib/instrumentations.js +1 -1
  63. package/lib/logger.js +5 -5
  64. package/lib/metrics/index.js +15 -15
  65. package/lib/metrics/mapper.js +7 -7
  66. package/lib/metrics/normalizer/rule.js +9 -9
  67. package/lib/metrics/normalizer/tx_segment.js +17 -17
  68. package/lib/metrics/normalizer.js +22 -22
  69. package/lib/metrics/recorders/custom.js +5 -5
  70. package/lib/metrics/recorders/generic.js +3 -3
  71. package/lib/metrics/recorders/http.js +7 -7
  72. package/lib/metrics/recorders/http_external.js +7 -7
  73. package/lib/metrics/recorders/message-transaction.js +5 -6
  74. package/lib/metrics/recorders/other.js +5 -5
  75. package/lib/parse-proc-cpuinfo.js +18 -18
  76. package/lib/parse-proc-meminfo.js +2 -2
  77. package/lib/prioritized-attributes.js +2 -2
  78. package/lib/priority-queue.js +10 -10
  79. package/lib/reservoir.js +3 -3
  80. package/lib/sampler.js +26 -26
  81. package/lib/shim/datastore-shim.js +35 -32
  82. package/lib/shim/index.js +2 -2
  83. package/lib/shim/message-shim.js +47 -47
  84. package/lib/shim/promise-shim.js +1 -1
  85. package/lib/shim/shim.js +61 -61
  86. package/lib/shim/specs/index.js +3 -3
  87. package/lib/shim/transaction-shim.js +44 -192
  88. package/lib/shim/webframework-shim.js +52 -52
  89. package/lib/spans/span-event.js +1 -1
  90. package/lib/spans/streaming-span-attributes.js +1 -1
  91. package/lib/stats/apdex.js +2 -2
  92. package/lib/stats/index.js +2 -2
  93. package/lib/system-info.js +23 -23
  94. package/lib/timer.js +5 -5
  95. package/lib/transaction/dt-payload.js +1 -1
  96. package/lib/transaction/index.js +40 -40
  97. package/lib/transaction/name-state.js +14 -14
  98. package/lib/transaction/trace/exclusive-time-calculator.js +6 -6
  99. package/lib/transaction/trace/index.js +14 -14
  100. package/lib/transaction/trace/segment.js +18 -18
  101. package/lib/transaction/tracecontext.js +1 -1
  102. package/lib/transaction/tracer/index.js +53 -49
  103. package/lib/uninstrumented.js +7 -7
  104. package/lib/util/arity.js +2 -2
  105. package/lib/util/byte-limit.js +4 -4
  106. package/lib/util/cat.js +269 -24
  107. package/lib/util/codec.js +2 -2
  108. package/lib/util/copy.js +2 -2
  109. package/lib/util/deep-equal.js +10 -10
  110. package/lib/util/flatten.js +4 -4
  111. package/lib/util/hashes.js +14 -14
  112. package/lib/util/label-parser.js +17 -17
  113. package/lib/util/logger.js +24 -24
  114. package/lib/util/process-version.js +2 -2
  115. package/lib/util/properties.js +4 -4
  116. package/lib/util/sql/obfuscate.js +15 -15
  117. package/lib/util/stream-sink.js +3 -3
  118. package/lib/util/unwrapped-core.js +2 -2
  119. package/lib/util/urltils.js +16 -16
  120. package/lib/utilization/aws-info.js +7 -7
  121. package/lib/utilization/azure-info.js +6 -6
  122. package/lib/utilization/common.js +13 -13
  123. package/lib/utilization/docker-info.js +11 -11
  124. package/lib/utilization/gcp-info.js +4 -4
  125. package/lib/utilization/index.js +5 -5
  126. package/lib/utilization/pcf-info.js +9 -9
  127. package/package.json +7 -2
  128. package/stub_api.js +8 -8
@@ -5,9 +5,9 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var util = require('util')
9
- var properties = require('../util/properties')
10
- var shimmer = require('../shimmer')
8
+ const util = require('util')
9
+ const properties = require('../util/properties')
10
+ const shimmer = require('../shimmer')
11
11
 
12
12
  /**
13
13
  * @namespace Library.Spec
@@ -92,7 +92,7 @@ module.exports = function initialize(agent, library, spec) {
92
92
  wrapStaticMethods(library, spec.name, spec.$library)
93
93
 
94
94
  // Wrap prototype methods.
95
- var Promise = library[spec.constructor]
95
+ const Promise = library[spec.constructor]
96
96
  wrapPrototype(Promise.prototype)
97
97
  wrapStaticMethods(Promise, spec.constructor, spec.$static)
98
98
 
@@ -114,7 +114,7 @@ module.exports = function initialize(agent, library, spec) {
114
114
  })
115
115
  }
116
116
 
117
- var passThrough = spec.$static && spec.$static.$passThrough
117
+ const passThrough = spec.$static && spec.$static.$passThrough
118
118
  if (passThrough) {
119
119
  passThrough.forEach(function assignProxy(proxyProp) {
120
120
  if (!properties.hasOwn(wrappedPromise, proxyProp)) {
@@ -144,8 +144,8 @@ module.exports = function initialize(agent, library, spec) {
144
144
  return Promise(executor) // eslint-disable-line new-cap
145
145
  }
146
146
 
147
- var parent = agent.tracer.segment
148
- var promise = null
147
+ const parent = agent.tracer.segment
148
+ let promise = null
149
149
  if (
150
150
  !parent ||
151
151
  !parent.transaction.isActive() ||
@@ -155,19 +155,19 @@ module.exports = function initialize(agent, library, spec) {
155
155
  // We are expecting one function argument for executor, anything else is
156
156
  // non-standard, do not attempt to wrap. Also do not attempt to wrap if we
157
157
  // are not in a transaction.
158
- var cnstrctArgs = agent.tracer.slice(arguments)
158
+ const cnstrctArgs = agent.tracer.slice(arguments)
159
159
  cnstrctArgs.unshift(Promise) // `unshift` === `push_front`
160
160
  promise = new (Promise.bind.apply(Promise, cnstrctArgs))()
161
161
  } else {
162
- var segmentName = 'Promise ' + (executor.name || '<anonymous>')
163
- var context = {
162
+ const segmentName = 'Promise ' + (executor.name || '<anonymous>')
163
+ const context = {
164
164
  promise: null,
165
165
  self: null,
166
166
  args: null
167
167
  }
168
168
  promise = new Promise(wrapExecutorContext(context))
169
169
  context.promise = promise
170
- var segment = _createSegment(segmentName)
170
+ const segment = _createSegment(segmentName)
171
171
  Contextualizer.link(null, promise, segment, spec.useFinally)
172
172
 
173
173
  agent.tracer.segment = segment
@@ -221,24 +221,24 @@ module.exports = function initialize(agent, library, spec) {
221
221
 
222
222
  function wrapExecutorCaller(caller) {
223
223
  return function wrappedExecutorCaller(executor) {
224
- var parent = agent.tracer.getSegment()
224
+ const parent = agent.tracer.getSegment()
225
225
  if (!(this instanceof Promise) || !parent || !parent.transaction.isActive()) {
226
226
  return caller.apply(this, arguments)
227
227
  }
228
228
 
229
- var context = {
229
+ const context = {
230
230
  promise: this,
231
231
  self: null,
232
232
  args: null
233
233
  }
234
234
  if (!this.__NR_context) {
235
- var segmentName = 'Promise ' + executor.name || '<anonymous>'
236
- var segment = _createSegment(segmentName)
235
+ const segmentName = 'Promise ' + executor.name || '<anonymous>'
236
+ const segment = _createSegment(segmentName)
237
237
  Contextualizer.link(null, this, segment, spec.useFinally)
238
238
  }
239
- var args = [].slice.call(arguments)
239
+ const args = [].slice.call(arguments)
240
240
  args[0] = wrapExecutorContext(context, this.__NR_context.getSegment())
241
- var ret = caller.apply(this, args)
241
+ const ret = caller.apply(this, args)
242
242
 
243
243
  // Bluebird catches executor errors and auto-rejects when it catches them,
244
244
  // thus we need to do so as well.
@@ -274,7 +274,7 @@ module.exports = function initialize(agent, library, spec) {
274
274
 
275
275
  function wrapResolver(context, fn) {
276
276
  return function wrappedResolveReject(val) {
277
- var promise = context.promise
277
+ const promise = context.promise
278
278
  if (promise && promise.__NR_context) {
279
279
  promise.__NR_context.getSegment().touch()
280
280
  }
@@ -323,14 +323,14 @@ module.exports = function initialize(agent, library, spec) {
323
323
  return then.apply(this, arguments)
324
324
  }
325
325
 
326
- var segmentNamePrefix = 'Promise#' + name + ' '
327
- var thenSegment = agent.tracer.getSegment()
328
- var promise = this
326
+ const segmentNamePrefix = 'Promise#' + name + ' '
327
+ const thenSegment = agent.tracer.getSegment()
328
+ const promise = this
329
329
 
330
330
  // Wrap up the arguments and execute the real then.
331
- var isWrapped = false
332
- var args = [].map.call(arguments, wrapHandler)
333
- var next = then.apply(this, args)
331
+ let isWrapped = false
332
+ const args = [].map.call(arguments, wrapHandler)
333
+ const next = then.apply(this, args)
334
334
 
335
335
  // If we got a promise (which we should have), link the parent's context.
336
336
  if (!isWrapped && next instanceof Promise && next !== promise) {
@@ -353,15 +353,15 @@ module.exports = function initialize(agent, library, spec) {
353
353
  return fn.apply(this, arguments)
354
354
  }
355
355
 
356
- var promSegment = next.__NR_context.getSegment()
357
- var segmentName = segmentNamePrefix + (fn.name || '<anonymous>')
358
- var segment = _createSegment(segmentName, promSegment)
356
+ let promSegment = next.__NR_context.getSegment()
357
+ const segmentName = segmentNamePrefix + (fn.name || '<anonymous>')
358
+ const segment = _createSegment(segmentName, promSegment)
359
359
  if (segment && segment !== promSegment) {
360
360
  next.__NR_context.setSegment(segment)
361
361
  promSegment = segment
362
362
  }
363
363
 
364
- var ret = null
364
+ let ret = null
365
365
  try {
366
366
  ret = agent.tracer.bindFunction(fn, promSegment, true).apply(this, arguments)
367
367
  } finally {
@@ -383,10 +383,10 @@ module.exports = function initialize(agent, library, spec) {
383
383
  return cast
384
384
  }
385
385
 
386
- var CAST_SEGMENT_NAME = 'Promise.' + name
386
+ const CAST_SEGMENT_NAME = 'Promise.' + name
387
387
  return function __NR_wrappedCast() {
388
- var segment = _createSegment(CAST_SEGMENT_NAME)
389
- var prom = cast.apply(this, arguments)
388
+ const segment = _createSegment(CAST_SEGMENT_NAME)
389
+ const prom = cast.apply(this, arguments)
390
390
  if (segment) {
391
391
  Contextualizer.link(null, prom, segment, spec.useFinally)
392
392
  }
@@ -399,9 +399,9 @@ module.exports = function initialize(agent, library, spec) {
399
399
  return promisify
400
400
  }
401
401
 
402
- var WRAP_SEGMENT_NAME = 'Promise.' + name
402
+ const WRAP_SEGMENT_NAME = 'Promise.' + name
403
403
  return function __NR_wrappedPromisify() {
404
- var promisified = promisify.apply(this, arguments)
404
+ const promisified = promisify.apply(this, arguments)
405
405
  if (typeof promisified !== 'function') {
406
406
  return promisified
407
407
  }
@@ -412,8 +412,8 @@ module.exports = function initialize(agent, library, spec) {
412
412
 
413
413
  return __NR_wrappedPromisified
414
414
  function __NR_wrappedPromisified() {
415
- var segment = _createSegment(WRAP_SEGMENT_NAME)
416
- var prom = agent.tracer.bindFunction(promisified, segment, true).apply(this, arguments)
415
+ const segment = _createSegment(WRAP_SEGMENT_NAME)
416
+ const prom = agent.tracer.bindFunction(promisified, segment, true).apply(this, arguments)
417
417
 
418
418
  if (segment) {
419
419
  Contextualizer.link(null, prom, segment, spec.useFinally)
@@ -466,7 +466,7 @@ function Contextualizer(idx, context, useFinally) {
466
466
  module.exports.Contextualizer = Contextualizer
467
467
 
468
468
  Contextualizer.link = function link(prev, next, segment, useFinally) {
469
- var ctxlzr = prev && prev.__NR_context
469
+ let ctxlzr = prev && prev.__NR_context
470
470
  if (ctxlzr && !ctxlzr.isActive()) {
471
471
  ctxlzr = prev.__NR_context = null
472
472
  }
@@ -489,9 +489,9 @@ Contextualizer.link = function link(prev, next, segment, useFinally) {
489
489
  //
490
490
  // Note: This does not account for branches of branches. That may result
491
491
  // in improperly parented segments.
492
- var parent = ctxlzr
493
- var child = ctxlzr.child
494
- var branchIdx = ctxlzr.context.branch()
492
+ let parent = ctxlzr
493
+ let child = ctxlzr.child
494
+ const branchIdx = ctxlzr.context.branch()
495
495
  do {
496
496
  child.parentIdx = parent.idx
497
497
  child.idx = branchIdx
@@ -507,7 +507,7 @@ Contextualizer.link = function link(prev, next, segment, useFinally) {
507
507
 
508
508
  // If this is a branching link then create a new branch for the next promise.
509
509
  // Otherwise, we can just piggy-back on the previous link's spot.
510
- var idx = ctxlzr.child === false ? ctxlzr.context.branch() : ctxlzr.idx
510
+ const idx = ctxlzr.child === false ? ctxlzr.context.branch() : ctxlzr.idx
511
511
 
512
512
  // Create a new context for this next promise.
513
513
  next.__NR_context = new Contextualizer(idx, ctxlzr.context, ctxlzr.useFinally)
@@ -527,14 +527,14 @@ Contextualizer.link = function link(prev, next, segment, useFinally) {
527
527
  Contextualizer.prototype = Object.create(null)
528
528
 
529
529
  Contextualizer.prototype.isActive = function isActive() {
530
- var segments = this.context.segments
531
- var segment = segments[this.idx] || segments[this.parentIdx] || segments[0]
530
+ const segments = this.context.segments
531
+ const segment = segments[this.idx] || segments[this.parentIdx] || segments[0]
532
532
  return segment && segment.transaction.isActive()
533
533
  }
534
534
 
535
535
  Contextualizer.prototype.getSegment = function getSegment() {
536
- var segments = this.context.segments
537
- var segment = segments[this.idx]
536
+ const segments = this.context.segments
537
+ let segment = segments[this.idx]
538
538
  if (segment == null) {
539
539
  segment = segments[this.idx] = segments[this.parentIdx] || segments[0]
540
540
  }
@@ -550,8 +550,8 @@ Contextualizer.prototype.toJSON = function toJSON() {
550
550
  }
551
551
 
552
552
  Contextualizer.prototype.continue = function continueContext(prom) {
553
- var self = this
554
- var nextContext = prom.__NR_context
553
+ const self = this
554
+ const nextContext = prom.__NR_context
555
555
  if (!nextContext) {
556
556
  return prom
557
557
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var wrap = require('../shimmer').wrapMethod
8
+ const wrap = require('../shimmer').wrapMethod
9
9
 
10
10
  module.exports = initialize
11
11
 
@@ -17,7 +17,7 @@ function initialize(agent, Q) {
17
17
  if (Q.nextTick) {
18
18
  // The wrap() call for nextTick wipes the sub-function. Save a reference
19
19
  // now so it can be restored later
20
- var savedRunAfter = Q.nextTick.runAfter
20
+ const savedRunAfter = Q.nextTick.runAfter
21
21
 
22
22
  wrap(Q, 'Q', 'nextTick', wrapUninstrumented)
23
23
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var hasOwnProperty = require('../util/properties').hasOwn
9
- var stringify = require('json-stringify-safe')
8
+ const hasOwnProperty = require('../util/properties').hasOwn
9
+ const stringify = require('json-stringify-safe')
10
10
 
11
11
  module.exports = function initialize(agent, redis, moduleName, shim) {
12
- var proto = redis && redis.RedisClient && redis.RedisClient.prototype
12
+ const proto = redis && redis.RedisClient && redis.RedisClient.prototype
13
13
  if (!proto) {
14
14
  return false
15
15
  }
@@ -20,9 +20,9 @@ module.exports = function initialize(agent, redis, moduleName, shim) {
20
20
  proto,
21
21
  'internal_send_command',
22
22
  function wrapInternalSendCommand(shim, _, __, args) {
23
- var commandObject = args[0]
24
- var keys = commandObject.args
25
- var parameters = getInstanceParameters(this)
23
+ const commandObject = args[0]
24
+ const keys = commandObject.args
25
+ const parameters = getInstanceParameters(this)
26
26
 
27
27
  if (keys && keys.length > 0) {
28
28
  try {
@@ -40,7 +40,7 @@ module.exports = function initialize(agent, redis, moduleName, shim) {
40
40
  if (shim.isFunction(commandObject.callback)) {
41
41
  shim.bindCallbackSegment(commandObject, 'callback', segment)
42
42
  } else {
43
- var self = this
43
+ const self = this
44
44
  commandObject.callback = shim.bindSegment(
45
45
  function NRCallback(err) {
46
46
  if (err && self.emit instanceof Function) {
@@ -58,8 +58,8 @@ module.exports = function initialize(agent, redis, moduleName, shim) {
58
58
  } else {
59
59
  // For redis versions <2.6.1
60
60
  shim.recordOperation(proto, 'send_command', function wrapSendCommand(shim, _, __, args) {
61
- var keys = args[1]
62
- var parameters = getInstanceParameters(this)
61
+ const keys = args[1]
62
+ const parameters = getInstanceParameters(this)
63
63
 
64
64
  if (keys && !shim.isFunction(keys)) {
65
65
  try {
@@ -74,7 +74,7 @@ module.exports = function initialize(agent, redis, moduleName, shim) {
74
74
  name: args[0] || 'other',
75
75
  parameters: parameters,
76
76
  callback: function bindCallback(shim, _f, _n, segment) {
77
- var last = args[args.length - 1]
77
+ const last = args[args.length - 1]
78
78
  if (shim.isFunction(last)) {
79
79
  shim.bindCallbackSegment(args, shim.LAST, segment)
80
80
  } else if (shim.isArray(last) && shim.isFunction(last[last.length - 1])) {
@@ -108,7 +108,7 @@ module.exports = function initialize(agent, redis, moduleName, shim) {
108
108
  }
109
109
 
110
110
  function doCapture(opts) {
111
- var db = (hasOwnProperty(client, 'selected_db') ? client.selected_db : opts.db) || 0
111
+ const db = (hasOwnProperty(client, 'selected_db') ? client.selected_db : opts.db) || 0
112
112
 
113
113
  return {
114
114
  host: opts.host || 'localhost',
@@ -47,7 +47,7 @@ module.exports = function initialize(agent, restify, moduleName, shim) {
47
47
 
48
48
  function wrapServer(serverProto) {
49
49
  // These are all the methods for mounting routed middleware.
50
- var routings = ['del', 'get', 'head', 'opts', 'post', 'put', 'patch']
50
+ const routings = ['del', 'get', 'head', 'opts', 'post', 'put', 'patch']
51
51
  shim.wrapMiddlewareMounter(serverProto, routings, {
52
52
  route: shim.FIRST,
53
53
  endpoint: shim.LAST,
@@ -5,10 +5,10 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var semver = require('semver')
8
+ const semver = require('semver')
9
9
 
10
10
  module.exports = function initialize(agent, vision, moduleName, shim) {
11
- var plugin = vision.plugin
11
+ const plugin = vision.plugin
12
12
 
13
13
  if (!plugin || !plugin.pkg || semver.lt(plugin.pkg.version, '5.0.0')) {
14
14
  shim.logger.debug('Vision instrumentation requires v5 or greater, not instrumenting')
@@ -22,7 +22,7 @@ module.exports = function initialize(agent, vision, moduleName, shim) {
22
22
  return function wrappedRegister(server) {
23
23
  shim.wrap(server, 'decorate', wrapDecorate)
24
24
 
25
- var ret = register.apply(this, arguments)
25
+ const ret = register.apply(this, arguments)
26
26
 
27
27
  shim.unwrapOnce(server, 'decorate')
28
28
 
@@ -37,7 +37,7 @@ function wrapDecorate(shim, decorate) {
37
37
  return decorate.apply(this, arguments)
38
38
  }
39
39
 
40
- var args = shim.argsToArray.apply(shim, arguments)
40
+ const args = shim.argsToArray.apply(shim, arguments)
41
41
  args[2] = shim.recordRender(handler, { promise: true })
42
42
 
43
43
  return decorate.apply(this, args)
@@ -5,9 +5,9 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var promInit = require('./promise')
8
+ const promInit = require('./promise')
9
9
 
10
- var STATIC_PROMISE_METHODS = [
10
+ const STATIC_PROMISE_METHODS = [
11
11
  'reject',
12
12
  'resolve',
13
13
  'all',
@@ -19,7 +19,7 @@ var STATIC_PROMISE_METHODS = [
19
19
  'reduceRight'
20
20
  ]
21
21
 
22
- var WHEN_SPEC = {
22
+ const WHEN_SPEC = {
23
23
  name: 'when',
24
24
  constructor: 'Promise',
25
25
  executor: true,
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var MODULE_TYPE = require('./shim/constants').MODULE_TYPE
8
+ const MODULE_TYPE = require('./shim/constants').MODULE_TYPE
9
9
 
10
10
  // Return a new copy of this array every time we're called
11
11
  module.exports = function instrumentations() {
package/lib/logger.js CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var Logger = require('./util/logger')
9
- var fs = require('./util/unwrapped-core').fs
8
+ const Logger = require('./util/logger')
9
+ const fs = require('./util/unwrapped-core').fs
10
10
 
11
11
  // create bootstrapping logger
12
12
  module.exports = new Logger({
@@ -20,9 +20,9 @@ module.exports = new Logger({
20
20
  * module, and if it gets loaded too early, module.exports will have no
21
21
  * value.
22
22
  */
23
- var config = require('./config').getOrCreateInstance()
23
+ const config = require('./config').getOrCreateInstance()
24
24
  if (config) {
25
- var options = {
25
+ const options = {
26
26
  name: 'newrelic',
27
27
  level: config.logging.level,
28
28
  enabled: config.logging.enabled
@@ -32,7 +32,7 @@ if (config) {
32
32
  module.exports = new Logger(options)
33
33
 
34
34
  if (config.logging.enabled) {
35
- var stream
35
+ let stream
36
36
  switch (config.logging.filepath) {
37
37
  case 'stdout':
38
38
  stream = process.stdout
@@ -82,7 +82,7 @@ function Metrics(apdexT, mapper, normalizer) {
82
82
  Metrics.prototype.measureMilliseconds = measureMilliseconds
83
83
 
84
84
  function measureMilliseconds(name, scope, duration, exclusive) {
85
- var stats = this.getOrCreateMetric(name, scope)
85
+ const stats = this.getOrCreateMetric(name, scope)
86
86
  stats.recordValueInMillis(duration, exclusive)
87
87
  return stats
88
88
  }
@@ -96,7 +96,7 @@ function measureMilliseconds(name, scope, duration, exclusive) {
96
96
  * @return {Stats} The aggregated data related to this metric.
97
97
  */
98
98
  Metrics.prototype.measureBytes = function measureBytes(name, size) {
99
- var stats = this.getOrCreateMetric(name)
99
+ const stats = this.getOrCreateMetric(name)
100
100
  stats.recordValueInBytes(size)
101
101
  return stats
102
102
  }
@@ -110,8 +110,8 @@ Metrics.prototype.measureBytes = function measureBytes(name, size) {
110
110
  * @return {Stats} The aggregated data for that name.
111
111
  */
112
112
  Metrics.prototype.getOrCreateMetric = function getOrCreateMetric(name, scope) {
113
- var resolved = this._resolve(scope)
114
- var stats = resolved[name]
113
+ const resolved = this._resolve(scope)
114
+ let stats = resolved[name]
115
115
  if (!stats) {
116
116
  this.empty = false
117
117
  stats = resolved[name] = new Stats()
@@ -141,14 +141,14 @@ function getOrCreateApdexMetric(name, scope, overrideApdex) {
141
141
  throw new Error('Metrics must be named')
142
142
  }
143
143
 
144
- var resolved = this._resolve(scope)
144
+ const resolved = this._resolve(scope)
145
145
 
146
146
  if (!resolved[name]) {
147
147
  this.empty = false
148
148
 
149
149
  // Only use the given override to create the metric if this is not the
150
150
  // global apdex AND we have a valid value.
151
- var apdexT =
151
+ const apdexT =
152
152
  name !== NAMES.APDEX && overrideApdex > 0 ? overrideApdex * FROM_MILLIS : this.apdexT
153
153
  resolved[name] = new ApdexStats(apdexT)
154
154
  }
@@ -209,12 +209,12 @@ Metrics.prototype.merge = function merge(other, adjustStartTime) {
209
209
  // Loop through all scopes and merge them. Since we know `.scoped` has a `null`
210
210
  // prototype we don't need to worry about own property checks.
211
211
  // eslint-disable-next-line guard-for-in
212
- for (var scope in other.scoped) {
212
+ for (const scope in other.scoped) {
213
213
  _merge(this._resolve(scope), other.scoped[scope])
214
214
  }
215
215
  }
216
216
  function _merge(a, b) {
217
- for (var name in b) {
217
+ for (const name in b) {
218
218
  if (a[name]) {
219
219
  a[name].merge(b[name])
220
220
  } else {
@@ -232,7 +232,7 @@ function _merge(a, b) {
232
232
  * un-scoped metrics if the scope isn't set.
233
233
  */
234
234
  Metrics.prototype._resolve = function _resolve(scope) {
235
- var resolved = this.unscoped
235
+ let resolved = this.unscoped
236
236
 
237
237
  if (scope) {
238
238
  resolved = this.scoped[scope]
@@ -255,7 +255,7 @@ Metrics.prototype._getUnscopedData = function _getUnscopedData(name) {
255
255
  return
256
256
  }
257
257
 
258
- var normalized = this.normalizer.normalize(name)
258
+ const normalized = this.normalizer.normalize(name)
259
259
  if (normalized.ignore || !normalized.value) {
260
260
  return
261
261
  }
@@ -274,7 +274,7 @@ Metrics.prototype._getScopedData = function _getScopedData(name, scope) {
274
274
  return
275
275
  }
276
276
 
277
- var normalized = this.normalizer.normalize(name)
277
+ const normalized = this.normalizer.normalize(name)
278
278
  if (normalized.ignore || !normalized.value) {
279
279
  return
280
280
  }
@@ -287,10 +287,10 @@ Metrics.prototype._getScopedData = function _getScopedData(name, scope) {
287
287
  * for use by toJSON.
288
288
  */
289
289
  Metrics.prototype._toUnscopedData = function _toUnscopedData() {
290
- var metricData = []
290
+ const metricData = []
291
291
 
292
292
  Object.keys(this.unscoped).forEach((name) => {
293
- var data = this._getUnscopedData(name)
293
+ const data = this._getUnscopedData(name)
294
294
  if (data) {
295
295
  metricData.push(data)
296
296
  }
@@ -304,11 +304,11 @@ Metrics.prototype._toUnscopedData = function _toUnscopedData() {
304
304
  * use by toJSON.
305
305
  */
306
306
  Metrics.prototype._toScopedData = function _toScopedData() {
307
- var metricData = []
307
+ const metricData = []
308
308
 
309
309
  Object.keys(this.scoped).forEach(function forEachScope(scope) {
310
310
  Object.keys(this.scoped[scope]).forEach(function forEachMetric(name) {
311
- var data = this._getScopedData(name, scope)
311
+ const data = this._getScopedData(name, scope)
312
312
  if (data) {
313
313
  metricData.push(data)
314
314
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var logger = require('../logger').child({ component: 'mapper' })
8
+ const logger = require('../logger').child({ component: 'mapper' })
9
9
 
10
10
  /**
11
11
  * To tighten up the metrics JSON, the collector will maintain a list of
@@ -41,12 +41,12 @@ MetricMapper.prototype.load = function load(raw) {
41
41
  return
42
42
  }
43
43
 
44
- for (var i = 0; i < raw.length; i++) {
45
- var spec = raw[i][0]
46
- var scope = spec.scope
47
- var name = spec.name
48
- var id = raw[i][1]
49
- var resolved
44
+ for (let i = 0; i < raw.length; i++) {
45
+ const spec = raw[i][0]
46
+ const scope = spec.scope
47
+ const name = spec.name
48
+ const id = raw[i][1]
49
+ let resolved
50
50
 
51
51
  if (scope) {
52
52
  if (!this.scoped[scope]) {
@@ -5,12 +5,12 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var logger = require('../../logger').child({ component: 'normalizer_rule' })
8
+ const logger = require('../../logger').child({ component: 'normalizer_rule' })
9
9
 
10
10
  /**
11
11
  * JavaScript just has to do things slightly differently.
12
12
  */
13
- var replaceReplacer = function replaceReplacer(input) {
13
+ const replaceReplacer = function replaceReplacer(input) {
14
14
  return input.replace(/\\/g, '$')
15
15
  }
16
16
 
@@ -37,7 +37,7 @@ function NormalizerRule(json) {
37
37
  this.ignore = json.ignore || false
38
38
  this.matched = false
39
39
 
40
- var modifiers = 'i'
40
+ let modifiers = 'i'
41
41
  if (this.replaceAll) {
42
42
  modifiers += 'g'
43
43
  }
@@ -78,9 +78,9 @@ NormalizerRule.prototype.getSegments = function getSegments(input) {
78
78
  * @return {bool} - True if this rule matches the given input, otherwise false.
79
79
  */
80
80
  NormalizerRule.prototype.matches = function matches(input) {
81
- var segments = this.getSegments(input)
81
+ const segments = this.getSegments(input)
82
82
 
83
- for (var i = 0; i < segments.length; ++i) {
83
+ for (let i = 0; i < segments.length; ++i) {
84
84
  if (this.pattern.test(segments[i])) {
85
85
  return true
86
86
  }
@@ -118,7 +118,7 @@ NormalizerRule.prototype.apply = function apply(input) {
118
118
  }
119
119
 
120
120
  this.matched = false
121
- var result = this.getSegments(input)
121
+ const result = this.getSegments(input)
122
122
  .map(function applyMap(segment) {
123
123
  // Discussion of why we use `lastIndex` in function documentation to
124
124
  // prevent de-opt due to long function.
@@ -154,9 +154,9 @@ NormalizerRule.prototype.toJSON = function toJSON() {
154
154
  * @return {RegExp} - A regular expression with all the given flags added.
155
155
  */
156
156
  function _addRegExpFlags(re, flags) {
157
- var foundMissing = false
158
- var reFlags = re.flags
159
- for (var i = 0; i < flags.length; ++i) {
157
+ let foundMissing = false
158
+ let reFlags = re.flags
159
+ for (let i = 0; i < flags.length; ++i) {
160
160
  if (reFlags.indexOf(flags[i]) === -1) {
161
161
  foundMissing = true
162
162
  reFlags += flags[i]