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
@@ -28,7 +28,7 @@ function serverFactoryWrapper(shim, fn, fnName, server) {
28
28
  }
29
29
 
30
30
  function serverPostConstructor(shim) {
31
- var proto = Object.getPrototypeOf(this)
31
+ const proto = Object.getPrototypeOf(this)
32
32
 
33
33
  if (shim.isWrapped(proto.decorate)) {
34
34
  shim.logger.trace('Already wrapped Server proto, not wrapping again')
@@ -44,7 +44,7 @@ function serverPostConstructor(shim) {
44
44
  }
45
45
 
46
46
  // Convert arguments to usable array
47
- var args = shim.argsToArray.apply(shim, arguments)
47
+ const args = shim.argsToArray.apply(shim, arguments)
48
48
 
49
49
  // Wrap the third server.decorate arg, the user-defined handler
50
50
  shim.wrap(args, shim.THIRD, function wrapHandler(shim, fn) {
@@ -59,7 +59,7 @@ function serverPostConstructor(shim) {
59
59
  return wrappedHandler
60
60
 
61
61
  function wrappedHandler(route) {
62
- var ret = fn.apply(this, arguments)
62
+ const ret = fn.apply(this, arguments)
63
63
 
64
64
  return typeof ret === 'function' ? wrapRouteHandler(shim, ret, route && route.path) : ret
65
65
  }
@@ -71,7 +71,7 @@ function serverPostConstructor(shim) {
71
71
 
72
72
  shim.wrap(proto, 'route', function wrapRoute(shim, original) {
73
73
  return function wrappedRoute() {
74
- var args = shim.argsToArray.apply(shim, arguments)
74
+ const args = shim.argsToArray.apply(shim, arguments)
75
75
 
76
76
  if (!shim.isObject(args[0])) {
77
77
  return original.apply(this, args)
@@ -92,7 +92,7 @@ function serverPostConstructor(shim) {
92
92
  function _wrapRoute(shim, route) {
93
93
  const routePath = prefix + route.path
94
94
  if (shim.isArray(route)) {
95
- for (var i = 0; i < route.length; ++i) {
95
+ for (let i = 0; i < route.length; ++i) {
96
96
  _wrapRoute(shim, route[i])
97
97
  }
98
98
  return
@@ -132,10 +132,10 @@ function serverPostConstructor(shim) {
132
132
 
133
133
  shim.wrap(proto, 'ext', function wrapExt(shim, original) {
134
134
  return function wrappedExt(event, method) {
135
- var args = shim.argsToArray.apply(shim, arguments)
135
+ const args = shim.argsToArray.apply(shim, arguments)
136
136
 
137
137
  if (shim.isArray(event)) {
138
- for (var i = 0; i < event.length; i++) {
138
+ for (let i = 0; i < event.length; i++) {
139
139
  event[i].method = wrapMiddleware(shim, event[i].method, event[i].type)
140
140
  }
141
141
  } else if (shim.isObject(event)) {
@@ -154,7 +154,7 @@ function serverPostConstructor(shim) {
154
154
 
155
155
  function wrapPreHandlers(shim, container, path) {
156
156
  if (shim.isArray(container)) {
157
- for (var i = 0; i < container.length; ++i) {
157
+ for (let i = 0; i < container.length; ++i) {
158
158
  container[i] = wrapPreHandlers(shim, container[i], path)
159
159
  }
160
160
  return container
@@ -177,14 +177,14 @@ function wrapRouteHandler(shim, handler, path) {
177
177
  return shim.recordMiddleware(handler, {
178
178
  route: path,
179
179
  req: function getReq(shim, fn, fnName, args) {
180
- var request = args[0]
180
+ const request = args[0]
181
181
  if (request && request.raw) {
182
182
  return request.raw.req
183
183
  }
184
184
  },
185
185
  promise: true,
186
186
  params: function getParams(shim, fn, fnName, args) {
187
- var req = args[0]
187
+ const req = args[0]
188
188
  return req && req.params
189
189
  }
190
190
  })
@@ -200,7 +200,7 @@ function wrapMiddleware(shim, middleware, event) {
200
200
  type: event === 'onPreResponse' ? shim.ERRORWARE : shim.MIDDLEWARE,
201
201
  promise: true,
202
202
  req: function getReq(shim, fn, fnName, args) {
203
- var req = args[0]
203
+ const req = args[0]
204
204
  return req && req.raw && req.raw.req
205
205
  }
206
206
  })
@@ -7,7 +7,7 @@
7
7
 
8
8
  // This object defines all the events that we want to wrap extensions
9
9
  // for, as they are the only ones associated with requests.
10
- var ROUTE_EVENTS = {
10
+ const ROUTE_EVENTS = {
11
11
  onRequest: true,
12
12
  onPreAuth: true,
13
13
  onCredentials: true,
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var shared = require('./hapi/shared')
8
+ const shared = require('./hapi/shared')
9
9
 
10
10
  module.exports = function initialize(agent, hapi, moduleName, shim) {
11
11
  if (!agent || !hapi || !shim) {
@@ -32,7 +32,7 @@ module.exports = function initialize(agent, hapi, moduleName, shim) {
32
32
 
33
33
  // See if we can find the plugin class. This should be the super class of
34
34
  // Server and will cover more scenarios.
35
- var Plugin = hapi.Server.super_
35
+ const Plugin = hapi.Server.super_
36
36
  if (_isPluginClass(Plugin)) {
37
37
  wrapServer(shim, Plugin)
38
38
  } else {
@@ -46,9 +46,9 @@ function wrapServer(shim, Server) {
46
46
  // the second argument is expected to be a function that generates the handler function
47
47
  shim.wrap(Server.prototype, 'handler', function wrapHandler(shim, original) {
48
48
  return function wrappedHandler() {
49
- var args = shim.argsToArray.apply(shim, arguments)
49
+ const args = shim.argsToArray.apply(shim, arguments)
50
50
 
51
- var handlerGenerator = args[1]
51
+ const handlerGenerator = args[1]
52
52
  if (typeof handlerGenerator === 'function') {
53
53
  args[1] = wrapGenerator(handlerGenerator)
54
54
  }
@@ -57,10 +57,10 @@ function wrapServer(shim, Server) {
57
57
 
58
58
  function wrapGenerator(generator) {
59
59
  function wrappedGenerator() {
60
- var generatorArgs = shim.argsToArray.apply(shim, arguments)
61
- var handler = generator.apply(this, generatorArgs)
60
+ const generatorArgs = shim.argsToArray.apply(shim, arguments)
61
+ const handler = generator.apply(this, generatorArgs)
62
62
  if (typeof handler === 'function') {
63
- var route = generatorArgs[0]
63
+ const route = generatorArgs[0]
64
64
  return wrapRouteHandler(shim, handler, route && route.path)
65
65
  }
66
66
  return handler
@@ -75,7 +75,7 @@ function wrapServer(shim, Server) {
75
75
 
76
76
  shim.wrap(Server.prototype, 'route', function wrapRoute(shim, original) {
77
77
  return function wrappedRoute() {
78
- var args = shim.argsToArray.apply(shim, arguments)
78
+ const args = shim.argsToArray.apply(shim, arguments)
79
79
 
80
80
  // first argument is expected to be the route configuration object
81
81
  if (!shim.isObject(args[0])) {
@@ -98,7 +98,7 @@ function wrapServer(shim, Server) {
98
98
  const routePath = prefix + route.path
99
99
  // handler function could be on the route object, or on a nested config object
100
100
  if (shim.isArray(route)) {
101
- for (var i = 0; i < route.length; ++i) {
101
+ for (let i = 0; i < route.length; ++i) {
102
102
  _wrapRoute(shim, route[i])
103
103
  }
104
104
  return
@@ -119,10 +119,10 @@ function wrapServer(shim, Server) {
119
119
 
120
120
  shim.wrap(Server.prototype, 'ext', function wrapExt(shim, original) {
121
121
  return function wrappedExt(event, method) {
122
- var args = shim.argsToArray.apply(shim, arguments)
122
+ const args = shim.argsToArray.apply(shim, arguments)
123
123
 
124
124
  if (shim.isArray(event)) {
125
- for (var i = 0; i < event.length; i++) {
125
+ for (let i = 0; i < event.length; i++) {
126
126
  event[i].method = wrapMiddleware(shim, event[i].method, event[i].type)
127
127
  }
128
128
  } else if (shim.isObject(event)) {
@@ -142,7 +142,7 @@ function wrapServer(shim, Server) {
142
142
  function wrapCreateServer(shim, hapi) {
143
143
  shim.wrap(hapi, 'createServer', function getWrapper(shim, createServer) {
144
144
  return function createServerWrapper() {
145
- var server = createServer.apply(this, arguments)
145
+ const server = createServer.apply(this, arguments)
146
146
  wrapServer(shim, server.constructor)
147
147
  shim.unwrap(hapi, 'createServer')
148
148
  return server
@@ -152,7 +152,7 @@ function wrapCreateServer(shim, hapi) {
152
152
 
153
153
  function wrapPreHandlers(shim, container, path) {
154
154
  if (shim.isArray(container)) {
155
- for (var i = 0; i < container.length; ++i) {
155
+ for (let i = 0; i < container.length; ++i) {
156
156
  container[i] = wrapPreHandlers(shim, container[i], path)
157
157
  }
158
158
  return container
@@ -194,20 +194,20 @@ function buildMiddlewareSpec(shim, path, isPreHandler) {
194
194
  return {
195
195
  route: path,
196
196
  req: function getReq(shim, fn, fnName, args) {
197
- var request = args[0]
197
+ const request = args[0]
198
198
  if (request && request.raw) {
199
199
  return request.raw.req
200
200
  }
201
201
  },
202
202
  next: function wrapNext(shim, fn, fnName, args, wrap) {
203
- var reply = args[1]
203
+ const reply = args[1]
204
204
  if (!shim.isFunction(reply)) {
205
205
  return
206
206
  }
207
207
  wrapReply(wrap, reply, isPreHandler)
208
208
  },
209
209
  params: function getParams(shim, fn, fnName, args) {
210
- var req = args[0]
210
+ const req = args[0]
211
211
  return req && req.params
212
212
  }
213
213
  }
@@ -216,7 +216,7 @@ function buildMiddlewareSpec(shim, path, isPreHandler) {
216
216
  function wrapHapiHandler(shim, handler) {
217
217
  return shim.wrap(handler, function wrapHandler(shim, original) {
218
218
  return function wrapped() {
219
- var reply = arguments[1]
219
+ const reply = arguments[1]
220
220
  if (reply) {
221
221
  shim.recordRender(reply, 'view')
222
222
  }
@@ -230,18 +230,18 @@ function wrapMiddleware(shim, middleware, event) {
230
230
  return middleware
231
231
  }
232
232
 
233
- var spec = {
233
+ const spec = {
234
234
  route: event,
235
235
  type: event === 'onPreResponse' ? shim.ERRORWARE : shim.MIDDLEWARE,
236
236
  next: function wrapNext(shim, fn, fnName, args, wrap) {
237
- var reply = args[1]
237
+ const reply = args[1]
238
238
  if (!reply || !shim.isFunction(reply.continue)) {
239
239
  return
240
240
  }
241
241
  wrap(reply, 'continue')
242
242
  },
243
243
  req: function getReq(shim, fn, fnName, args) {
244
- var request = args[0]
244
+ const request = args[0]
245
245
  if (request && request.raw) {
246
246
  return request.raw.req
247
247
  }
@@ -256,7 +256,7 @@ function _isPluginClass(Plugin) {
256
256
  return false
257
257
  }
258
258
 
259
- var proto = Plugin.prototype
259
+ const proto = Plugin.prototype
260
260
  return (
261
261
  typeof proto.handler === 'function' &&
262
262
  typeof proto.route === 'function' &&
@@ -265,7 +265,7 @@ function _isPluginClass(Plugin) {
265
265
  }
266
266
 
267
267
  function wrapReply(wrap, reply, isPreHandler) {
268
- var isFinal = !isPreHandler
268
+ const isFinal = !isPreHandler
269
269
  // The only reply method that is actually used by pre-handlers is `response`. All
270
270
  // other methods still exist, but don't function as they do in normal route handlers.
271
271
  // Since they can still be referenced by users, they still need to be wrapped.
@@ -5,11 +5,11 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var stringify = require('json-stringify-safe')
9
- var urltils = require('../util/urltils.js')
8
+ const stringify = require('json-stringify-safe')
9
+ const urltils = require('../util/urltils.js')
10
10
 
11
11
  module.exports = function initialize(agent, redis, moduleName, shim) {
12
- var proto = redis && redis.prototype
12
+ const proto = redis && redis.prototype
13
13
  if (!proto) {
14
14
  return false
15
15
  }
@@ -18,17 +18,17 @@ module.exports = function initialize(agent, redis, moduleName, shim) {
18
18
  shim.recordOperation(proto, 'sendCommand', wrapSendCommand)
19
19
 
20
20
  function wrapSendCommand(shim, original, name, args) {
21
- var command = args[0]
21
+ const command = args[0]
22
22
 
23
23
  // TODO: Instance attributes for ioredis
24
- var parameters = {
24
+ const parameters = {
25
25
  host: this.connector.options.host,
26
26
  port_path_or_id: this.connector.options.port
27
27
  }
28
28
 
29
- var keys = command.args
29
+ const keys = command.args
30
30
  if (keys && typeof keys !== 'function') {
31
- var src = Object.create(null)
31
+ const src = Object.create(null)
32
32
  try {
33
33
  src.key = stringify(keys[0])
34
34
  } catch (err) {
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var stringify = require('json-stringify-safe')
8
+ const stringify = require('json-stringify-safe')
9
9
 
10
10
  function wrapKeys(metacall) {
11
11
  if (metacall.key) {
@@ -23,7 +23,7 @@ function wrapKeys(metacall) {
23
23
  * instrument the memcached driver to intercept calls and keep stats on them.
24
24
  */
25
25
  module.exports = function initialize(agent, memcached, moduleName, shim) {
26
- var proto = memcached && memcached.prototype
26
+ const proto = memcached && memcached.prototype
27
27
  if (!proto) {
28
28
  return false
29
29
  }
@@ -34,10 +34,10 @@ module.exports = function initialize(agent, memcached, moduleName, shim) {
34
34
  // address. The query generator returns a simple object describing the
35
35
  // memcached call. The server parameter is only provided for multi-calls.
36
36
  // When not provided, it can be derived from the key being interacted with.
37
- var metacall = args[0]()
38
- var server = args[1]
39
- var keys = wrapKeys(metacall)
40
- var parameters = Object.create(null)
37
+ const metacall = args[0]()
38
+ const server = args[1]
39
+ const keys = wrapKeys(metacall)
40
+ const parameters = Object.create(null)
41
41
  try {
42
42
  parameters.key = stringify(keys[0])
43
43
  } catch (err) {
@@ -46,7 +46,7 @@ module.exports = function initialize(agent, memcached, moduleName, shim) {
46
46
  }
47
47
 
48
48
  // Capture connection info for datastore instance metric.
49
- var location = null
49
+ let location = null
50
50
  if (typeof server === 'string') {
51
51
  location = server
52
52
  } else if (this.HashRing && this.HashRing.get && metacall.key) {
@@ -173,7 +173,10 @@ function getInstanceAttributeParameters(shim, obj) {
173
173
  obj.s.db.s.client.s.options.hosts.length
174
174
  ) {
175
175
  // hosts is an array but we will always pull the first for consistency
176
- let [{ host, port, socketPath }] = obj.s.db.s.client.s.options.hosts
176
+ const hosts = obj.s.db.s.client.s.options.hosts
177
+ let host = hosts[0].host
178
+ let port = hosts[0].port
179
+ const socketPath = hosts[0].socketPath
177
180
 
178
181
  if (socketPath) {
179
182
  port = socketPath
@@ -5,8 +5,8 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var dbutils = require('../db/utils')
9
- var properties = require('../util/properties')
8
+ const dbutils = require('../db/utils')
9
+ const properties = require('../util/properties')
10
10
 
11
11
  module.exports = function initialize(agent, mysql, moduleName, shim) {
12
12
  shim.setDatastore(shim.MYSQL)
@@ -16,7 +16,7 @@ module.exports = function initialize(agent, mysql, moduleName, shim) {
16
16
  function wrapCreateConnection(shim, fn, fnName, connection) {
17
17
  shim.logger.debug('Wrapping Connection#query')
18
18
  if (wrapQueriable(shim, connection, false)) {
19
- var connProto = Object.getPrototypeOf(connection)
19
+ const connProto = Object.getPrototypeOf(connection)
20
20
  shim.setInternalProperty(connProto, '__NR_storeDatabase', true)
21
21
  shim.unwrap(mysql, 'createConnection')
22
22
  }
@@ -33,7 +33,7 @@ module.exports = function initialize(agent, mysql, moduleName, shim) {
33
33
  shim.wrapReturn(mysql, 'createPoolCluster', wrapCreatePoolCluster)
34
34
  function wrapCreatePoolCluster(shim, fn, fnName, poolCluster) {
35
35
  shim.logger.debug('Wrapping PoolCluster#of')
36
- var proto = Object.getPrototypeOf(poolCluster)
36
+ const proto = Object.getPrototypeOf(poolCluster)
37
37
  shim.wrapReturn(proto, 'of', wrapPoolClusterOf)
38
38
  function wrapPoolClusterOf(shim, of, _n, poolNamespace) {
39
39
  if (wrapGetConnection(shim, poolNamespace)) {
@@ -61,11 +61,11 @@ function wrapGetConnection(shim, connectable) {
61
61
  return false
62
62
  }
63
63
 
64
- var proto = Object.getPrototypeOf(connectable)
64
+ const proto = Object.getPrototypeOf(connectable)
65
65
  shim.wrap(proto, 'getConnection', function doWrapGetConnection(shim, fn) {
66
66
  return function wrappedGetConnection() {
67
- var args = shim.toArray(arguments)
68
- var cbIdx = args.length - 1
67
+ const args = shim.toArray(arguments)
68
+ const cbIdx = args.length - 1
69
69
 
70
70
  if (shim.isFunction(args[cbIdx]) && !shim.isWrapped(args[cbIdx])) {
71
71
  shim.logger.trace(
@@ -74,7 +74,7 @@ function wrapGetConnection(shim, connectable) {
74
74
  },
75
75
  'Wrapping callback with segment'
76
76
  )
77
- var cb = args[cbIdx]
77
+ let cb = args[cbIdx]
78
78
  if (!shim.__wrappedPoolConnection) {
79
79
  cb = shim.wrap(cb, wrapGetConnectionCallback)
80
80
  }
@@ -119,9 +119,9 @@ function wrapQueriable(shim, queriable, isPoolQuery) {
119
119
  return false
120
120
  }
121
121
 
122
- var proto = Object.getPrototypeOf(queriable)
122
+ const proto = Object.getPrototypeOf(queriable)
123
123
 
124
- var describe
124
+ let describe
125
125
  if (isPoolQuery) {
126
126
  describe = describePoolQuery
127
127
  } else {
@@ -139,8 +139,8 @@ function wrapQueriable(shim, queriable, isPoolQuery) {
139
139
  }
140
140
 
141
141
  function extractQueryArgs(shim, args) {
142
- var query = ''
143
- var callback = null
142
+ let query = ''
143
+ let callback = null
144
144
 
145
145
  // Figure out the query parameter.
146
146
  if (shim.isString(args[0])) {
@@ -168,10 +168,10 @@ function extractQueryArgs(shim, args) {
168
168
 
169
169
  function describeQuery(shim, queryFn, fnName, args) {
170
170
  shim.logger.trace('Recording query')
171
- var extractedArgs = extractQueryArgs(shim, args)
171
+ const extractedArgs = extractQueryArgs(shim, args)
172
172
 
173
173
  // Pull out instance attributes.
174
- var parameters = getInstanceParameters(shim, this, extractedArgs.query)
174
+ const parameters = getInstanceParameters(shim, this, extractedArgs.query)
175
175
 
176
176
  shim.logger.trace(
177
177
  {
@@ -193,7 +193,7 @@ function describeQuery(shim, queryFn, fnName, args) {
193
193
 
194
194
  function describePoolQuery(shim, queryFn, fnName, args) {
195
195
  shim.logger.trace('Recording pool query')
196
- var extractedArgs = extractQueryArgs(shim, args)
196
+ const extractedArgs = extractQueryArgs(shim, args)
197
197
  return {
198
198
  stream: true,
199
199
  query: null,
@@ -204,10 +204,10 @@ function describePoolQuery(shim, queryFn, fnName, args) {
204
204
  }
205
205
 
206
206
  function getInstanceParameters(shim, queryable, query) {
207
- var parameters = { host: null, port_path_or_id: null, database_name: null }
208
- var conf = queryable.config
207
+ const parameters = { host: null, port_path_or_id: null, database_name: null }
208
+ let conf = queryable.config
209
209
  conf = (conf && conf.connectionConfig) || conf
210
- var databaseName = queryable.__NR_databaseName || null
210
+ let databaseName = queryable.__NR_databaseName || null
211
211
  if (conf) {
212
212
  parameters.database_name = databaseName = databaseName || conf.database
213
213
 
@@ -229,7 +229,7 @@ function getInstanceParameters(shim, queryable, query) {
229
229
 
230
230
  function storeDatabaseName(shim, queryable, query) {
231
231
  if (queryable.__NR_storeDatabase) {
232
- var databaseName = dbutils.extractDatabaseChangeFromUse(query)
232
+ const databaseName = dbutils.extractDatabaseChangeFromUse(query)
233
233
  if (databaseName) {
234
234
  shim.setInternalProperty(queryable, '__NR_databaseName', databaseName)
235
235
  }
@@ -5,14 +5,14 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- var logger = require('../logger').child({ component: 'oracle' })
9
- var shimmer = require('../shimmer')
10
- var parseSql = require('../db/parse-sql')
11
- var ORACLE = require('../metrics/names').ORACLE
8
+ const logger = require('../logger').child({ component: 'oracle' })
9
+ const shimmer = require('../shimmer')
10
+ const parseSql = require('../db/parse-sql')
11
+ const ORACLE = require('../metrics/names').ORACLE
12
12
 
13
13
  module.exports = function initialize(agent, oracle) {
14
- var tracer = agent.tracer
15
- var wrapped = false
14
+ const tracer = agent.tracer
15
+ let wrapped = false
16
16
 
17
17
  logger.trace('wrapping oracle.connect and oracle.connectSync')
18
18
 
@@ -31,7 +31,7 @@ module.exports = function initialize(agent, oracle) {
31
31
 
32
32
  shimmer.wrapMethod(oracle, 'Oracle', 'connectSync', function wrapSyncConnect(connect) {
33
33
  return function wrappedSyncConnect() {
34
- var connection = connect.apply(this, arguments)
34
+ const connection = connect.apply(this, arguments)
35
35
  ensureConnectionWrapped(connection)
36
36
  return connection
37
37
  }
@@ -51,13 +51,13 @@ module.exports = function initialize(agent, oracle) {
51
51
  return tracer.wrapFunctionNoSegment(connect, 'connect')
52
52
  })
53
53
 
54
- var proto = Object.getPrototypeOf(connection)
54
+ const proto = Object.getPrototypeOf(connection)
55
55
  wrapConnectionExecute(proto, tracer)
56
56
  wrapConnectionPrepare(proto, tracer)
57
57
 
58
58
  shimmer.wrapMethod(proto, 'Oracle', 'reader', function wrapMethod(createReader) {
59
59
  return function wrappedConnect(sql) {
60
- var reader = createReader.apply(this, arguments)
60
+ const reader = createReader.apply(this, arguments)
61
61
  wrapReader(reader, tracer, sql)
62
62
  return reader
63
63
  }
@@ -73,9 +73,9 @@ function wrapConnectionExecute(connection, tracer) {
73
73
  }
74
74
 
75
75
  function wrappedExecute(segment, args, bind) {
76
- var ps = parseSql(ORACLE.PREFIX, args[0])
77
- var collection = ps.collection
78
- var operation = ps.operation
76
+ const ps = parseSql(ORACLE.PREFIX, args[0])
77
+ const collection = ps.collection
78
+ const operation = ps.operation
79
79
 
80
80
  segment.name = ORACLE.STATEMENT + collection + '/Connection.execute/' + operation
81
81
  logger.trace('capturing oracle query. collection: %s, Operation: %s', collection, operation)
@@ -87,7 +87,7 @@ function wrapConnectionExecute(connection, tracer) {
87
87
  }
88
88
 
89
89
  function wrapReader(reader, tracer, sql) {
90
- var ps = parseSql(ORACLE.PREFIX, sql)
90
+ const ps = parseSql(ORACLE.PREFIX, sql)
91
91
  shimmer.wrapMethod(reader, 'Oracle.Reader', 'nextRow', wrapNextRow)
92
92
  shimmer.wrapMethod(reader, 'Oracle.Reader', 'nextRows', wrapNextRows)
93
93
 
@@ -113,8 +113,8 @@ function wrapConnectionPrepare(connection, tracer) {
113
113
 
114
114
  function wrapPrepare(prepare) {
115
115
  return function wrappedPrepare(sql) {
116
- var ps = parseSql(ORACLE.PREFIX, sql)
117
- var prepared = prepare.apply(this, arguments)
116
+ const ps = parseSql(ORACLE.PREFIX, sql)
117
+ const prepared = prepare.apply(this, arguments)
118
118
  shimmer.wrapMethod(prepared, 'Oracle', 'execute', wrapExecute)
119
119
  return prepared
120
120
 
@@ -8,8 +8,8 @@
8
8
  const semver = require('semver')
9
9
 
10
10
  function getQuery(shim, original, name, args) {
11
- var config = args[0]
12
- var statement
11
+ const config = args[0]
12
+ let statement
13
13
  if (config && (typeof config === 'string' || config instanceof String)) {
14
14
  statement = config
15
15
  } else if (config && config.text) {
@@ -98,11 +98,11 @@ module.exports = function initialize(agent, pgsql, moduleName, shim) {
98
98
  // client. The original getter replaces itself with the instance of the native
99
99
  // client, so only instrument if the getter exists (otherwise assume already
100
100
  // instrumented).
101
- var origGetter = pgsql.__lookupGetter__('native')
101
+ const origGetter = pgsql.__lookupGetter__('native')
102
102
  if (origGetter) {
103
103
  delete pgsql.native
104
104
  pgsql.__defineGetter__('native', function getNative() {
105
- var temp = origGetter()
105
+ const temp = origGetter()
106
106
  if (temp != null) {
107
107
  instrumentPGNative(temp)
108
108
  }