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
@@ -137,8 +137,8 @@ TraceSegment.prototype.getSpanId = function getSpanId() {
137
137
  TraceSegment.prototype.captureDBInstanceAttributes = captureDBInstanceAttributes
138
138
 
139
139
  function captureDBInstanceAttributes(host, port, database) {
140
- var config = this.transaction.agent.config
141
- var dsTracerConf = config.datastore_tracer
140
+ const config = this.transaction.agent.config
141
+ const dsTracerConf = config.datastore_tracer
142
142
 
143
143
  // Add database name if provided and enabled.
144
144
  if (database !== false && dsTracerConf.database_name_reporting.enabled) {
@@ -185,7 +185,7 @@ TraceSegment.prototype.probe = function probe(action) {
185
185
  * the end).
186
186
  */
187
187
  TraceSegment.prototype.setNameFromTransaction = function setNameFromTransaction() {
188
- var transaction = this.transaction
188
+ const transaction = this.transaction
189
189
 
190
190
  // transaction name and transaciton segment name must match
191
191
  this.name = transaction.getFullName()
@@ -203,10 +203,10 @@ TraceSegment.prototype.setNameFromTransaction = function setNameFromTransaction(
203
203
  * segment's parameters onto the transaction.
204
204
  */
205
205
  TraceSegment.prototype.markAsWeb = function markAsWeb() {
206
- var transaction = this.transaction
206
+ const transaction = this.transaction
207
207
  this.setNameFromTransaction()
208
208
 
209
- var traceAttrs = transaction.trace.attributes.get(DESTINATIONS.TRANS_TRACE)
209
+ const traceAttrs = transaction.trace.attributes.get(DESTINATIONS.TRANS_TRACE)
210
210
  Object.keys(traceAttrs).forEach((key) => {
211
211
  if (!this.attributes.has(key)) {
212
212
  this.addAttribute(key, traceAttrs[key])
@@ -262,9 +262,9 @@ TraceSegment.prototype.finalize = function finalize() {
262
262
  * in time.
263
263
  */
264
264
  TraceSegment.prototype._updateRootTimer = function _updateRootTimer() {
265
- var root = this.transaction.trace.root
265
+ const root = this.transaction.trace.root
266
266
  if (this.timer.endsAfter(root.timer)) {
267
- var newDuration = this.timer.start + this.getDurationInMillis() - root.timer.start
267
+ const newDuration = this.timer.start + this.getDurationInMillis() - root.timer.start
268
268
  root.overwriteDurationInMillis(newDuration)
269
269
  }
270
270
  }
@@ -290,8 +290,8 @@ TraceSegment.prototype.add = function add(childName, recorder) {
290
290
  return this
291
291
  }
292
292
  logger.trace('Adding segment %s to %s in %s', childName, this.name, this.transaction.id)
293
- var segment = new TraceSegment(this.transaction, childName, recorder)
294
- var config = this.transaction.agent.config
293
+ const segment = new TraceSegment(this.transaction, childName, recorder)
294
+ const config = this.transaction.agent.config
295
295
 
296
296
  if (this.transaction.trace.segmentsSeen++ >= config.max_trace_segments) {
297
297
  segment._collect = false
@@ -350,8 +350,8 @@ function getExclusiveDurationInMillis() {
350
350
  }
351
351
 
352
352
  TraceSegment.prototype.getChildren = function getChildren() {
353
- var children = []
354
- for (var i = 0, len = this.children.length; i < len; ++i) {
353
+ const children = []
354
+ for (let i = 0, len = this.children.length; i < len; ++i) {
355
355
  if (!this.children[i].ignore) {
356
356
  children.push(this.children[i])
357
357
  }
@@ -360,8 +360,8 @@ TraceSegment.prototype.getChildren = function getChildren() {
360
360
  }
361
361
 
362
362
  TraceSegment.prototype.getCollectedChildren = function getCollectedChildren() {
363
- var children = []
364
- for (var i = 0, len = this.children.length; i < len; ++i) {
363
+ const children = []
364
+ for (let i = 0, len = this.children.length; i < len; ++i) {
365
365
  if (this.children[i]._collect && !this.children[i].ignore) {
366
366
  children.push(this.children[i])
367
367
  }
@@ -388,11 +388,11 @@ TraceSegment.prototype._getChildPairs = function _getChildPairs(end) {
388
388
  end = Infinity
389
389
  }
390
390
 
391
- var children = this.getChildren()
392
- var childPairs = []
391
+ let children = this.getChildren()
392
+ const childPairs = []
393
393
  while (children.length) {
394
- var child = children.pop()
395
- var pair = child.timer.toRange()
394
+ const child = children.pop()
395
+ const pair = child.timer.toRange()
396
396
 
397
397
  if (pair[0] >= end) {
398
398
  continue
@@ -460,7 +460,7 @@ TraceSegment.prototype.toJSON = function toJSON() {
460
460
  // push the children and the parent's children array into the stack.
461
461
  // to preserve the chronological order of the children, push them
462
462
  // onto the stack backwards (so the first one created is on top).
463
- for (var i = segmentChildren.length - 1; i >= 0; --i) {
463
+ for (let i = segmentChildren.length - 1; i >= 0; --i) {
464
464
  segmentsToProcess.push({
465
465
  segment: segmentChildren[i],
466
466
  destination: childArray
@@ -375,7 +375,7 @@ class TraceContext {
375
375
  * instrinsics on any relevant New Relic tracestate strings found
376
376
  */
377
377
  _validateAndParseTraceStateHeader(tracestate) {
378
- let tsd = {
378
+ const tsd = {
379
379
  entryFound: false,
380
380
  entryValid: undefined,
381
381
  entryInvalidReason: undefined,
@@ -5,14 +5,14 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var Transaction = require('../index.js')
9
- var logger = require('../../logger').child({ component: 'tracer' })
8
+ const Transaction = require('../index.js')
9
+ const logger = require('../../logger').child({ component: 'tracer' })
10
10
 
11
11
  /*
12
12
  * CONSTANTS
13
13
  */
14
- var ORIGINAL = '__NR_original'
15
- var SEGMENT = '__NR_segment'
14
+ const ORIGINAL = '__NR_original'
15
+ const SEGMENT = '__NR_segment'
16
16
 
17
17
  module.exports = Tracer
18
18
 
@@ -73,7 +73,7 @@ function getSpanContext() {
73
73
  }
74
74
 
75
75
  function createSegment(name, recorder, _parent) {
76
- var parent = _parent || this.segment
76
+ const parent = _parent || this.segment
77
77
  if (!parent || !parent.transaction.isActive()) {
78
78
  logger.trace(
79
79
  {
@@ -93,7 +93,7 @@ function addSegment(name, recorder, parent, full, task) {
93
93
  throw new Error('task must be a function')
94
94
  }
95
95
 
96
- var segment = this.createSegment(name, recorder, parent)
96
+ const segment = this.createSegment(name, recorder, parent)
97
97
 
98
98
  return this.bindFunction(task, segment, full)(segment)
99
99
  }
@@ -104,14 +104,14 @@ function transactionProxy(handler) {
104
104
  return handler
105
105
  }
106
106
 
107
- var tracer = this
108
- var wrapped = function wrapTransactionInvocation() {
107
+ const tracer = this
108
+ const wrapped = function wrapTransactionInvocation() {
109
109
  if (!tracer.agent.canCollectData()) {
110
110
  return handler.apply(this, arguments)
111
111
  }
112
112
 
113
113
  // don't nest transactions, reuse existing ones
114
- var segment = tracer.segment
114
+ const segment = tracer.segment
115
115
  if (segment) {
116
116
  if (segment.transaction.traceStacks) {
117
117
  segment.probe('!!! Nested transaction creation !!!')
@@ -127,7 +127,7 @@ function transactionProxy(handler) {
127
127
  tracer.agent.recordSupportability('Nodejs/Transactions/Nested')
128
128
  return handler.apply(this, arguments)
129
129
  }
130
- var transaction = new Transaction(tracer.agent)
130
+ const transaction = new Transaction(tracer.agent)
131
131
  return tracer.bindFunction(handler, transaction.trace.root, true).apply(this, arguments)
132
132
  }
133
133
 
@@ -157,17 +157,17 @@ function transactionNestProxy(type, handler) {
157
157
  return handler
158
158
  }
159
159
 
160
- var tracer = this
161
- var wrapped = function wrapTransactionInvocation() {
160
+ const tracer = this
161
+ const wrapped = function wrapTransactionInvocation() {
162
162
  if (!tracer.agent.canCollectData()) {
163
163
  return handler.apply(this, arguments)
164
164
  }
165
165
 
166
166
  // don't nest transactions, reuse existing ones
167
- var transaction = tracer.getTransaction()
168
- var segment = tracer.segment
167
+ let transaction = tracer.getTransaction()
168
+ let segment = tracer.segment
169
169
 
170
- var createNew = false
170
+ let createNew = false
171
171
 
172
172
  if (!transaction || transaction.type !== type) {
173
173
  createNew = true
@@ -201,7 +201,7 @@ function _makeWrapped(tracer, handler, active, full) {
201
201
  return wrapped
202
202
 
203
203
  function wrapped() {
204
- var prev = tracer.segment
204
+ const prev = tracer.segment
205
205
  tracer.segment = active
206
206
  if (active && full) {
207
207
  active.start()
@@ -238,7 +238,7 @@ function bindEmitter(emitter, segment) {
238
238
  return emitter
239
239
  }
240
240
 
241
- var emit = getOriginal(emitter.emit)
241
+ const emit = getOriginal(emitter.emit)
242
242
  emitter.emit = this.bindFunction(emit, segment)
243
243
 
244
244
  return emitter
@@ -260,10 +260,10 @@ function argSlice(args) {
260
260
  * inlining.
261
261
  *
262
262
  */
263
- var length = args.length
264
- var array = new Array(length)
263
+ const length = args.length
264
+ const array = new Array(length)
265
265
 
266
- for (var i = 0; i < length; i++) {
266
+ for (let i = 0; i < length; i++) {
267
267
  array[i] = args[i]
268
268
  }
269
269
 
@@ -276,7 +276,7 @@ function wrapFunctionNoSegment(original, name, wrapper) {
276
276
  }
277
277
 
278
278
  logger.trace('Wrapping function %s (no segment)', name || original.name || 'anonymous')
279
- var tracer = this
279
+ const tracer = this
280
280
 
281
281
  return wrappedFunction
282
282
 
@@ -284,11 +284,11 @@ function wrapFunctionNoSegment(original, name, wrapper) {
284
284
  if (!tracer.getTransaction()) {
285
285
  return original.apply(this, arguments)
286
286
  }
287
- var args = tracer.slice(arguments)
287
+ let args = tracer.slice(arguments)
288
288
 
289
289
  if (wrapper === undefined) {
290
- var last = args.length - 1
291
- var cb = args[last]
290
+ const last = args.length - 1
291
+ const cb = args[last]
292
292
  if (typeof cb === 'function') {
293
293
  args[last] = tracer.bindFunction(cb)
294
294
  }
@@ -305,7 +305,7 @@ function wrapFunctionFirstNoSegment(original, name) {
305
305
  }
306
306
 
307
307
  logger.trace('Wrapping function %s (no segment)', name || original.name || 'anonymous')
308
- var tracer = this
308
+ const tracer = this
309
309
 
310
310
  return wrappedFunction
311
311
 
@@ -313,8 +313,8 @@ function wrapFunctionFirstNoSegment(original, name) {
313
313
  if (!tracer.getTransaction()) {
314
314
  return original.apply(this, arguments)
315
315
  }
316
- var args = tracer.slice(arguments)
317
- var cb = args[0]
316
+ const args = tracer.slice(arguments)
317
+ const cb = args[0]
318
318
  if (typeof cb === 'function') {
319
319
  args[0] = tracer.bindFunction(cb)
320
320
  }
@@ -329,25 +329,25 @@ function wrapFunctionLast(name, recorder, original) {
329
329
  }
330
330
 
331
331
  logger.trace('Wrapping %s as a callback-last function', name)
332
- var tracer = this
332
+ const tracer = this
333
333
 
334
334
  return wrappedFunction
335
335
 
336
336
  function wrappedFunction() {
337
- var transaction = tracer.getTransaction()
337
+ const transaction = tracer.getTransaction()
338
338
  if (!transaction) {
339
339
  logger.trace('Not creating segment "%s" because no transaction was active', name)
340
340
  return original.apply(this, arguments)
341
341
  }
342
342
 
343
343
  logger.trace('Creating "%s" segment for transaction %s.', name, transaction.id)
344
- var args = tracer.slice(arguments)
345
- var last = args.length - 1
346
- var cb = args[last]
344
+ const args = tracer.slice(arguments)
345
+ const last = args.length - 1
346
+ const cb = args[last]
347
347
  if (typeof cb !== 'function') {
348
348
  return original.apply(this, arguments)
349
349
  }
350
- var child = tracer.createSegment(name, recorder)
350
+ const child = tracer.createSegment(name, recorder)
351
351
  args[last] = tracer.wrapCallback(cb, child, wrappedCallback)
352
352
  child.start()
353
353
  return tracer.bindFunction(original, child).apply(this, args)
@@ -367,24 +367,24 @@ function wrapFunctionFirst(name, recorder, original) {
367
367
  }
368
368
 
369
369
  logger.trace('Wrapping %s as a callback-first function', name)
370
- var tracer = this
370
+ const tracer = this
371
371
 
372
372
  return wrappedFunction
373
373
 
374
374
  function wrappedFunction() {
375
- var transaction = tracer.getTransaction()
375
+ const transaction = tracer.getTransaction()
376
376
  if (!transaction) {
377
377
  logger.trace('Not creating segment "%s" because no transaction was active', name)
378
378
  return original.apply(this, arguments)
379
379
  }
380
380
 
381
381
  logger.trace('Creating "%s" segment for transaction %s.', name, transaction.id)
382
- var args = tracer.slice(arguments)
383
- var cb = args[0]
382
+ const args = tracer.slice(arguments)
383
+ const cb = args[0]
384
384
  if (typeof cb !== 'function') {
385
385
  return original.apply(this, arguments)
386
386
  }
387
- var child = tracer.createSegment(name, recorder)
387
+ const child = tracer.createSegment(name, recorder)
388
388
  args[0] = tracer.wrapCallback(cb, child, wrappedCallback)
389
389
  child.start()
390
390
  return tracer.bindFunction(original, child).apply(this, args)
@@ -392,7 +392,7 @@ function wrapFunctionFirst(name, recorder, original) {
392
392
  function wrappedCallback() {
393
393
  logger.trace('Ending "%s" segment for transaction %s.', name, transaction.id)
394
394
  child.touch()
395
- var result = cb.apply(this, arguments)
395
+ const result = cb.apply(this, arguments)
396
396
  return result
397
397
  }
398
398
  }
@@ -406,12 +406,12 @@ function wrapFunction(name, recorder, original, wrapper, resp) {
406
406
 
407
407
  logger.trace('Wrapping %s using a custom wrapper', name)
408
408
 
409
- var tracer = this
409
+ const tracer = this
410
410
 
411
411
  return wrappedFunction
412
412
 
413
413
  function wrappedFunction() {
414
- var transaction = tracer.getTransaction()
414
+ const transaction = tracer.getTransaction()
415
415
  if (!transaction) {
416
416
  logger.trace('Not creating segment "%s" because no transaction was active', name)
417
417
  return original.apply(this, arguments)
@@ -419,10 +419,10 @@ function wrapFunction(name, recorder, original, wrapper, resp) {
419
419
 
420
420
  logger.trace('Creating "%s" segment for transaction %s.', name, transaction.id)
421
421
 
422
- var child = tracer.createSegment(name, recorder)
423
- var args = wrapper.call(this, child, tracer.slice(arguments), bind)
422
+ const child = tracer.createSegment(name, recorder)
423
+ const args = wrapper.call(this, child, tracer.slice(arguments), bind)
424
424
  child.start()
425
- var result = tracer.bindFunction(original, child).apply(this, args)
425
+ let result = tracer.bindFunction(original, child).apply(this, args)
426
426
  if (resp) {
427
427
  result = resp.call(this, child, result, bind)
428
428
  }
@@ -449,18 +449,18 @@ function wrapSyncFunction(name, recorder, original) {
449
449
 
450
450
  logger.trace('Wrapping "%s" as a synchronous function', name)
451
451
 
452
- var tracer = this
452
+ const tracer = this
453
453
 
454
454
  return wrappedFunction
455
455
 
456
456
  function wrappedFunction() {
457
- var transaction = tracer.getTransaction()
457
+ const transaction = tracer.getTransaction()
458
458
  if (!transaction) {
459
459
  logger.trace('Not creating segment "%s" because no transaction was active', name)
460
460
  return original.apply(this, arguments)
461
461
  }
462
462
  logger.trace('Creating "%s" sync segment for transaction %s.', name, transaction.id)
463
- var child = tracer.createSegment(name, recorder)
463
+ const child = tracer.createSegment(name, recorder)
464
464
  if (child) {
465
465
  child.async = false
466
466
  }
@@ -469,7 +469,7 @@ function wrapSyncFunction(name, recorder, original) {
469
469
  }
470
470
 
471
471
  function wrapCallback(original, segment, wrapped) {
472
- var tracer = this
472
+ const tracer = this
473
473
 
474
474
  if (typeof original !== 'function') {
475
475
  return original
@@ -483,7 +483,11 @@ function wrapCallback(original, segment, wrapped) {
483
483
  wrapped[ORIGINAL] = original
484
484
  }
485
485
 
486
- var child = tracer.createSegment('Callback: ' + (original.name || 'anonymous'), null, segment)
486
+ const child = tracer.createSegment(
487
+ 'Callback: ' + (original.name || 'anonymous'),
488
+ null,
489
+ segment
490
+ )
487
491
 
488
492
  if (child) {
489
493
  child.async = false
@@ -5,20 +5,20 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var path = require('path')
9
- var logger = require('./logger')
10
- var NAMES = require('./metrics/names')
11
- var properties = require('./util/properties')
8
+ const path = require('path')
9
+ const logger = require('./logger')
10
+ const NAMES = require('./metrics/names')
11
+ const properties = require('./util/properties')
12
12
  const shimmer = require('./shimmer')
13
13
 
14
14
  // Static variable holding map of un-instrumented modules for use in the future
15
- var uninstrumented = Object.create(null)
15
+ const uninstrumented = Object.create(null)
16
16
 
17
17
  // Log a helpful message about un-instrumented modules
18
18
  function logUninstrumented() {
19
19
  const modules = Object.keys(uninstrumented)
20
20
  if (modules.length > 0) {
21
- var message =
21
+ let message =
22
22
  'The newrelic module must be the first module required.\n' +
23
23
  'The following modules were required before newrelic and are not being ' +
24
24
  'instrumented:'
@@ -57,7 +57,7 @@ function check() {
57
57
  // and mysql2 work.
58
58
  instrumentations.push('pg.js', 'mysql2')
59
59
 
60
- for (var filename in require.cache) {
60
+ for (const filename in require.cache) {
61
61
  if (!properties.hasOwn(require.cache, filename)) {
62
62
  continue
63
63
  }
package/lib/util/arity.js CHANGED
@@ -5,14 +5,14 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var hasOwnProperty = require('./properties').hasOwn
8
+ const hasOwnProperty = require('./properties').hasOwn
9
9
 
10
10
  // Starting in what we believe to be Node v4 you can set the name and length of
11
11
  // a function as properties. This is more ideal than wrapping a function.
12
12
  exports.fixArity = fixArity
13
13
 
14
14
  function fixArity(original, wrapper) {
15
- var toDefine = {
15
+ const toDefine = {
16
16
  name: { value: original.name },
17
17
  length: { value: original.length }
18
18
  }
@@ -48,16 +48,16 @@ function truncate(val, limit) {
48
48
  // Our limitation is on byte length, and the string could contain multi-byte
49
49
  // characters. Doing a byte-substring could chop a character in half. Instead
50
50
  // we do a binary search over the byte length of the substrings.
51
- var substrLen = val.length
52
- var delta = Math.ceil(substrLen / 2)
53
- var cmpVal = compareLength(val.substring(0, substrLen), limit)
51
+ let substrLen = val.length
52
+ let delta = Math.ceil(substrLen / 2)
53
+ let cmpVal = compareLength(val.substring(0, substrLen), limit)
54
54
 
55
55
  // Continue the binary search till:
56
56
  // 1) The string is the desired length (i.e. cmpVal = 0) OR
57
57
  // 2) The desired string must split a character to achieve the desired byte length
58
58
  // In this case, we should cut the character that would be split.
59
59
  // (i.e. delta > 1 character OR the string is larger than the limit)
60
- var substr
60
+ let substr
61
61
  while (cmpVal && (cmpVal > 0 || delta > 1)) {
62
62
  substrLen = cmpVal < 0 ? substrLen + delta : substrLen - delta
63
63
  substr = val.substring(0, substrLen)