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.
- package/NEWS.md +34 -0
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/api.js +74 -68
- package/bin/test-naming-rules.js +22 -22
- package/lib/agent.js +4 -4
- package/lib/attributes.js +2 -2
- package/lib/collector/api.js +12 -12
- package/lib/collector/facts.js +1 -1
- package/lib/collector/http-agents.js +12 -11
- package/lib/collector/key-parser.js +1 -1
- package/lib/collector/remote-method.js +27 -26
- package/lib/config/attribute-filter.js +23 -23
- package/lib/config/default.js +12 -10
- package/lib/config/hsm.js +1 -1
- package/lib/config/index.js +82 -66
- package/lib/config/lasp.js +3 -3
- package/lib/config/merge-server-config.js +1 -1
- package/lib/db/parse-sql.js +8 -8
- package/lib/db/parsed-statement.js +9 -8
- package/lib/db/query-parsers/sql.js +7 -7
- package/lib/db/query-sample.js +9 -9
- package/lib/db/query-trace-aggregator.js +4 -4
- package/lib/db/statement-matcher.js +5 -5
- package/lib/db/utils.js +1 -1
- package/lib/environment.js +43 -43
- package/lib/errors/error-collector.js +2 -2
- package/lib/errors/error-trace-aggregator.js +1 -1
- package/lib/errors/helper.js +3 -3
- package/lib/errors/index.js +17 -17
- package/lib/header-attributes.js +6 -6
- package/lib/header-processing.js +1 -1
- package/lib/instrumentation/amqplib.js +26 -26
- package/lib/instrumentation/bluebird.js +3 -3
- package/lib/instrumentation/cassandra-driver.js +7 -3
- package/lib/instrumentation/connect.js +4 -4
- package/lib/instrumentation/core/async_hooks.js +6 -6
- package/lib/instrumentation/core/domain.js +2 -2
- package/lib/instrumentation/core/globals.js +1 -1
- package/lib/instrumentation/core/http-outbound.js +14 -83
- package/lib/instrumentation/core/http.js +34 -67
- package/lib/instrumentation/core/inspector.js +2 -2
- package/lib/instrumentation/core/timers.js +7 -7
- package/lib/instrumentation/core/zlib.js +2 -2
- package/lib/instrumentation/director.js +4 -4
- package/lib/instrumentation/express.js +8 -8
- package/lib/instrumentation/generic-pool.js +1 -1
- package/lib/instrumentation/hapi/hapi-17.js +11 -11
- package/lib/instrumentation/hapi/shared.js +1 -1
- package/lib/instrumentation/hapi.js +22 -22
- package/lib/instrumentation/ioredis.js +7 -7
- package/lib/instrumentation/memcached.js +7 -7
- package/lib/instrumentation/mongodb/common.js +4 -1
- package/lib/instrumentation/mysql.js +19 -19
- package/lib/instrumentation/oracle.js +15 -15
- package/lib/instrumentation/pg.js +4 -4
- package/lib/instrumentation/promise.js +46 -46
- package/lib/instrumentation/q.js +2 -2
- package/lib/instrumentation/redis.js +11 -11
- package/lib/instrumentation/restify.js +1 -1
- package/lib/instrumentation/vision.js +4 -4
- package/lib/instrumentation/when.js +3 -3
- package/lib/instrumentations.js +1 -1
- package/lib/logger.js +5 -5
- package/lib/metrics/index.js +15 -15
- package/lib/metrics/mapper.js +7 -7
- package/lib/metrics/normalizer/rule.js +9 -9
- package/lib/metrics/normalizer/tx_segment.js +17 -17
- package/lib/metrics/normalizer.js +22 -22
- package/lib/metrics/recorders/custom.js +5 -5
- package/lib/metrics/recorders/generic.js +3 -3
- package/lib/metrics/recorders/http.js +7 -7
- package/lib/metrics/recorders/http_external.js +7 -7
- package/lib/metrics/recorders/message-transaction.js +5 -6
- package/lib/metrics/recorders/other.js +5 -5
- package/lib/parse-proc-cpuinfo.js +18 -18
- package/lib/parse-proc-meminfo.js +2 -2
- package/lib/prioritized-attributes.js +2 -2
- package/lib/priority-queue.js +10 -10
- package/lib/reservoir.js +3 -3
- package/lib/sampler.js +26 -26
- package/lib/shim/datastore-shim.js +35 -32
- package/lib/shim/index.js +2 -2
- package/lib/shim/message-shim.js +47 -47
- package/lib/shim/promise-shim.js +1 -1
- package/lib/shim/shim.js +61 -61
- package/lib/shim/specs/index.js +3 -3
- package/lib/shim/transaction-shim.js +44 -192
- package/lib/shim/webframework-shim.js +52 -52
- package/lib/spans/span-event.js +1 -1
- package/lib/spans/streaming-span-attributes.js +1 -1
- package/lib/stats/apdex.js +2 -2
- package/lib/stats/index.js +2 -2
- package/lib/system-info.js +23 -23
- package/lib/timer.js +5 -5
- package/lib/transaction/dt-payload.js +1 -1
- package/lib/transaction/index.js +40 -40
- package/lib/transaction/name-state.js +14 -14
- package/lib/transaction/trace/exclusive-time-calculator.js +6 -6
- package/lib/transaction/trace/index.js +14 -14
- package/lib/transaction/trace/segment.js +18 -18
- package/lib/transaction/tracecontext.js +1 -1
- package/lib/transaction/tracer/index.js +53 -49
- package/lib/uninstrumented.js +7 -7
- package/lib/util/arity.js +2 -2
- package/lib/util/byte-limit.js +4 -4
- package/lib/util/cat.js +269 -24
- package/lib/util/codec.js +2 -2
- package/lib/util/copy.js +2 -2
- package/lib/util/deep-equal.js +10 -10
- package/lib/util/flatten.js +4 -4
- package/lib/util/hashes.js +14 -14
- package/lib/util/label-parser.js +17 -17
- package/lib/util/logger.js +24 -24
- package/lib/util/process-version.js +2 -2
- package/lib/util/properties.js +4 -4
- package/lib/util/sql/obfuscate.js +15 -15
- package/lib/util/stream-sink.js +3 -3
- package/lib/util/unwrapped-core.js +2 -2
- package/lib/util/urltils.js +16 -16
- package/lib/utilization/aws-info.js +7 -7
- package/lib/utilization/azure-info.js +6 -6
- package/lib/utilization/common.js +13 -13
- package/lib/utilization/docker-info.js +11 -11
- package/lib/utilization/gcp-info.js +4 -4
- package/lib/utilization/index.js +5 -5
- package/lib/utilization/pcf-info.js +9 -9
- package/package.json +7 -2
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
135
|
+
const args = shim.argsToArray.apply(shim, arguments)
|
|
136
136
|
|
|
137
137
|
if (shim.isArray(event)) {
|
|
138
|
-
for (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
203
|
+
const req = args[0]
|
|
204
204
|
return req && req.raw && req.raw.req
|
|
205
205
|
}
|
|
206
206
|
})
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
+
const args = shim.argsToArray.apply(shim, arguments)
|
|
50
50
|
|
|
51
|
-
|
|
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
|
-
|
|
61
|
-
|
|
60
|
+
const generatorArgs = shim.argsToArray.apply(shim, arguments)
|
|
61
|
+
const handler = generator.apply(this, generatorArgs)
|
|
62
62
|
if (typeof handler === 'function') {
|
|
63
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
122
|
+
const args = shim.argsToArray.apply(shim, arguments)
|
|
123
123
|
|
|
124
124
|
if (shim.isArray(event)) {
|
|
125
|
-
for (
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
+
const command = args[0]
|
|
22
22
|
|
|
23
23
|
// TODO: Instance attributes for ioredis
|
|
24
|
-
|
|
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
|
-
|
|
29
|
+
const keys = command.args
|
|
30
30
|
if (keys && typeof keys !== 'function') {
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
64
|
+
const proto = Object.getPrototypeOf(connectable)
|
|
65
65
|
shim.wrap(proto, 'getConnection', function doWrapGetConnection(shim, fn) {
|
|
66
66
|
return function wrappedGetConnection() {
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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
|
-
|
|
122
|
+
const proto = Object.getPrototypeOf(queriable)
|
|
123
123
|
|
|
124
|
-
|
|
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
|
-
|
|
143
|
-
|
|
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
|
-
|
|
171
|
+
const extractedArgs = extractQueryArgs(shim, args)
|
|
172
172
|
|
|
173
173
|
// Pull out instance attributes.
|
|
174
|
-
|
|
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
|
-
|
|
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
|
-
|
|
208
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
117
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
101
|
+
const origGetter = pgsql.__lookupGetter__('native')
|
|
102
102
|
if (origGetter) {
|
|
103
103
|
delete pgsql.native
|
|
104
104
|
pgsql.__defineGetter__('native', function getNative() {
|
|
105
|
-
|
|
105
|
+
const temp = origGetter()
|
|
106
106
|
if (temp != null) {
|
|
107
107
|
instrumentPGNative(temp)
|
|
108
108
|
}
|