newrelic 8.0.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 (173) hide show
  1. package/NEWS.md +5023 -4922
  2. package/THIRD_PARTY_NOTICES.md +618 -209
  3. package/api.js +156 -219
  4. package/bin/test-naming-rules.js +57 -51
  5. package/bin/tracetractor +0 -1
  6. package/index.js +7 -14
  7. package/lib/agent.js +111 -114
  8. package/lib/aggregators/base-aggregator.js +1 -1
  9. package/lib/aggregators/event-aggregator.js +6 -6
  10. package/lib/attributes.js +13 -14
  11. package/lib/collector/api.js +44 -54
  12. package/lib/collector/facts.js +68 -66
  13. package/lib/collector/http-agents.js +36 -32
  14. package/lib/collector/key-parser.js +1 -1
  15. package/lib/collector/parse-response.js +1 -2
  16. package/lib/collector/remote-method.js +69 -61
  17. package/lib/collector/serverless.js +13 -18
  18. package/lib/collector/ssl/certificates.js +1056 -1056
  19. package/lib/config/attribute-filter.js +109 -101
  20. package/lib/config/default.js +35 -21
  21. package/lib/config/env.js +17 -12
  22. package/lib/config/harvest-config-validator.js +1 -1
  23. package/lib/config/hsm.js +1 -1
  24. package/lib/config/index.js +240 -234
  25. package/lib/config/lasp.js +3 -3
  26. package/lib/config/merge-server-config.js +8 -6
  27. package/lib/custom-events/custom-event-aggregator.js +1 -1
  28. package/lib/db/parse-sql.js +13 -16
  29. package/lib/db/parsed-statement.js +13 -19
  30. package/lib/db/query-parsers/sql.js +12 -15
  31. package/lib/db/query-sample.js +16 -12
  32. package/lib/db/query-trace-aggregator.js +16 -16
  33. package/lib/db/statement-matcher.js +5 -5
  34. package/lib/db/utils.js +2 -2
  35. package/lib/environment.js +210 -175
  36. package/lib/errors/error-collector.js +20 -33
  37. package/lib/errors/error-event-aggregator.js +1 -1
  38. package/lib/errors/error-trace-aggregator.js +3 -4
  39. package/lib/errors/helper.js +23 -32
  40. package/lib/errors/index.js +31 -43
  41. package/lib/feature_flags.js +3 -4
  42. package/lib/grpc/connection/states.js +6 -6
  43. package/lib/grpc/connection.js +35 -46
  44. package/lib/header-attributes.js +55 -59
  45. package/lib/header-processing.js +1 -1
  46. package/lib/instrumentation/amqplib.js +34 -43
  47. package/lib/instrumentation/bluebird.js +63 -22
  48. package/lib/instrumentation/cassandra-driver.js +8 -4
  49. package/lib/instrumentation/connect.js +7 -6
  50. package/lib/instrumentation/core/async_hooks.js +16 -9
  51. package/lib/instrumentation/core/child_process.js +20 -28
  52. package/lib/instrumentation/core/crypto.js +1 -7
  53. package/lib/instrumentation/core/dns.js +3 -7
  54. package/lib/instrumentation/core/domain.js +4 -10
  55. package/lib/instrumentation/core/fs.js +22 -37
  56. package/lib/instrumentation/core/globals.js +4 -8
  57. package/lib/instrumentation/core/http-outbound.js +20 -114
  58. package/lib/instrumentation/core/http.js +61 -128
  59. package/lib/instrumentation/core/inspector.js +7 -11
  60. package/lib/instrumentation/core/net.js +3 -1
  61. package/lib/instrumentation/core/timers.js +21 -28
  62. package/lib/instrumentation/core/zlib.js +3 -11
  63. package/lib/instrumentation/director.js +4 -4
  64. package/lib/instrumentation/express.js +12 -10
  65. package/lib/instrumentation/fastify/spec-builders.js +5 -0
  66. package/lib/instrumentation/fastify.js +37 -10
  67. package/lib/instrumentation/generic-pool.js +1 -1
  68. package/lib/instrumentation/hapi/hapi-17.js +20 -21
  69. package/lib/instrumentation/hapi/shared.js +1 -1
  70. package/lib/instrumentation/hapi.js +37 -37
  71. package/lib/instrumentation/ioredis.js +8 -9
  72. package/lib/instrumentation/memcached.js +41 -45
  73. package/lib/instrumentation/mongodb/common.js +221 -0
  74. package/lib/instrumentation/mongodb/constants.js +87 -0
  75. package/lib/instrumentation/mongodb/v2-mongo.js +110 -0
  76. package/lib/instrumentation/mongodb/v3-mongo.js +80 -0
  77. package/lib/instrumentation/mongodb/v4-mongo.js +90 -0
  78. package/lib/instrumentation/mongodb.js +20 -312
  79. package/lib/instrumentation/mysql.js +51 -44
  80. package/lib/instrumentation/oracle.js +24 -28
  81. package/lib/instrumentation/pg.js +34 -25
  82. package/lib/instrumentation/promise.js +65 -62
  83. package/lib/instrumentation/q.js +2 -2
  84. package/lib/instrumentation/redis.js +38 -38
  85. package/lib/instrumentation/restify.js +1 -1
  86. package/lib/instrumentation/vision.js +4 -4
  87. package/lib/instrumentation/when.js +12 -4
  88. package/lib/instrumentations.js +25 -25
  89. package/lib/logger.js +6 -6
  90. package/lib/metrics/index.js +50 -30
  91. package/lib/metrics/mapper.js +15 -15
  92. package/lib/metrics/metric-aggregator.js +5 -10
  93. package/lib/metrics/names.js +8 -7
  94. package/lib/metrics/normalizer/rule.js +14 -15
  95. package/lib/metrics/normalizer/tx_segment.js +33 -29
  96. package/lib/metrics/normalizer.js +51 -54
  97. package/lib/metrics/recorders/custom.js +8 -6
  98. package/lib/metrics/recorders/distributed-trace.js +3 -18
  99. package/lib/metrics/recorders/generic.js +6 -5
  100. package/lib/metrics/recorders/http.js +11 -13
  101. package/lib/metrics/recorders/http_external.js +8 -10
  102. package/lib/metrics/recorders/message-transaction.js +7 -18
  103. package/lib/metrics/recorders/other.js +7 -17
  104. package/lib/parse-proc-cpuinfo.js +26 -31
  105. package/lib/parse-proc-meminfo.js +5 -3
  106. package/lib/prioritized-attributes.js +14 -19
  107. package/lib/priority-queue.js +11 -11
  108. package/lib/proxy/grpc.js +1 -1
  109. package/lib/reservoir.js +12 -6
  110. package/lib/sampler.js +33 -34
  111. package/lib/serverless/api-gateway.js +3 -3
  112. package/lib/serverless/aws-lambda.js +28 -37
  113. package/lib/shim/conglomerate-shim.js +4 -4
  114. package/lib/shim/datastore-shim.js +61 -67
  115. package/lib/shim/index.js +10 -11
  116. package/lib/shim/message-shim.js +149 -151
  117. package/lib/shim/promise-shim.js +19 -14
  118. package/lib/shim/shim.js +131 -125
  119. package/lib/shim/specs/index.js +21 -22
  120. package/lib/shim/transaction-shim.js +52 -210
  121. package/lib/shim/webframework-shim.js +75 -85
  122. package/lib/shimmer.js +184 -166
  123. package/lib/spans/create-span-event-aggregator.js +11 -8
  124. package/lib/spans/span-context.js +4 -10
  125. package/lib/spans/span-event-aggregator.js +68 -13
  126. package/lib/spans/span-event.js +6 -8
  127. package/lib/spans/span-streamer.js +10 -18
  128. package/lib/spans/streaming-span-attributes.js +1 -1
  129. package/lib/spans/streaming-span-event-aggregator.js +1 -1
  130. package/lib/spans/streaming-span-event.js +4 -4
  131. package/lib/stats/apdex.js +7 -13
  132. package/lib/stats/index.js +14 -19
  133. package/lib/system-info.js +29 -25
  134. package/lib/timer.js +35 -21
  135. package/lib/transaction/dt-payload.js +1 -1
  136. package/lib/transaction/handle.js +19 -19
  137. package/lib/transaction/index.js +133 -151
  138. package/lib/transaction/name-state.js +18 -19
  139. package/lib/transaction/trace/aggregator.js +78 -73
  140. package/lib/transaction/trace/exclusive-time-calculator.js +9 -13
  141. package/lib/transaction/trace/index.js +37 -35
  142. package/lib/transaction/trace/segment.js +56 -73
  143. package/lib/transaction/tracecontext.js +38 -46
  144. package/lib/transaction/tracer/index.js +130 -91
  145. package/lib/transaction/transaction-event-aggregator.js +29 -31
  146. package/lib/uninstrumented.js +11 -12
  147. package/lib/util/arity.js +2 -2
  148. package/lib/util/attribute-types.js +1 -5
  149. package/lib/util/byte-limit.js +4 -5
  150. package/lib/util/cat.js +270 -33
  151. package/lib/util/codec.js +10 -6
  152. package/lib/util/copy.js +2 -2
  153. package/lib/util/deep-equal.js +51 -21
  154. package/lib/util/flatten.js +9 -6
  155. package/lib/util/hashes.js +16 -16
  156. package/lib/util/label-parser.js +22 -28
  157. package/lib/util/logger.js +53 -35
  158. package/lib/util/process-version.js +3 -3
  159. package/lib/util/properties.js +5 -5
  160. package/lib/util/sql/obfuscate.js +21 -31
  161. package/lib/util/stream-sink.js +5 -6
  162. package/lib/util/unwrapped-core.js +2 -2
  163. package/lib/util/urltils.js +26 -30
  164. package/lib/utilization/aws-info.js +8 -9
  165. package/lib/utilization/azure-info.js +37 -35
  166. package/lib/utilization/common.js +17 -16
  167. package/lib/utilization/docker-info.js +14 -16
  168. package/lib/utilization/gcp-info.js +38 -37
  169. package/lib/utilization/index.js +5 -5
  170. package/lib/utilization/kubernetes-info.js +2 -2
  171. package/lib/utilization/pcf-info.js +12 -12
  172. package/package.json +23 -6
  173. package/stub_api.js +16 -14
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var Heap = require('@tyriar/fibonacci-heap').FibonacciHeap
8
+ const Heap = require('@tyriar/fibonacci-heap').FibonacciHeap
9
9
 
10
10
  function PriorityQueue(limit) {
11
11
  this.limit = limit == null ? 10 : limit
@@ -20,7 +20,7 @@ function PriorityQueue(limit) {
20
20
  }
21
21
 
22
22
  PriorityQueue.prototype.overflow = function overflow() {
23
- var diff = this.seen - this.limit
23
+ const diff = this.seen - this.limit
24
24
  return diff >= 0 ? diff : 0
25
25
  }
26
26
 
@@ -51,8 +51,8 @@ PriorityQueue.prototype._replace = function _replace(value, priority) {
51
51
  }
52
52
 
53
53
  PriorityQueue.prototype.getRawEvents = function getRawEvents() {
54
- var events = []
55
- var min = this._data.findMinimum()
54
+ const events = []
55
+ const min = this._data.findMinimum()
56
56
 
57
57
  if (min) {
58
58
  _getRawEvents(min, events)
@@ -61,10 +61,10 @@ PriorityQueue.prototype.getRawEvents = function getRawEvents() {
61
61
  return events
62
62
 
63
63
  function _getRawEvents(head, evts) {
64
- var current = head
64
+ let current = head
65
65
 
66
66
  do {
67
- evts.push({value: current.value, priority: current.key})
67
+ evts.push({ value: current.value, priority: current.key })
68
68
  if (current.child) {
69
69
  _getRawEvents(current.child, evts)
70
70
  }
@@ -74,8 +74,8 @@ PriorityQueue.prototype.getRawEvents = function getRawEvents() {
74
74
  }
75
75
 
76
76
  PriorityQueue.prototype.toArray = function toArray() {
77
- var nodes = []
78
- var min = this._data.findMinimum()
77
+ const nodes = []
78
+ const min = this._data.findMinimum()
79
79
 
80
80
  if (min) {
81
81
  serializeHeap(min, nodes)
@@ -84,7 +84,7 @@ PriorityQueue.prototype.toArray = function toArray() {
84
84
  return nodes
85
85
 
86
86
  function serializeHeap(head, arr) {
87
- var current = head
87
+ let current = head
88
88
 
89
89
  do {
90
90
  arr.push(current.value)
@@ -110,11 +110,11 @@ PriorityQueue.prototype.merge = function merge(events) {
110
110
 
111
111
  if (events instanceof PriorityQueue) {
112
112
  while (events.length) {
113
- var current = events._data.extractMinimum()
113
+ const current = events._data.extractMinimum()
114
114
  this.add(current.value, current.key)
115
115
  }
116
116
  } else {
117
- for (var i = 0; i < events.length; ++i) {
117
+ for (let i = 0; i < events.length; ++i) {
118
118
  this.add(events[i].value, events[i].priority)
119
119
  }
120
120
  }
package/lib/proxy/grpc.js CHANGED
@@ -17,4 +17,4 @@ class ProxyGrpc {
17
17
  this.ServerCredentials = this.library.ServerCredentials
18
18
  }
19
19
  }
20
- module.exports = (new ProxyGrpc)
20
+ module.exports = new ProxyGrpc()
package/lib/reservoir.js CHANGED
@@ -14,7 +14,7 @@ function Reservoir(limit) {
14
14
  }
15
15
 
16
16
  Reservoir.prototype.overflow = function overflow() {
17
- var diff = this.seen - this.limit
17
+ const diff = this.seen - this.limit
18
18
  return diff >= 0 ? diff : 0
19
19
  }
20
20
 
@@ -29,8 +29,10 @@ Reservoir.prototype.add = function add(item) {
29
29
  // This is effectively the same as adding the new element to the
30
30
  // end, swapping the last element (the new one) with a random element in the list,
31
31
  // then dropping the last element (the potentially swapped one) in the list.
32
- var toReplace = Math.floor(Math.random() * (this.seen + 2))
33
- if (toReplace < this.limit) this._data[toReplace] = item
32
+ const toReplace = Math.floor(Math.random() * (this.seen + 2))
33
+ if (toReplace < this.limit) {
34
+ this._data[toReplace] = item
35
+ }
34
36
  }
35
37
  this.seen++
36
38
  }
@@ -40,9 +42,13 @@ Reservoir.prototype.toArray = function toArray() {
40
42
  }
41
43
 
42
44
  Reservoir.prototype.merge = function merge(items) {
43
- if (!items || !items.length) return
44
- if (items === this._data) return
45
- for (var i = 0; i < items.length; i++) {
45
+ if (!items || !items.length) {
46
+ return
47
+ }
48
+ if (items === this._data) {
49
+ return
50
+ }
51
+ for (let i = 0; i < items.length; i++) {
46
52
  this.add(items[i])
47
53
  }
48
54
  }
package/lib/sampler.js CHANGED
@@ -5,22 +5,22 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var NAMES = require('./metrics/names')
9
- var logger = require('./logger').child({component: 'sampler'})
10
- var Timer = require('./timer')
11
- var os = require('os')
8
+ const NAMES = require('./metrics/names')
9
+ const logger = require('./logger').child({ component: 'sampler' })
10
+ const Timer = require('./timer')
11
+ const os = require('os')
12
12
 
13
13
  /*
14
14
  *
15
15
  * CONSTANTS
16
16
  *
17
17
  */
18
- var MILLIS = 1e3
19
- var MICROS = 1e6
20
- var CPUS = os.cpus().length
21
- var SAMPLE_INTERVAL = 15 * MILLIS
18
+ const MILLIS = 1e3
19
+ const MICROS = 1e6
20
+ const CPUS = os.cpus().length
21
+ const SAMPLE_INTERVAL = 15 * MILLIS
22
22
 
23
- var samplers = []
23
+ let samplers = []
24
24
 
25
25
  function Sampler(sampler, interval) {
26
26
  this.id = setInterval(sampler, interval)
@@ -39,7 +39,7 @@ function recordQueueTime(agent, timer) {
39
39
  function sampleMemory(agent) {
40
40
  return function memorySampler() {
41
41
  try {
42
- var mem = process.memoryUsage()
42
+ const mem = process.memoryUsage()
43
43
  agent.metrics.measureBytes(NAMES.MEMORY.PHYSICAL, mem.rss)
44
44
  agent.metrics.measureBytes(NAMES.MEMORY.USED_HEAP, mem.heapUsed)
45
45
  agent.metrics.measureBytes(NAMES.MEMORY.MAX_HEAP, mem.heapTotal)
@@ -54,7 +54,7 @@ function sampleMemory(agent) {
54
54
 
55
55
  function checkEvents(agent) {
56
56
  return function eventSampler() {
57
- var timer = new Timer()
57
+ const timer = new Timer()
58
58
  timer.begin()
59
59
  setTimeout(recordQueueTime.bind(null, agent, timer), 0)
60
60
  }
@@ -70,22 +70,22 @@ function getCpuSample(lastSample) {
70
70
  }
71
71
 
72
72
  function generateCPUMetricRecorder(agent) {
73
- var lastSampleTime
73
+ let lastSampleTime
74
74
  // userTime and sysTime are in seconds
75
75
  return function recordCPUMetrics(userTime, sysTime) {
76
- var elapsedUptime
76
+ let elapsedUptime
77
77
  if (!lastSampleTime) {
78
78
  elapsedUptime = process.uptime()
79
79
  } else {
80
80
  elapsedUptime = (Date.now() - lastSampleTime) / MILLIS
81
81
  }
82
82
 
83
- var totalCpuTime = CPUS * elapsedUptime
83
+ const totalCpuTime = CPUS * elapsedUptime
84
84
 
85
85
  lastSampleTime = Date.now()
86
86
 
87
- var userUtil = userTime / totalCpuTime
88
- var sysUtil = sysTime / totalCpuTime
87
+ const userUtil = userTime / totalCpuTime
88
+ const sysUtil = sysTime / totalCpuTime
89
89
 
90
90
  recordValue(agent, NAMES.CPU.USER_TIME, userTime)
91
91
  recordValue(agent, NAMES.CPU.SYSTEM_TIME, sysTime)
@@ -95,10 +95,10 @@ function generateCPUMetricRecorder(agent) {
95
95
  }
96
96
 
97
97
  function sampleCpu(agent) {
98
- var lastSample
99
- var recordCPU = generateCPUMetricRecorder(agent)
98
+ let lastSample
99
+ const recordCPU = generateCPUMetricRecorder(agent)
100
100
  return function cpuSampler() {
101
- var cpuSample = getCpuSample(lastSample)
101
+ const cpuSample = getCpuSample(lastSample)
102
102
  lastSample = getCpuSample()
103
103
 
104
104
  if (lastSample == null) {
@@ -110,7 +110,7 @@ function sampleCpu(agent) {
110
110
  }
111
111
 
112
112
  function sampleCpuNative(agent, nativeMetrics) {
113
- var recordCPU = generateCPUMetricRecorder(agent)
113
+ const recordCPU = generateCPUMetricRecorder(agent)
114
114
  nativeMetrics.on('usage', function collectResourceUsage(usage) {
115
115
  recordCPU(usage.diff.ru_utime / MILLIS, usage.diff.ru_stime / MILLIS)
116
116
  })
@@ -149,7 +149,7 @@ function sampleGc(agent, nativeMetrics) {
149
149
  }
150
150
  }
151
151
 
152
- var sampler = module.exports = {
152
+ module.exports = {
153
153
  state: 'stopped',
154
154
  sampleMemory: sampleMemory,
155
155
  checkEvents: checkEvents,
@@ -170,12 +170,12 @@ var sampler = module.exports = {
170
170
  })
171
171
  } catch (err) {
172
172
  logger.info(
173
- {error: {message: err.message, stack: err.stack}},
173
+ { error: { message: err.message, stack: err.stack } },
174
174
  'Not adding native metric sampler.'
175
175
  )
176
- agent.metrics.getOrCreateMetric(
177
- NAMES.SUPPORTABILITY.DEPENDENCIES + '/NoNativeMetricsModule'
178
- ).incrementCallCount()
176
+ agent.metrics
177
+ .getOrCreateMetric(NAMES.SUPPORTABILITY.DEPENDENCIES + '/NoNativeMetricsModule')
178
+ .incrementCallCount()
179
179
  }
180
180
  }
181
181
 
@@ -197,17 +197,16 @@ var sampler = module.exports = {
197
197
 
198
198
  // Add CPU sampling using the built-in data if available, otherwise pulling
199
199
  // from the native module.
200
- if (process.cpuUsage) { // introduced in 6.1.0
200
+ if (process.cpuUsage) {
201
+ // introduced in 6.1.0
201
202
  samplers.push(new Sampler(sampleCpu(agent), SAMPLE_INTERVAL))
202
203
  } else if (this.nativeMetrics && this.nativeMetrics.usageEnabled) {
203
- samplers.push(
204
- new Sampler(sampleCpuNative(agent, this.nativeMetrics), SAMPLE_INTERVAL)
205
- )
204
+ samplers.push(new Sampler(sampleCpuNative(agent, this.nativeMetrics), SAMPLE_INTERVAL))
206
205
  } else {
207
206
  logger.debug('Not adding CPU metric sampler.')
208
207
  }
209
208
 
210
- sampler.state = 'running'
209
+ this.state = 'running'
211
210
  },
212
211
 
213
212
  stop: function stop() {
@@ -215,7 +214,7 @@ var sampler = module.exports = {
215
214
  s.stop()
216
215
  })
217
216
  samplers = []
218
- sampler.state = 'stopped'
217
+ this.state = 'stopped'
219
218
  if (this.nativeMetrics) {
220
219
  this.nativeMetrics.unbind()
221
220
  this.nativeMetrics.removeAllListeners()
@@ -228,13 +227,13 @@ var sampler = module.exports = {
228
227
  }
229
228
 
230
229
  function recordValue(agent, metric, value) {
231
- var stats = agent.metrics.getOrCreateMetric(metric)
230
+ const stats = agent.metrics.getOrCreateMetric(metric)
232
231
  stats.recordValue(value)
233
232
  logger.trace('Recorded metric %s: %j', metric, value)
234
233
  }
235
234
 
236
235
  function recordCompleteMetric(agent, metricName, metric) {
237
- var stats = agent.metrics.getOrCreateMetric(metricName)
236
+ const stats = agent.metrics.getOrCreateMetric(metricName)
238
237
  stats.merge(metric)
239
238
  logger.trace('Recorded metric %s: %j', metricName, metric)
240
239
  }
@@ -243,5 +242,5 @@ function divideMetric(metric, divisor) {
243
242
  metric.min /= divisor
244
243
  metric.max /= divisor
245
244
  metric.total /= divisor
246
- metric.sumOfSquares /= (divisor * divisor)
245
+ metric.sumOfSquares /= divisor * divisor
247
246
  }
@@ -14,9 +14,9 @@ class LambdaProxyWebRequest {
14
14
  constructor(event) {
15
15
  this.headers = event.headers
16
16
  this.url = {
17
- 'path': event.path,
18
- 'port': event.headers['X-Forwarded-Port'],
19
- 'requestParameters': event.queryStringParameters
17
+ path: event.path,
18
+ port: event.headers['X-Forwarded-Port'],
19
+ requestParameters: event.queryStringParameters
20
20
  }
21
21
  this.method = event.httpMethod
22
22
  this.transportType = event.headers['X-Forwarded-Proto']
@@ -8,7 +8,7 @@
8
8
  const apiGateway = require('./api-gateway')
9
9
  const headerAttributes = require('../header-attributes')
10
10
  const get = require('../util/get')
11
- const logger = require('../logger').child({component: 'aws-lambda'})
11
+ const logger = require('../logger').child({ component: 'aws-lambda' })
12
12
  const recordBackground = require('../metrics/recorders/other')
13
13
  const recordWeb = require('../metrics/recorders/http')
14
14
  const TransactionShim = require('../shim/transaction-shim')
@@ -106,7 +106,7 @@ class AwsLambda {
106
106
  })
107
107
  }
108
108
 
109
- return shim.bindCreateTransaction(wrappedHandler, {type: shim.BG})
109
+ return shim.bindCreateTransaction(wrappedHandler, { type: shim.BG })
110
110
 
111
111
  function wrappedHandler() {
112
112
  const args = shim.argsToArray.apply(shim, arguments)
@@ -138,17 +138,12 @@ class AwsLambda {
138
138
  resultProcessor = getApiGatewayLambdaProxyResultProcessor(transaction)
139
139
  }
140
140
 
141
-
142
141
  const cbIndex = args.length - 1
143
142
 
144
143
  // Add transaction ending closure to the list of functions to be called on
145
144
  // beforeExit (i.e. in the case that context.{done,fail,succeed} or callback
146
145
  // were not called).
147
- const txnEnder = endTransaction.bind(
148
- null,
149
- transaction,
150
- transactionEnders.length
151
- )
146
+ const txnEnder = endTransaction.bind(null, transaction, transactionEnders.length)
152
147
 
153
148
  transactionEnders.push(txnEnder)
154
149
 
@@ -171,10 +166,7 @@ class AwsLambda {
171
166
  })
172
167
 
173
168
  const awsAttributes = awsLambda._getAwsAgentAttributes(event, context)
174
- transaction.trace.attributes.addAttributes(
175
- ATTR_DEST.TRANS_COMMON,
176
- awsAttributes
177
- )
169
+ transaction.trace.attributes.addAttributes(ATTR_DEST.TRANS_COMMON, awsAttributes)
178
170
 
179
171
  shim.agent.setLambdaArn(context.invokedFunctionArn)
180
172
 
@@ -201,17 +193,20 @@ class AwsLambda {
201
193
  // we need to store the error in uncaughtException
202
194
  // otherwise the transaction will end before they are captured
203
195
  function lambdaInterceptPromise(prom, resultProcessor, cb) {
204
- return prom.then(function onThen(arg) {
205
- if (resultProcessor) {
206
- resultProcessor(arg)
196
+ return prom.then(
197
+ function onThen(arg) {
198
+ if (resultProcessor) {
199
+ resultProcessor(arg)
200
+ }
201
+ cb()
202
+ return arg
203
+ },
204
+ function onCatch(err) {
205
+ uncaughtException = err
206
+ cb()
207
+ throw err // This is not our error, just rethrowing the promise rejection.
207
208
  }
208
- cb()
209
- return arg
210
- }, function onCatch(err) {
211
- uncaughtException = err
212
- cb()
213
- throw err // This is not our error, just rethrowing the promise rejection.
214
- })
209
+ )
215
210
  }
216
211
 
217
212
  function wrapCallbackAndCaptureError(transaction, txnEnder, cb, processResult) {
@@ -285,8 +280,11 @@ function setEventSourceAttributes(event, attributes) {
285
280
  } else if (event.records && event.deliveryStreamArn) {
286
281
  // Kinesis Firehose
287
282
  attributes[EVENT_SOURCE_ARN_KEY] = event.deliveryStreamArn
288
- } else if (event.requestContext && event.requestContext.elb &&
289
- event.requestContext.elb.targetGroupArn) {
283
+ } else if (
284
+ event.requestContext &&
285
+ event.requestContext.elb &&
286
+ event.requestContext.elb.targetGroupArn
287
+ ) {
290
288
  attributes[EVENT_SOURCE_ARN_KEY] = event.requestContext.elb.targetGroupArn
291
289
  } else if (event.resources && event.resources[0]) {
292
290
  attributes[EVENT_SOURCE_ARN_KEY] = event.resources[0]
@@ -319,10 +317,7 @@ function setWebRequest(shim, transaction, request) {
319
317
  request.method
320
318
  )
321
319
 
322
- segment.addSpanAttribute(
323
- 'request.method',
324
- request.method
325
- )
320
+ segment.addSpanAttribute('request.method', request.method)
326
321
 
327
322
  transaction.port = request.url.port
328
323
 
@@ -335,10 +330,7 @@ function setWebRequest(shim, transaction, request) {
335
330
  request.url.path
336
331
  )
337
332
 
338
- segment.addSpanAttribute(
339
- 'request.uri',
340
- request.url.path
341
- )
333
+ segment.addSpanAttribute('request.uri', request.url.path)
342
334
 
343
335
  headerAttributes.collectRequestHeaders(request.headers, transaction)
344
336
 
@@ -351,11 +343,10 @@ function setWebRequest(shim, transaction, request) {
351
343
  }
352
344
 
353
345
  function lowercaseObjectKeys(original) {
354
- const lowercaseObject = Object.keys(original)
355
- .reduce((destination, key) => {
356
- destination[key.toLowerCase()] = original[key]
357
- return destination
358
- }, {})
346
+ const lowercaseObject = Object.keys(original).reduce((destination, key) => {
347
+ destination[key.toLowerCase()] = original[key]
348
+ return destination
349
+ }, {})
359
350
 
360
351
  return lowercaseObject
361
352
  }
@@ -5,10 +5,10 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- const logger = require('../logger').child({component: 'ConglomerateShim'})
8
+ const logger = require('../logger').child({ component: 'ConglomerateShim' })
9
9
  const Shim = require('./shim')
10
10
 
11
- const {MODULE_TYPE} = require('./constants')
11
+ const { MODULE_TYPE } = require('./constants')
12
12
  const SHIM_CLASSES = {
13
13
  [MODULE_TYPE.GENERIC]: Shim,
14
14
  [MODULE_TYPE.DATASTORE]: require('./datastore-shim'),
@@ -27,7 +27,7 @@ const SHIM_CLASSES = {
27
27
  class ConglomerateShim extends Shim {
28
28
  constructor(agent, moduleName, resolvedName) {
29
29
  super(agent, moduleName, resolvedName)
30
- this._logger = logger.child({module: moduleName})
30
+ this._logger = logger.child({ module: moduleName })
31
31
  this._resolvedName = resolvedName
32
32
  }
33
33
 
@@ -62,7 +62,7 @@ class ConglomerateShim extends Shim {
62
62
  makeSpecializedShim(type, submodule) {
63
63
  const ShimClass = SHIM_CLASSES[type]
64
64
  const shim = new ShimClass(this.agent, this.moduleName, this._resolvedName)
65
- shim._logger = shim._logger.child({submodule})
65
+ shim._logger = shim._logger.child({ submodule })
66
66
  return shim
67
67
  }
68
68
  }