newrelic 9.5.0 → 9.7.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 +14 -0
- package/api.js +2 -0
- package/bin/test-naming-rules.js +1 -1
- package/esm-loader.mjs +1 -3
- package/index.js +6 -5
- package/lib/adaptive-sampler.js +1 -2
- package/lib/agent.js +2 -0
- package/lib/aggregators/event-aggregator.js +2 -2
- package/lib/attributes.js +2 -4
- package/lib/collector/api.js +20 -12
- package/lib/collector/facts.js +1 -3
- package/lib/collector/parse-response.js +3 -1
- package/lib/collector/remote-method.js +10 -10
- package/lib/config/attribute-filter.js +14 -16
- package/lib/config/default.js +544 -286
- package/lib/config/formatters.js +108 -0
- package/lib/config/harvest-config-validator.js +3 -5
- package/lib/config/index.js +74 -93
- package/lib/environment.js +6 -5
- package/lib/errors/error-collector.js +6 -3
- package/lib/errors/helper.js +10 -18
- package/lib/errors/index.js +12 -6
- package/lib/grpc/connection.js +12 -5
- package/lib/header-attributes.js +4 -2
- package/lib/header-processing.js +2 -2
- package/lib/instrumentation/@hapi/hapi.js +231 -1
- package/lib/instrumentation/{vision.js → @hapi/vision.js} +0 -0
- package/lib/instrumentation/@node-redis/client.js +2 -0
- package/lib/instrumentation/amqplib.js +2 -0
- package/lib/instrumentation/core/async_hooks.js +3 -4
- package/lib/instrumentation/core/globals.js +12 -10
- package/lib/instrumentation/core/http-outbound.js +17 -17
- package/lib/instrumentation/core/http.js +16 -27
- package/lib/instrumentation/core/timers.js +5 -1
- package/lib/instrumentation/fastify.js +1 -3
- package/lib/instrumentation/grpc-js/grpc.js +14 -3
- package/lib/instrumentation/memcached.js +5 -0
- package/lib/instrumentation/mongodb/common.js +3 -0
- package/lib/instrumentation/mongodb/v2-mongo.js +6 -3
- package/lib/instrumentation/mongodb.js +1 -1
- package/lib/instrumentation/mysql/mysql.js +6 -5
- package/lib/instrumentation/nr-winston-transport.js +3 -4
- package/lib/instrumentation/promise.js +22 -18
- package/lib/instrumentation/redis.js +2 -0
- package/lib/instrumentation/undici.js +12 -15
- package/lib/instrumentations.js +1 -1
- package/lib/metrics/mapper.js +2 -3
- package/lib/metrics/metric-aggregator.js +1 -3
- package/lib/metrics/names.js +19 -15
- package/lib/metrics/normalizer/rule.js +6 -7
- package/lib/metrics/normalizer/tx_segment.js +3 -2
- package/lib/metrics/normalizer.js +5 -3
- package/lib/parse-proc-cpuinfo.js +11 -6
- package/lib/serverless/api-gateway.js +3 -4
- package/lib/serverless/aws-lambda.js +3 -3
- package/lib/shim/conglomerate-shim.js +2 -3
- package/lib/shim/constants.js +1 -16
- package/lib/shim/datastore-shim.js +24 -105
- package/lib/shim/index.js +7 -0
- package/lib/shim/message-shim.js +2 -0
- package/lib/shim/promise-shim.js +66 -59
- package/lib/shim/shim.js +44 -89
- package/lib/shim/transaction-shim.js +1 -1
- package/lib/shim/webframework-shim.js +4 -8
- package/lib/shimmer.js +29 -23
- package/lib/spans/map-to-streaming-type.js +0 -2
- package/lib/spans/span-context.js +2 -0
- package/lib/spans/span-event-aggregator.js +2 -2
- package/lib/spans/span-event.js +2 -2
- package/lib/spans/span-streamer.js +4 -0
- package/lib/spans/streaming-span-event-aggregator.js +2 -4
- package/lib/spans/streaming-span-event.js +3 -2
- package/lib/symbols.js +26 -0
- package/lib/system-info.js +4 -7
- package/lib/timer.js +8 -6
- package/lib/transaction/dt-payload.js +4 -3
- package/lib/transaction/handle.js +12 -2
- package/lib/transaction/index.js +19 -18
- package/lib/transaction/name-state.js +17 -2
- package/lib/transaction/trace/aggregator.js +4 -12
- package/lib/transaction/trace/index.js +7 -5
- package/lib/transaction/trace/segment.js +6 -11
- package/lib/transaction/tracecontext.js +10 -6
- package/lib/transaction/tracer/index.js +35 -43
- package/lib/transaction/transaction-event-aggregator.js +1 -3
- package/lib/util/arity.js +4 -9
- package/lib/util/attribute-types.js +1 -2
- package/lib/util/byte-limit.js +1 -3
- package/lib/util/cat.js +16 -13
- package/lib/util/codec.js +0 -2
- package/lib/util/copy.js +1 -2
- package/lib/util/deep-equal.js +7 -0
- package/lib/util/flatten.js +4 -6
- package/lib/util/hashes.js +1 -3
- package/lib/util/process-version.js +2 -3
- package/lib/util/properties.js +2 -51
- package/lib/util/stream-sink.js +2 -0
- package/lib/util/urltils.js +4 -10
- package/newrelic.js +1 -1
- package/package.json +2 -1
- package/lib/config/env.js +0 -294
- package/lib/instrumentation/hapi/hapi.js +0 -207
- package/lib/instrumentation/hapi/shared.js +0 -28
- package/lib/instrumentation/hapi.js +0 -254
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 52] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
|
|
9
|
+
|
|
8
10
|
const dbutil = require('../db/utils')
|
|
9
11
|
const hasOwnProperty = require('../util/properties').hasOwn
|
|
10
12
|
const logger = require('../logger').child({ component: 'DatastoreShim' })
|
|
@@ -14,6 +16,7 @@ const ParsedStatement = require('../db/parsed-statement')
|
|
|
14
16
|
const Shim = require('./shim')
|
|
15
17
|
const urltils = require('../util/urltils')
|
|
16
18
|
const util = require('util')
|
|
19
|
+
const symbols = require('../symbols')
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* An enumeration of well-known datastores so that new instrumentations can use
|
|
@@ -67,26 +70,21 @@ const QUERY_PARSERS = {
|
|
|
67
70
|
* Constructs a shim associated with the given agent instance, specialized for
|
|
68
71
|
* instrumenting datastores.
|
|
69
72
|
*
|
|
70
|
-
* @
|
|
71
|
-
* @
|
|
73
|
+
* @class
|
|
74
|
+
* @augments Shim
|
|
72
75
|
* @classdesc
|
|
73
76
|
* A helper class for wrapping datastore modules.
|
|
74
|
-
*
|
|
75
77
|
* @param {Agent} agent
|
|
76
78
|
* The agent this shim will use.
|
|
77
|
-
*
|
|
78
79
|
* @param {string} moduleName
|
|
79
80
|
* The name of the module being instrumented.
|
|
80
|
-
*
|
|
81
81
|
* @param {string} resolvedName
|
|
82
82
|
* The full path to the loaded module.
|
|
83
|
-
*
|
|
84
83
|
* @param {string} [datastoreId]
|
|
85
84
|
* The name of the datastore being instrumented. If available, use one of the
|
|
86
85
|
* values from {@link DatastoreShim.DATASTORE_NAMES}.
|
|
87
86
|
* Calls {@link DatastoreShim#setDatastore} if datastoreId is
|
|
88
87
|
* specified.
|
|
89
|
-
*
|
|
90
88
|
* @see Shim
|
|
91
89
|
* @see DatastoreShim.DATASTORE_NAMES
|
|
92
90
|
*/
|
|
@@ -130,25 +128,18 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
|
|
|
130
128
|
|
|
131
129
|
/**
|
|
132
130
|
* @callback QuerySpecFunction
|
|
133
|
-
*
|
|
134
131
|
* @summary
|
|
135
132
|
* Used for determining information about a query when it can not be simply
|
|
136
133
|
* found in the arguments.
|
|
137
|
-
*
|
|
138
134
|
* @param {Shim} shim
|
|
139
135
|
* The shim this function was passed to.
|
|
140
|
-
*
|
|
141
136
|
* @param {Function} func
|
|
142
137
|
* The function being recorded.
|
|
143
|
-
*
|
|
144
138
|
* @param {string} name
|
|
145
139
|
* The name of the function.
|
|
146
|
-
*
|
|
147
140
|
* @param {Array.<*>} args
|
|
148
141
|
* The arguments being passed into the function.
|
|
149
|
-
*
|
|
150
|
-
* @return {QuerySpec} The spec for how this query should be recorded.
|
|
151
|
-
*
|
|
142
|
+
* @returns {QuerySpec} The spec for how this query should be recorded.
|
|
152
143
|
* @see DatastoreShim#recordQuery
|
|
153
144
|
* @see DatastoreShim#recordBatchQuery
|
|
154
145
|
* @see QuerySpec
|
|
@@ -156,68 +147,50 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
|
|
|
156
147
|
|
|
157
148
|
/**
|
|
158
149
|
* @callback QueryFunction
|
|
159
|
-
*
|
|
160
150
|
* @summary
|
|
161
151
|
* Pulls the query argument out from an array of arguments.
|
|
162
|
-
*
|
|
163
152
|
* @param {Shim} shim
|
|
164
153
|
* The shim this function was passed to.
|
|
165
|
-
*
|
|
166
154
|
* @param {Function} func
|
|
167
155
|
* The function being recorded.
|
|
168
|
-
*
|
|
169
156
|
* @param {string} name
|
|
170
157
|
* The name of the function.
|
|
171
|
-
*
|
|
172
158
|
* @param {Array.<*>} args
|
|
173
159
|
* The arguments being passed into the function.
|
|
174
|
-
*
|
|
175
|
-
* @return {string} The query string from the arguments list.
|
|
176
|
-
*
|
|
160
|
+
* @returns {string} The query string from the arguments list.
|
|
177
161
|
* @see QuerySpec
|
|
178
162
|
* @see QuerySpecFunction
|
|
179
163
|
*/
|
|
180
164
|
|
|
181
165
|
/**
|
|
182
166
|
* @callback QueryParserFunction
|
|
183
|
-
*
|
|
184
167
|
* @summary
|
|
185
168
|
* Used to parse queries to extract the basic information about it.
|
|
186
|
-
*
|
|
187
169
|
* @param {string} query - The query to be parsed.
|
|
188
|
-
*
|
|
189
|
-
* @return {ParsedQueryData} An object containing the basic information about
|
|
170
|
+
* @returns {ParsedQueryData} An object containing the basic information about
|
|
190
171
|
* the query.
|
|
191
|
-
*
|
|
192
172
|
* @see DatastoreShim#setParser
|
|
193
173
|
* @see ParsedQueryData
|
|
194
174
|
*/
|
|
195
175
|
|
|
196
176
|
/**
|
|
197
177
|
* @interface OperationSpec
|
|
198
|
-
*
|
|
199
178
|
* @description
|
|
200
179
|
* Describes the interface for an operation function.
|
|
201
|
-
*
|
|
202
180
|
* @property {string} [name]
|
|
203
181
|
* The name for this operation. If omitted, the operation function's name will
|
|
204
182
|
* used instead.
|
|
205
|
-
*
|
|
206
183
|
* @property {DatastoreParameters} [parameters]
|
|
207
184
|
* Extra parameters to be set on the metric for the operation.
|
|
208
|
-
*
|
|
209
185
|
* @property {bool} [record=true]
|
|
210
186
|
* Indicates if the operation should be recorded as a metric. A segment will be
|
|
211
187
|
* created even if this is `false`.
|
|
212
|
-
*
|
|
213
188
|
* @property {number|CallbackBindFunction} [callback]
|
|
214
189
|
* If a number, it is the offset in the arguments array for the operation's
|
|
215
190
|
* callback argument. If it is a function, it should perform the segment
|
|
216
191
|
* binding to the callback.
|
|
217
|
-
*
|
|
218
192
|
* @property {bool} [promise=false]
|
|
219
193
|
* If `true`, the return value will be wrapped as a Promise.
|
|
220
|
-
*
|
|
221
194
|
* @see DatastoreShim#recordOperation
|
|
222
195
|
* @see QuerySpec
|
|
223
196
|
* @see DatastoreParameters
|
|
@@ -225,20 +198,16 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
|
|
|
225
198
|
|
|
226
199
|
/**
|
|
227
200
|
* @interface QuerySpec
|
|
228
|
-
* @
|
|
229
|
-
*
|
|
201
|
+
* @augments OperationSpec
|
|
230
202
|
* @description
|
|
231
203
|
* Describes the interface for a query function. Extends {@link OperationSpec}
|
|
232
204
|
* with query-specific parameters.
|
|
233
|
-
*
|
|
234
205
|
* @property {bool} [stream=false]
|
|
235
206
|
* If `true`, the return value will be wrapped as a stream.
|
|
236
|
-
*
|
|
237
207
|
* @property {number|string|QueryFunction} query
|
|
238
208
|
* If a number, it is the offset in the arguments array for the query string
|
|
239
209
|
* argument. If a string, it is the query being executed. If a function, it
|
|
240
210
|
* will be passed the arguments and must return the query string.
|
|
241
|
-
*
|
|
242
211
|
* @see DatastoreShim#recordQuery
|
|
243
212
|
* @see DatastoreShim#recordBatchQuery
|
|
244
213
|
* @see QuerySpecFunction
|
|
@@ -249,44 +218,34 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
|
|
|
249
218
|
|
|
250
219
|
/**
|
|
251
220
|
* @interface DatastoreParameters
|
|
252
|
-
*
|
|
253
221
|
* @description
|
|
254
222
|
* Extra parameters which may be added to an operation or query segment. All of
|
|
255
223
|
* these properties are optional.
|
|
256
|
-
*
|
|
257
224
|
* @property {string} host
|
|
258
225
|
* The host of the database server being interacted with. If provided, along
|
|
259
226
|
* with `port_path_or_id`, then an instance metric will also be generated for
|
|
260
227
|
* this database.
|
|
261
|
-
*
|
|
262
228
|
* @property {number|string} port_path_or_id
|
|
263
229
|
* The port number or path to domain socket used to connect to the database
|
|
264
230
|
* server.
|
|
265
|
-
*
|
|
266
231
|
* @property {string} database_name
|
|
267
232
|
* The name of the database being queried or operated on.
|
|
268
|
-
*
|
|
269
233
|
* @see OperationSpec
|
|
270
234
|
* @see QuerySpec
|
|
271
235
|
*/
|
|
272
236
|
|
|
273
237
|
/**
|
|
274
238
|
* @interface ParsedQueryData
|
|
275
|
-
*
|
|
276
239
|
* @description
|
|
277
240
|
* Returned by a {@link QueryParserFunction}, this information is used to
|
|
278
241
|
* generate the name for recording datastore queries.
|
|
279
|
-
*
|
|
280
242
|
* @property {string} operation
|
|
281
243
|
* The datastore operation such as `SELECT` or `UPDATE`.
|
|
282
|
-
*
|
|
283
244
|
* @property {string} collection
|
|
284
245
|
* The collection being queried. This would be the table name from a SQL
|
|
285
246
|
* statement or the collection name in a MongoDB query.
|
|
286
|
-
*
|
|
287
247
|
* @property {string} [query]
|
|
288
248
|
* The query with any sensitive information redacted and comments removed.
|
|
289
|
-
*
|
|
290
249
|
* @see DatastoreShim#setParser
|
|
291
250
|
* @see QueryParserFunction
|
|
292
251
|
*/
|
|
@@ -303,11 +262,9 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
|
|
|
303
262
|
* segments or metrics.
|
|
304
263
|
*
|
|
305
264
|
* @memberof DatastoreShim.prototype
|
|
306
|
-
*
|
|
307
265
|
* @param {string} datastore
|
|
308
266
|
* The name of this datastore. Use one of the well-known constants listed in
|
|
309
267
|
* {@link DatastoreShim.DATASTORE_NAMES} if available for the datastore.
|
|
310
|
-
*
|
|
311
268
|
* @see DatastoreShim.DATASTORE_NAMES
|
|
312
269
|
* @see DatastoreShim#recordBatchQuery
|
|
313
270
|
* @see DatastoreShim#recordQuery
|
|
@@ -333,12 +290,10 @@ function setDatastore(datastore) {
|
|
|
333
290
|
* Sets the query parser used by this shim instance.
|
|
334
291
|
*
|
|
335
292
|
* @memberof DatastoreShim.prototype
|
|
336
|
-
*
|
|
337
293
|
* @param {string|QueryParserFunction} parser
|
|
338
294
|
* The string used to look up a default parser or the function used to parse
|
|
339
295
|
* queries. It is recommended that you use one of the well-known constants if
|
|
340
296
|
* available in the {@link DatastoreShim.QUERY_PARSERS}.
|
|
341
|
-
*
|
|
342
297
|
* @see DatastoreShim.QUERY_PARSERS
|
|
343
298
|
* @see QueryParserFunction
|
|
344
299
|
* @see ParsedQueryData
|
|
@@ -374,20 +329,15 @@ function setParser(parser) {
|
|
|
374
329
|
* will result in an exception.
|
|
375
330
|
*
|
|
376
331
|
* @memberof DatastoreShim.prototype
|
|
377
|
-
*
|
|
378
|
-
* @param {Object|Function} nodule
|
|
332
|
+
* @param {object | Function} nodule
|
|
379
333
|
* The source for the properties to wrap, or a single function to wrap.
|
|
380
|
-
*
|
|
381
334
|
* @param {string|Array.<string>} [properties]
|
|
382
335
|
* One or more properties to wrap. If omitted, the `nodule` parameter is
|
|
383
336
|
* assumed to be the function to wrap.
|
|
384
|
-
*
|
|
385
337
|
* @param {OperationSpec|SegmentFunction} opSpec
|
|
386
338
|
* The spec for this operation function.
|
|
387
|
-
*
|
|
388
|
-
* @return {Object|Function} The first parameter to this function, after
|
|
339
|
+
* @returns {object | Function} The first parameter to this function, after
|
|
389
340
|
* wrapping it or its properties.
|
|
390
|
-
*
|
|
391
341
|
* @see Shim#wrap
|
|
392
342
|
* @see Shim#record
|
|
393
343
|
* @see OperationSpec
|
|
@@ -451,20 +401,15 @@ function recordOperation(nodule, properties, opSpec) {
|
|
|
451
401
|
* will result in an exception.
|
|
452
402
|
*
|
|
453
403
|
* @memberof DatastoreShim.prototype
|
|
454
|
-
*
|
|
455
|
-
* @param {Object|Function} nodule
|
|
404
|
+
* @param {object | Function} nodule
|
|
456
405
|
* The source for the properties to wrap, or a single function to wrap.
|
|
457
|
-
*
|
|
458
406
|
* @param {string|Array.<string>} [properties]
|
|
459
407
|
* One or more properties to wrap. If omitted, the `nodule` parameter is
|
|
460
408
|
* assumed to be the function to wrap.
|
|
461
|
-
*
|
|
462
409
|
* @param {QuerySpec|QuerySpecFunction} querySpec
|
|
463
410
|
* The spec for this query function.
|
|
464
|
-
*
|
|
465
|
-
* @return {Object|Function} The first parameter to this function, after
|
|
411
|
+
* @returns {object | Function} The first parameter to this function, after
|
|
466
412
|
* wrapping it or its properties.
|
|
467
|
-
*
|
|
468
413
|
* @see Shim#wrap
|
|
469
414
|
* @see Shim#record
|
|
470
415
|
* @see DatastoreShim#recordBatchQuery
|
|
@@ -489,20 +434,15 @@ function recordQuery(nodule, properties, querySpec) {
|
|
|
489
434
|
* will result in an exception.
|
|
490
435
|
*
|
|
491
436
|
* @memberof DatastoreShim.prototype
|
|
492
|
-
*
|
|
493
|
-
* @param {Object|Function} nodule
|
|
437
|
+
* @param {object | Function} nodule
|
|
494
438
|
* The source for the properties to wrap, or a single function to wrap.
|
|
495
|
-
*
|
|
496
439
|
* @param {string|Array.<string>} [properties]
|
|
497
440
|
* One or more properties to wrap. If omitted, the `nodule` parameter is
|
|
498
441
|
* assumed to be the function to wrap.
|
|
499
|
-
*
|
|
500
442
|
* @param {QuerySpec|QuerySpecFunction} querySpec
|
|
501
443
|
* The spec for this query function.
|
|
502
|
-
*
|
|
503
|
-
* @return {Object|Function} The first parameter to this function, after
|
|
444
|
+
* @returns {object | Function} The first parameter to this function, after
|
|
504
445
|
* wrapping it or its properties.
|
|
505
|
-
*
|
|
506
446
|
* @see Shim#wrap
|
|
507
447
|
* @see Shim#record
|
|
508
448
|
* @see DatastoreShim#recordQuery
|
|
@@ -521,13 +461,9 @@ function recordBatchQuery(nodule, properties, querySpec) {
|
|
|
521
461
|
* will result in an exception.
|
|
522
462
|
*
|
|
523
463
|
* @memberof DatastoreShim.prototype
|
|
524
|
-
*
|
|
525
464
|
* @param {string} query - The query to parse.
|
|
526
|
-
*
|
|
527
|
-
* @
|
|
528
|
-
*
|
|
529
|
-
* @return {ParsedStatement} The parsed query object.
|
|
530
|
-
*
|
|
465
|
+
* @param {object} nodule - Context for the queryParse to run under.
|
|
466
|
+
* @returns {ParsedStatement} The parsed query object.
|
|
531
467
|
* @see DatastoreShim#setParser
|
|
532
468
|
*/
|
|
533
469
|
function parseQuery(query, nodule) {
|
|
@@ -562,13 +498,10 @@ function parseQuery(query, nodule) {
|
|
|
562
498
|
* - `bindRowCallbackSegment(args, cbIdx [, parentSegment])`
|
|
563
499
|
*
|
|
564
500
|
* @memberof DatastoreShim.prototype
|
|
565
|
-
*
|
|
566
501
|
* @param {Array} args
|
|
567
502
|
* The arguments array to replace the callback in.
|
|
568
|
-
*
|
|
569
|
-
* @param {Number} cbIdx
|
|
503
|
+
* @param {number} cbIdx
|
|
570
504
|
* The index of the callback in the arguments array.
|
|
571
|
-
*
|
|
572
505
|
* @param {TraceSegment} [parentSegment]
|
|
573
506
|
* Optional. The segment to be the parent row callback's segment. Defaults to
|
|
574
507
|
* the segment active when the row callback is first called.
|
|
@@ -616,7 +549,7 @@ function bindRowCallbackSegment(args, cbIdx, parentSegment) {
|
|
|
616
549
|
}, parentSegment)
|
|
617
550
|
|
|
618
551
|
// Mark this as wrapped and put it in the args array.
|
|
619
|
-
|
|
552
|
+
wrapper[symbols.original] = cb
|
|
620
553
|
args[idx] = wrapper
|
|
621
554
|
}
|
|
622
555
|
|
|
@@ -626,7 +559,6 @@ function bindRowCallbackSegment(args, cbIdx, parentSegment) {
|
|
|
626
559
|
* If the current segment was not created by this shim then no action is taken.
|
|
627
560
|
*
|
|
628
561
|
* @memberof DatastoreShim.prototype
|
|
629
|
-
*
|
|
630
562
|
* @param {string} host - The name of the database host.
|
|
631
563
|
* @param {number|string} port - The port, path, or ID of the database server.
|
|
632
564
|
* @param {string} database - The name of the database in use.
|
|
@@ -661,8 +593,7 @@ function captureInstanceAttributes(host, port, database) {
|
|
|
661
593
|
* Parses the database name from a `USE` SQL query.
|
|
662
594
|
*
|
|
663
595
|
* @param {string} query - The SQL query to parse the database name from.
|
|
664
|
-
*
|
|
665
|
-
* @return {?string} The name of the database if it could be parsed, otherwise
|
|
596
|
+
* @returns {?string} The name of the database if it could be parsed, otherwise
|
|
666
597
|
* `null`.
|
|
667
598
|
*/
|
|
668
599
|
function getDatabaseNameFromUseQuery(query) {
|
|
@@ -682,23 +613,17 @@ function getDatabaseNameFromUseQuery(query) {
|
|
|
682
613
|
*
|
|
683
614
|
* @private
|
|
684
615
|
* @this DatastoreShim
|
|
685
|
-
*
|
|
686
616
|
* @param {string} suffix
|
|
687
617
|
* Suffix to be added to the segment name.
|
|
688
|
-
*
|
|
689
|
-
* @param {Object|Function} nodule
|
|
618
|
+
* @param {object | Function} nodule
|
|
690
619
|
* The source for the properties to wrap, or a single function to wrap.
|
|
691
|
-
*
|
|
692
620
|
* @param {string|Array.<string>} [properties]
|
|
693
621
|
* One or more properties to wrap. If omitted, the `nodule` parameter is
|
|
694
622
|
* assumed to be the function to wrap.
|
|
695
|
-
*
|
|
696
623
|
* @param {QuerySpec|QueryFunction} querySpec
|
|
697
624
|
* The spec for this query function.
|
|
698
|
-
*
|
|
699
|
-
* @return {Object|Function} The first parameter to this function, after
|
|
625
|
+
* @returns {object | Function} The first parameter to this function, after
|
|
700
626
|
* wrapping it or its properties.
|
|
701
|
-
*
|
|
702
627
|
* @see Shim#wrap
|
|
703
628
|
* @see Shim#record
|
|
704
629
|
* @see DatastoreShim#recordQuery
|
|
@@ -785,10 +710,8 @@ function _recordQuery(suffix, nodule, properties, querySpec) {
|
|
|
785
710
|
* @private
|
|
786
711
|
* @this DatastoreShim
|
|
787
712
|
* @implements {MetricFunction}
|
|
788
|
-
*
|
|
789
713
|
* @param {TraceSegment} segment - The segment being recorded.
|
|
790
714
|
* @param {string} [scope] - The scope of the segment.
|
|
791
|
-
*
|
|
792
715
|
* @see DatastoreShim#recordOperation
|
|
793
716
|
* @see MetricFunction
|
|
794
717
|
*/
|
|
@@ -838,14 +761,12 @@ function _recordOperationMetrics(segment, scope) {
|
|
|
838
761
|
*
|
|
839
762
|
* @private
|
|
840
763
|
* @this DatastoreShim
|
|
841
|
-
*
|
|
842
764
|
* @param {Function} fn - The query function to be executed.
|
|
843
765
|
* @param {string} fnName - The name of the query function.
|
|
844
766
|
* @param {QuerySpec} spec - The query spec.
|
|
845
767
|
* @param {*} ctx - The context of the query function's execution.
|
|
846
768
|
* @param {Array} args - The arguments for the query function.
|
|
847
|
-
*
|
|
848
|
-
* @return {?string} The query from the arguments if found, otherwise `null`.
|
|
769
|
+
* @returns {?string} The query from the arguments if found, otherwise `null`.
|
|
849
770
|
*/
|
|
850
771
|
function _extractQueryStr(fn, fnName, spec, ctx, args) {
|
|
851
772
|
let queryStr = spec.query
|
|
@@ -873,10 +794,8 @@ function _extractQueryStr(fn, fnName, spec, ctx, args) {
|
|
|
873
794
|
*
|
|
874
795
|
* @private
|
|
875
796
|
* @this DatastoreShim
|
|
876
|
-
*
|
|
877
797
|
* @param {object} [parameters={}] - The segment parameters to clean up.
|
|
878
|
-
*
|
|
879
|
-
* @return {object} - The normalized segment parameters.
|
|
798
|
+
* @returns {object} - The normalized segment parameters.
|
|
880
799
|
*/
|
|
881
800
|
function _normalizeParameters(parameters) {
|
|
882
801
|
parameters = parameters || Object.create(null)
|
package/lib/shim/index.js
CHANGED
|
@@ -24,6 +24,13 @@ SHIM_TYPE_MAP[constants.MODULE_TYPE.PROMISE] = PromiseShim
|
|
|
24
24
|
SHIM_TYPE_MAP[constants.MODULE_TYPE.TRANSACTION] = TransactionShim
|
|
25
25
|
SHIM_TYPE_MAP[constants.MODULE_TYPE.WEB_FRAMEWORK] = WebFrameworkShim
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param type
|
|
30
|
+
* @param agent
|
|
31
|
+
* @param moduleName
|
|
32
|
+
* @param resolvedName
|
|
33
|
+
*/
|
|
27
34
|
function createShimFromType(type, agent, moduleName, resolvedName) {
|
|
28
35
|
let shim = null
|
|
29
36
|
if (properties.hasOwn(SHIM_TYPE_MAP, type)) {
|
package/lib/shim/message-shim.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/* eslint sonarjs/cognitive-complexity: ["error", 72] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252*/
|
|
9
|
+
|
|
8
10
|
const copy = require('../util/copy')
|
|
9
11
|
const genericRecorder = require('../metrics/recorders/generic')
|
|
10
12
|
const logger = require('../logger').child({ component: 'MessageShim' })
|