newrelic 9.6.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.
Files changed (90) hide show
  1. package/NEWS.md +4 -0
  2. package/api.js +2 -0
  3. package/bin/test-naming-rules.js +1 -1
  4. package/esm-loader.mjs +1 -3
  5. package/lib/adaptive-sampler.js +1 -2
  6. package/lib/agent.js +2 -0
  7. package/lib/aggregators/event-aggregator.js +2 -2
  8. package/lib/attributes.js +2 -4
  9. package/lib/collector/api.js +20 -12
  10. package/lib/collector/facts.js +1 -3
  11. package/lib/collector/parse-response.js +3 -1
  12. package/lib/collector/remote-method.js +8 -9
  13. package/lib/config/attribute-filter.js +14 -16
  14. package/lib/config/default.js +17 -0
  15. package/lib/config/harvest-config-validator.js +3 -5
  16. package/lib/config/index.js +7 -4
  17. package/lib/environment.js +6 -5
  18. package/lib/errors/error-collector.js +6 -3
  19. package/lib/errors/helper.js +10 -18
  20. package/lib/errors/index.js +12 -6
  21. package/lib/grpc/connection.js +12 -5
  22. package/lib/header-attributes.js +4 -2
  23. package/lib/header-processing.js +2 -2
  24. package/lib/instrumentation/@hapi/hapi.js +2 -0
  25. package/lib/instrumentation/@node-redis/client.js +2 -0
  26. package/lib/instrumentation/amqplib.js +2 -0
  27. package/lib/instrumentation/core/async_hooks.js +2 -0
  28. package/lib/instrumentation/core/globals.js +11 -8
  29. package/lib/instrumentation/core/http-outbound.js +14 -12
  30. package/lib/instrumentation/core/http.js +10 -8
  31. package/lib/instrumentation/core/timers.js +2 -0
  32. package/lib/instrumentation/fastify.js +1 -3
  33. package/lib/instrumentation/grpc-js/grpc.js +14 -3
  34. package/lib/instrumentation/memcached.js +5 -0
  35. package/lib/instrumentation/mongodb/common.js +3 -0
  36. package/lib/instrumentation/mongodb/v2-mongo.js +6 -3
  37. package/lib/instrumentation/mongodb.js +1 -1
  38. package/lib/instrumentation/nr-winston-transport.js +3 -4
  39. package/lib/instrumentation/promise.js +7 -4
  40. package/lib/instrumentation/redis.js +2 -0
  41. package/lib/instrumentation/undici.js +2 -0
  42. package/lib/metrics/mapper.js +2 -3
  43. package/lib/metrics/metric-aggregator.js +1 -3
  44. package/lib/metrics/names.js +19 -15
  45. package/lib/metrics/normalizer/rule.js +6 -7
  46. package/lib/metrics/normalizer/tx_segment.js +3 -2
  47. package/lib/metrics/normalizer.js +5 -3
  48. package/lib/parse-proc-cpuinfo.js +11 -6
  49. package/lib/serverless/api-gateway.js +3 -4
  50. package/lib/serverless/aws-lambda.js +3 -3
  51. package/lib/shim/conglomerate-shim.js +2 -3
  52. package/lib/shim/datastore-shim.js +22 -104
  53. package/lib/shim/index.js +7 -0
  54. package/lib/shim/message-shim.js +2 -0
  55. package/lib/shim/promise-shim.js +48 -42
  56. package/lib/shim/shim.js +7 -7
  57. package/lib/shim/webframework-shim.js +2 -0
  58. package/lib/spans/map-to-streaming-type.js +0 -2
  59. package/lib/spans/span-context.js +2 -0
  60. package/lib/spans/span-event-aggregator.js +2 -2
  61. package/lib/spans/span-event.js +2 -2
  62. package/lib/spans/span-streamer.js +4 -0
  63. package/lib/spans/streaming-span-event-aggregator.js +2 -4
  64. package/lib/spans/streaming-span-event.js +3 -2
  65. package/lib/system-info.js +3 -5
  66. package/lib/timer.js +8 -6
  67. package/lib/transaction/dt-payload.js +4 -3
  68. package/lib/transaction/handle.js +12 -2
  69. package/lib/transaction/index.js +19 -18
  70. package/lib/transaction/name-state.js +17 -2
  71. package/lib/transaction/trace/aggregator.js +4 -12
  72. package/lib/transaction/trace/index.js +7 -5
  73. package/lib/transaction/trace/segment.js +6 -11
  74. package/lib/transaction/tracecontext.js +10 -6
  75. package/lib/transaction/tracer/index.js +23 -25
  76. package/lib/transaction/transaction-event-aggregator.js +1 -3
  77. package/lib/util/attribute-types.js +1 -2
  78. package/lib/util/byte-limit.js +1 -3
  79. package/lib/util/cat.js +16 -13
  80. package/lib/util/codec.js +0 -2
  81. package/lib/util/copy.js +1 -2
  82. package/lib/util/deep-equal.js +7 -0
  83. package/lib/util/flatten.js +4 -6
  84. package/lib/util/hashes.js +1 -3
  85. package/lib/util/process-version.js +2 -3
  86. package/lib/util/properties.js +2 -5
  87. package/lib/util/stream-sink.js +2 -0
  88. package/lib/util/urltils.js +4 -10
  89. package/newrelic.js +1 -1
  90. package/package.json +2 -1
@@ -10,6 +10,10 @@ const NODEJS = {
10
10
  }
11
11
 
12
12
  const ALL = 'all'
13
+ const POSTGRES_LITERAL = 'Postgres'
14
+ const CASSANDRA_LITERAL = 'Cassandra'
15
+ const EXPRESS_LITERAL = 'Expressjs'
16
+ const OTHER_TRANSACTION_MESSAGE = 'OtherTransaction/Message'
13
17
 
14
18
  const SUPPORTABILITY = {
15
19
  PREFIX: 'Supportability/',
@@ -133,24 +137,24 @@ const REDIS = {
133
137
  }
134
138
 
135
139
  const POSTGRES = {
136
- PREFIX: 'Postgres',
137
- STATEMENT: DB.STATEMENT + '/Postgres/',
138
- OPERATION: DB.OPERATION + '/Postgres/',
139
- INSTANCE: DB.INSTANCE + '/Postgres/'
140
+ PREFIX: POSTGRES_LITERAL,
141
+ STATEMENT: DB.STATEMENT + `/${POSTGRES_LITERAL}/`,
142
+ OPERATION: DB.OPERATION + `/${POSTGRES_LITERAL}/`,
143
+ INSTANCE: DB.INSTANCE + `/${POSTGRES_LITERAL}/`
140
144
  }
141
145
 
142
146
  const CASSANDRA = {
143
- PREFIX: 'Cassandra',
144
- OPERATION: DB.OPERATION + '/Cassandra/',
145
- STATEMENT: DB.STATEMENT + '/Cassandra/',
146
- INSTANCE: DB.INSTANCE + '/Cassandra/',
147
- ALL: DB.PREFIX + 'Cassandra/' + ALL
147
+ PREFIX: CASSANDRA_LITERAL,
148
+ OPERATION: DB.OPERATION + `/${CASSANDRA_LITERAL}/`,
149
+ STATEMENT: DB.STATEMENT + `/${CASSANDRA_LITERAL}/`,
150
+ INSTANCE: DB.INSTANCE + `/${CASSANDRA_LITERAL}/`,
151
+ ALL: DB.PREFIX + `${CASSANDRA_LITERAL}/` + ALL
148
152
  }
149
153
 
150
154
  const EXPRESS = {
151
- PREFIX: 'Expressjs/',
152
- MIDDLEWARE: MIDDLEWARE.PREFIX + 'Expressjs/',
153
- ERROR_HANDLER: MIDDLEWARE.PREFIX + 'Expressjs/'
155
+ PREFIX: `${EXPRESS_LITERAL}/`,
156
+ MIDDLEWARE: MIDDLEWARE.PREFIX + `${EXPRESS_LITERAL}/`,
157
+ ERROR_HANDLER: MIDDLEWARE.PREFIX + `${EXPRESS_LITERAL}/`
154
158
  }
155
159
 
156
160
  const RESTIFY = {
@@ -216,12 +220,12 @@ const OTHER_TRANSACTION = {
216
220
  PREFIX: 'OtherTransaction',
217
221
  RESPONSE_TIME: 'OtherTransaction',
218
222
  TOTAL_TIME: 'OtherTransactionTotalTime',
219
- MESSAGE: 'OtherTransaction/Message'
223
+ MESSAGE: OTHER_TRANSACTION_MESSAGE
220
224
  }
221
225
 
222
226
  const MESSAGE_TRANSACTION = {
223
- PREFIX: 'OtherTransaction/Message',
224
- RESPONSE_TIME: 'OtherTransaction/Message',
227
+ PREFIX: OTHER_TRANSACTION_MESSAGE,
228
+ RESPONSE_TIME: OTHER_TRANSACTION_MESSAGE,
225
229
  TOTAL_TIME: 'OtherTransactionTotalTime/Message'
226
230
  }
227
231
 
@@ -9,6 +9,8 @@ const logger = require('../../logger').child({ component: 'normalizer_rule' })
9
9
 
10
10
  /**
11
11
  * JavaScript just has to do things slightly differently.
12
+ *
13
+ * @param input
12
14
  */
13
15
  const replaceReplacer = function replaceReplacer(input) {
14
16
  return input.replace(/\\/g, '$')
@@ -20,7 +22,7 @@ const replaceReplacer = function replaceReplacer(input) {
20
22
  * fairly straightforward mapping of the concepts in metric normalization
21
23
  * rules into an object form.
22
24
  *
23
- * @param {Object} json A JavaScript object literal parsed out from the JSON
25
+ * @param {object} json A JavaScript object literal parsed out from the JSON
24
26
  * from the collector.
25
27
  */
26
28
  function NormalizerRule(json) {
@@ -74,8 +76,7 @@ NormalizerRule.prototype.getSegments = function getSegments(input) {
74
76
  * Does not set {NormalizerRule#matched}.
75
77
  *
76
78
  * @param {string} input - URL to match.
77
- *
78
- * @return {bool} - True if this rule matches the given input, otherwise false.
79
+ * @returns {bool} - True if this rule matches the given input, otherwise false.
79
80
  */
80
81
  NormalizerRule.prototype.matches = function matches(input) {
81
82
  const segments = this.getSegments(input)
@@ -106,8 +107,7 @@ NormalizerRule.prototype.matches = function matches(input) {
106
107
  * XXX `RegExp#lastIndex` to `0`.
107
108
  *
108
109
  * @param {string} input - URL to normalize.
109
- *
110
- * @return {string?} - The normalized url, or `null` if this is an ignore rule
110
+ * @returns {string?} - The normalized url, or `null` if this is an ignore rule
111
111
  * that matched this url.
112
112
  */
113
113
  NormalizerRule.prototype.apply = function apply(input) {
@@ -150,8 +150,7 @@ NormalizerRule.prototype.toJSON = function toJSON() {
150
150
  *
151
151
  * @param {RegExp} re - The regular expression to add flags to.
152
152
  * @param {string} flags - The flags to add to the regex.
153
- *
154
- * @return {RegExp} - A regular expression with all the given flags added.
153
+ * @returns {RegExp} - A regular expression with all the given flags added.
155
154
  */
156
155
  function _addRegExpFlags(re, flags) {
157
156
  let foundMissing = false
@@ -5,6 +5,8 @@
5
5
 
6
6
  'use strict'
7
7
 
8
+ /* eslint sonarjs/cognitive-complexity: ["error", 17] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
9
+
8
10
  const logger = require('../../logger').child({ component: 'tx_segment_normalizer' })
9
11
 
10
12
  module.exports = TxSegmentNormalizer
@@ -29,8 +31,7 @@ function TxSegmentNormalizer() {
29
31
  * 6. Join together the modified segments with slashes, and re-prepend the prefix.
30
32
  *
31
33
  * @param {string} path - The transaction metric path to normalize.
32
- *
33
- * @return {NormalizationResults} - The results of normalizing the given path.
34
+ * @returns {NormalizationResults} - The results of normalizing the given path.
34
35
  */
35
36
  TxSegmentNormalizer.prototype.normalize = function normalize(path) {
36
37
  let currentTerm
@@ -5,6 +5,8 @@
5
5
 
6
6
  'use strict'
7
7
 
8
+ /* eslint sonarjs/cognitive-complexity: ["error", 24] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
9
+
8
10
  const EventEmitter = require('events').EventEmitter
9
11
  const util = require('util')
10
12
  const logger = require('../logger').child({ component: 'metric_normalizer' })
@@ -41,6 +43,7 @@ function plain(normalized, path) {
41
43
  * @param {object} config The agent's configuration blob, which has a parameter
42
44
  * that indicates whether to enforce the normalization
43
45
  * backstop.
46
+ * @param type
44
47
  */
45
48
  function MetricNormalizer(config, type) {
46
49
  if (!config) {
@@ -68,8 +71,7 @@ util.inherits(MetricNormalizer, EventEmitter)
68
71
  // -------------------------------------------------------------------------- //
69
72
 
70
73
  /**
71
- * @typedef {Object} NormalizationResults
72
- *
74
+ * @typedef {object} NormalizationResults
73
75
  * @property {bool} matched - True if a rule was found that matched.
74
76
  * @property {bool} ignore - True if the given input should be ignored.
75
77
  * @property {string} value - The normalized input value.
@@ -83,6 +85,7 @@ util.inherits(MetricNormalizer, EventEmitter)
83
85
  *
84
86
  * @param object json The de-serialized JSON response sent on collector
85
87
  * connection.
88
+ * @param json
86
89
  */
87
90
  MetricNormalizer.prototype.load = function load(json) {
88
91
  if (json) {
@@ -196,7 +199,6 @@ MetricNormalizer.prototype.addSimple = function addSimple(pattern, name) {
196
199
  * Turn a (scrubbed) URL path into partial metric name.
197
200
  *
198
201
  * @param {string} path - The URL path to turn into a name.
199
- *
200
202
  * @returns {NormalizationResults} - The results of normalization.
201
203
  */
202
204
  MetricNormalizer.prototype.normalize = function normalize(path) {
@@ -6,10 +6,15 @@
6
6
  'use strict'
7
7
 
8
8
  const logger = require('./logger.js').child({ component: 'proc-cpuinfo' })
9
+ const PHYSICAL_ID = 'physical id'
10
+ const CPU_CORES = 'cpu cores'
11
+ const PROCESSOR = 'processor'
12
+ const CORE_ID = 'core id'
13
+
9
14
  module.exports = parseProcCPUInfo
10
15
 
11
16
  function parseProcCPUInfo(data) {
12
- const relevantAttributes = ['processor', 'physical id', 'cpu cores', 'core id']
17
+ const relevantAttributes = [PROCESSOR, PHYSICAL_ID, CPU_CORES, CORE_ID]
13
18
 
14
19
  let processorStats = {
15
20
  logical: null,
@@ -102,12 +107,12 @@ function countProcessorStats(processors) {
102
107
  for (let i = 0; i < processors.length; i++) {
103
108
  const processor = processors[i]
104
109
  if (
105
- processor['physical id'] &&
106
- processor['cpu cores'] &&
107
- phys.indexOf(processor['physical id']) === -1
110
+ processor[PHYSICAL_ID] &&
111
+ processor[CPU_CORES] &&
112
+ phys.indexOf(processor[PHYSICAL_ID]) === -1
108
113
  ) {
109
- phys.push(processor['physical id'])
110
- cores.push(processor['cpu cores'])
114
+ phys.push(processor[PHYSICAL_ID])
115
+ cores.push(processor[CPU_CORES])
111
116
  }
112
117
  }
113
118
 
@@ -38,8 +38,7 @@ class LambdaProxyWebResponse {
38
38
  /**
39
39
  * Determines if Lambda event appears to be a valid Lambda Proxy event.
40
40
  *
41
- * @param {Object} event The event to inspect.
42
- *
41
+ * @param {object} event The event to inspect.
43
42
  * @returns {boolean} Whether the given object contains fields necessary
44
43
  * to create a web transaction.
45
44
  */
@@ -50,8 +49,8 @@ function isLambdaProxyEvent(event) {
50
49
  /**
51
50
  * Determines if Lambda event appears to be a valid Lambda Proxy response.
52
51
  *
53
- * @param {Object} event The response to inspect.
54
- *
52
+ * @param {object} event The response to inspect.
53
+ * @param response
55
54
  * @returns {boolean} Whether the given object contains fields necessary
56
55
  * to create a web transaction.
57
56
  */
@@ -5,6 +5,8 @@
5
5
 
6
6
  'use strict'
7
7
 
8
+ /* eslint sonarjs/cognitive-complexity: ["error", 29] -- TODO: https://issues.newrelic.com/browse/NEWRELIC-5252 */
9
+
8
10
  const apiGateway = require('./api-gateway')
9
11
  const headerAttributes = require('../header-attributes')
10
12
  const get = require('../util/get')
@@ -348,12 +350,10 @@ function setWebRequest(shim, transaction, request) {
348
350
  }
349
351
 
350
352
  function lowercaseObjectKeys(original) {
351
- const lowercaseObject = Object.keys(original).reduce((destination, key) => {
353
+ return Object.keys(original).reduce((destination, key) => {
352
354
  destination[key.toLowerCase()] = original[key]
353
355
  return destination
354
356
  }, {})
355
-
356
- return lowercaseObject
357
357
  }
358
358
 
359
359
  function endTransaction(transaction, enderIndex) {
@@ -22,7 +22,7 @@ const SHIM_CLASSES = {
22
22
  * A shim for wrapping all-in-one modules which implement multiple services.
23
23
  *
24
24
  * @private
25
- * @extends Shim
25
+ * @augments Shim
26
26
  */
27
27
  class ConglomerateShim extends Shim {
28
28
  constructor(agent, moduleName, resolvedName) {
@@ -56,8 +56,7 @@ class ConglomerateShim extends Shim {
56
56
  *
57
57
  * @param {MODULE_TYPE} type - The type of shim to construct.
58
58
  * @param {string} submodule - The name of the submodule this will instrument.
59
- *
60
- * @return {Shim} A new shim of the given type.
59
+ * @returns {Shim} A new shim of the given type.
61
60
  */
62
61
  makeSpecializedShim(type, submodule) {
63
62
  const ShimClass = SHIM_CLASSES[type]
@@ -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' })
@@ -68,26 +70,21 @@ const QUERY_PARSERS = {
68
70
  * Constructs a shim associated with the given agent instance, specialized for
69
71
  * instrumenting datastores.
70
72
  *
71
- * @constructor
72
- * @extends Shim
73
+ * @class
74
+ * @augments Shim
73
75
  * @classdesc
74
76
  * A helper class for wrapping datastore modules.
75
- *
76
77
  * @param {Agent} agent
77
78
  * The agent this shim will use.
78
- *
79
79
  * @param {string} moduleName
80
80
  * The name of the module being instrumented.
81
- *
82
81
  * @param {string} resolvedName
83
82
  * The full path to the loaded module.
84
- *
85
83
  * @param {string} [datastoreId]
86
84
  * The name of the datastore being instrumented. If available, use one of the
87
85
  * values from {@link DatastoreShim.DATASTORE_NAMES}.
88
86
  * Calls {@link DatastoreShim#setDatastore} if datastoreId is
89
87
  * specified.
90
- *
91
88
  * @see Shim
92
89
  * @see DatastoreShim.DATASTORE_NAMES
93
90
  */
@@ -131,25 +128,18 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
131
128
 
132
129
  /**
133
130
  * @callback QuerySpecFunction
134
- *
135
131
  * @summary
136
132
  * Used for determining information about a query when it can not be simply
137
133
  * found in the arguments.
138
- *
139
134
  * @param {Shim} shim
140
135
  * The shim this function was passed to.
141
- *
142
136
  * @param {Function} func
143
137
  * The function being recorded.
144
- *
145
138
  * @param {string} name
146
139
  * The name of the function.
147
- *
148
140
  * @param {Array.<*>} args
149
141
  * The arguments being passed into the function.
150
- *
151
- * @return {QuerySpec} The spec for how this query should be recorded.
152
- *
142
+ * @returns {QuerySpec} The spec for how this query should be recorded.
153
143
  * @see DatastoreShim#recordQuery
154
144
  * @see DatastoreShim#recordBatchQuery
155
145
  * @see QuerySpec
@@ -157,68 +147,50 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
157
147
 
158
148
  /**
159
149
  * @callback QueryFunction
160
- *
161
150
  * @summary
162
151
  * Pulls the query argument out from an array of arguments.
163
- *
164
152
  * @param {Shim} shim
165
153
  * The shim this function was passed to.
166
- *
167
154
  * @param {Function} func
168
155
  * The function being recorded.
169
- *
170
156
  * @param {string} name
171
157
  * The name of the function.
172
- *
173
158
  * @param {Array.<*>} args
174
159
  * The arguments being passed into the function.
175
- *
176
- * @return {string} The query string from the arguments list.
177
- *
160
+ * @returns {string} The query string from the arguments list.
178
161
  * @see QuerySpec
179
162
  * @see QuerySpecFunction
180
163
  */
181
164
 
182
165
  /**
183
166
  * @callback QueryParserFunction
184
- *
185
167
  * @summary
186
168
  * Used to parse queries to extract the basic information about it.
187
- *
188
169
  * @param {string} query - The query to be parsed.
189
- *
190
- * @return {ParsedQueryData} An object containing the basic information about
170
+ * @returns {ParsedQueryData} An object containing the basic information about
191
171
  * the query.
192
- *
193
172
  * @see DatastoreShim#setParser
194
173
  * @see ParsedQueryData
195
174
  */
196
175
 
197
176
  /**
198
177
  * @interface OperationSpec
199
- *
200
178
  * @description
201
179
  * Describes the interface for an operation function.
202
- *
203
180
  * @property {string} [name]
204
181
  * The name for this operation. If omitted, the operation function's name will
205
182
  * used instead.
206
- *
207
183
  * @property {DatastoreParameters} [parameters]
208
184
  * Extra parameters to be set on the metric for the operation.
209
- *
210
185
  * @property {bool} [record=true]
211
186
  * Indicates if the operation should be recorded as a metric. A segment will be
212
187
  * created even if this is `false`.
213
- *
214
188
  * @property {number|CallbackBindFunction} [callback]
215
189
  * If a number, it is the offset in the arguments array for the operation's
216
190
  * callback argument. If it is a function, it should perform the segment
217
191
  * binding to the callback.
218
- *
219
192
  * @property {bool} [promise=false]
220
193
  * If `true`, the return value will be wrapped as a Promise.
221
- *
222
194
  * @see DatastoreShim#recordOperation
223
195
  * @see QuerySpec
224
196
  * @see DatastoreParameters
@@ -226,20 +198,16 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
226
198
 
227
199
  /**
228
200
  * @interface QuerySpec
229
- * @extends OperationSpec
230
- *
201
+ * @augments OperationSpec
231
202
  * @description
232
203
  * Describes the interface for a query function. Extends {@link OperationSpec}
233
204
  * with query-specific parameters.
234
- *
235
205
  * @property {bool} [stream=false]
236
206
  * If `true`, the return value will be wrapped as a stream.
237
- *
238
207
  * @property {number|string|QueryFunction} query
239
208
  * If a number, it is the offset in the arguments array for the query string
240
209
  * argument. If a string, it is the query being executed. If a function, it
241
210
  * will be passed the arguments and must return the query string.
242
- *
243
211
  * @see DatastoreShim#recordQuery
244
212
  * @see DatastoreShim#recordBatchQuery
245
213
  * @see QuerySpecFunction
@@ -250,44 +218,34 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
250
218
 
251
219
  /**
252
220
  * @interface DatastoreParameters
253
- *
254
221
  * @description
255
222
  * Extra parameters which may be added to an operation or query segment. All of
256
223
  * these properties are optional.
257
- *
258
224
  * @property {string} host
259
225
  * The host of the database server being interacted with. If provided, along
260
226
  * with `port_path_or_id`, then an instance metric will also be generated for
261
227
  * this database.
262
- *
263
228
  * @property {number|string} port_path_or_id
264
229
  * The port number or path to domain socket used to connect to the database
265
230
  * server.
266
- *
267
231
  * @property {string} database_name
268
232
  * The name of the database being queried or operated on.
269
- *
270
233
  * @see OperationSpec
271
234
  * @see QuerySpec
272
235
  */
273
236
 
274
237
  /**
275
238
  * @interface ParsedQueryData
276
- *
277
239
  * @description
278
240
  * Returned by a {@link QueryParserFunction}, this information is used to
279
241
  * generate the name for recording datastore queries.
280
- *
281
242
  * @property {string} operation
282
243
  * The datastore operation such as `SELECT` or `UPDATE`.
283
- *
284
244
  * @property {string} collection
285
245
  * The collection being queried. This would be the table name from a SQL
286
246
  * statement or the collection name in a MongoDB query.
287
- *
288
247
  * @property {string} [query]
289
248
  * The query with any sensitive information redacted and comments removed.
290
- *
291
249
  * @see DatastoreShim#setParser
292
250
  * @see QueryParserFunction
293
251
  */
@@ -304,11 +262,9 @@ DatastoreShim.prototype.getDatabaseNameFromUseQuery = getDatabaseNameFromUseQuer
304
262
  * segments or metrics.
305
263
  *
306
264
  * @memberof DatastoreShim.prototype
307
- *
308
265
  * @param {string} datastore
309
266
  * The name of this datastore. Use one of the well-known constants listed in
310
267
  * {@link DatastoreShim.DATASTORE_NAMES} if available for the datastore.
311
- *
312
268
  * @see DatastoreShim.DATASTORE_NAMES
313
269
  * @see DatastoreShim#recordBatchQuery
314
270
  * @see DatastoreShim#recordQuery
@@ -334,12 +290,10 @@ function setDatastore(datastore) {
334
290
  * Sets the query parser used by this shim instance.
335
291
  *
336
292
  * @memberof DatastoreShim.prototype
337
- *
338
293
  * @param {string|QueryParserFunction} parser
339
294
  * The string used to look up a default parser or the function used to parse
340
295
  * queries. It is recommended that you use one of the well-known constants if
341
296
  * available in the {@link DatastoreShim.QUERY_PARSERS}.
342
- *
343
297
  * @see DatastoreShim.QUERY_PARSERS
344
298
  * @see QueryParserFunction
345
299
  * @see ParsedQueryData
@@ -375,20 +329,15 @@ function setParser(parser) {
375
329
  * will result in an exception.
376
330
  *
377
331
  * @memberof DatastoreShim.prototype
378
- *
379
- * @param {Object|Function} nodule
332
+ * @param {object | Function} nodule
380
333
  * The source for the properties to wrap, or a single function to wrap.
381
- *
382
334
  * @param {string|Array.<string>} [properties]
383
335
  * One or more properties to wrap. If omitted, the `nodule` parameter is
384
336
  * assumed to be the function to wrap.
385
- *
386
337
  * @param {OperationSpec|SegmentFunction} opSpec
387
338
  * The spec for this operation function.
388
- *
389
- * @return {Object|Function} The first parameter to this function, after
339
+ * @returns {object | Function} The first parameter to this function, after
390
340
  * wrapping it or its properties.
391
- *
392
341
  * @see Shim#wrap
393
342
  * @see Shim#record
394
343
  * @see OperationSpec
@@ -452,20 +401,15 @@ function recordOperation(nodule, properties, opSpec) {
452
401
  * will result in an exception.
453
402
  *
454
403
  * @memberof DatastoreShim.prototype
455
- *
456
- * @param {Object|Function} nodule
404
+ * @param {object | Function} nodule
457
405
  * The source for the properties to wrap, or a single function to wrap.
458
- *
459
406
  * @param {string|Array.<string>} [properties]
460
407
  * One or more properties to wrap. If omitted, the `nodule` parameter is
461
408
  * assumed to be the function to wrap.
462
- *
463
409
  * @param {QuerySpec|QuerySpecFunction} querySpec
464
410
  * The spec for this query function.
465
- *
466
- * @return {Object|Function} The first parameter to this function, after
411
+ * @returns {object | Function} The first parameter to this function, after
467
412
  * wrapping it or its properties.
468
- *
469
413
  * @see Shim#wrap
470
414
  * @see Shim#record
471
415
  * @see DatastoreShim#recordBatchQuery
@@ -490,20 +434,15 @@ function recordQuery(nodule, properties, querySpec) {
490
434
  * will result in an exception.
491
435
  *
492
436
  * @memberof DatastoreShim.prototype
493
- *
494
- * @param {Object|Function} nodule
437
+ * @param {object | Function} nodule
495
438
  * The source for the properties to wrap, or a single function to wrap.
496
- *
497
439
  * @param {string|Array.<string>} [properties]
498
440
  * One or more properties to wrap. If omitted, the `nodule` parameter is
499
441
  * assumed to be the function to wrap.
500
- *
501
442
  * @param {QuerySpec|QuerySpecFunction} querySpec
502
443
  * The spec for this query function.
503
- *
504
- * @return {Object|Function} The first parameter to this function, after
444
+ * @returns {object | Function} The first parameter to this function, after
505
445
  * wrapping it or its properties.
506
- *
507
446
  * @see Shim#wrap
508
447
  * @see Shim#record
509
448
  * @see DatastoreShim#recordQuery
@@ -522,13 +461,9 @@ function recordBatchQuery(nodule, properties, querySpec) {
522
461
  * will result in an exception.
523
462
  *
524
463
  * @memberof DatastoreShim.prototype
525
- *
526
464
  * @param {string} query - The query to parse.
527
- *
528
- * @param {Object} nodule - Context for the queryParse to run under.
529
- *
530
- * @return {ParsedStatement} The parsed query object.
531
- *
465
+ * @param {object} nodule - Context for the queryParse to run under.
466
+ * @returns {ParsedStatement} The parsed query object.
532
467
  * @see DatastoreShim#setParser
533
468
  */
534
469
  function parseQuery(query, nodule) {
@@ -563,13 +498,10 @@ function parseQuery(query, nodule) {
563
498
  * - `bindRowCallbackSegment(args, cbIdx [, parentSegment])`
564
499
  *
565
500
  * @memberof DatastoreShim.prototype
566
- *
567
501
  * @param {Array} args
568
502
  * The arguments array to replace the callback in.
569
- *
570
- * @param {Number} cbIdx
503
+ * @param {number} cbIdx
571
504
  * The index of the callback in the arguments array.
572
- *
573
505
  * @param {TraceSegment} [parentSegment]
574
506
  * Optional. The segment to be the parent row callback's segment. Defaults to
575
507
  * the segment active when the row callback is first called.
@@ -627,7 +559,6 @@ function bindRowCallbackSegment(args, cbIdx, parentSegment) {
627
559
  * If the current segment was not created by this shim then no action is taken.
628
560
  *
629
561
  * @memberof DatastoreShim.prototype
630
- *
631
562
  * @param {string} host - The name of the database host.
632
563
  * @param {number|string} port - The port, path, or ID of the database server.
633
564
  * @param {string} database - The name of the database in use.
@@ -662,8 +593,7 @@ function captureInstanceAttributes(host, port, database) {
662
593
  * Parses the database name from a `USE` SQL query.
663
594
  *
664
595
  * @param {string} query - The SQL query to parse the database name from.
665
- *
666
- * @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
667
597
  * `null`.
668
598
  */
669
599
  function getDatabaseNameFromUseQuery(query) {
@@ -683,23 +613,17 @@ function getDatabaseNameFromUseQuery(query) {
683
613
  *
684
614
  * @private
685
615
  * @this DatastoreShim
686
- *
687
616
  * @param {string} suffix
688
617
  * Suffix to be added to the segment name.
689
- *
690
- * @param {Object|Function} nodule
618
+ * @param {object | Function} nodule
691
619
  * The source for the properties to wrap, or a single function to wrap.
692
- *
693
620
  * @param {string|Array.<string>} [properties]
694
621
  * One or more properties to wrap. If omitted, the `nodule` parameter is
695
622
  * assumed to be the function to wrap.
696
- *
697
623
  * @param {QuerySpec|QueryFunction} querySpec
698
624
  * The spec for this query function.
699
- *
700
- * @return {Object|Function} The first parameter to this function, after
625
+ * @returns {object | Function} The first parameter to this function, after
701
626
  * wrapping it or its properties.
702
- *
703
627
  * @see Shim#wrap
704
628
  * @see Shim#record
705
629
  * @see DatastoreShim#recordQuery
@@ -786,10 +710,8 @@ function _recordQuery(suffix, nodule, properties, querySpec) {
786
710
  * @private
787
711
  * @this DatastoreShim
788
712
  * @implements {MetricFunction}
789
- *
790
713
  * @param {TraceSegment} segment - The segment being recorded.
791
714
  * @param {string} [scope] - The scope of the segment.
792
- *
793
715
  * @see DatastoreShim#recordOperation
794
716
  * @see MetricFunction
795
717
  */
@@ -839,14 +761,12 @@ function _recordOperationMetrics(segment, scope) {
839
761
  *
840
762
  * @private
841
763
  * @this DatastoreShim
842
- *
843
764
  * @param {Function} fn - The query function to be executed.
844
765
  * @param {string} fnName - The name of the query function.
845
766
  * @param {QuerySpec} spec - The query spec.
846
767
  * @param {*} ctx - The context of the query function's execution.
847
768
  * @param {Array} args - The arguments for the query function.
848
- *
849
- * @return {?string} The query from the arguments if found, otherwise `null`.
769
+ * @returns {?string} The query from the arguments if found, otherwise `null`.
850
770
  */
851
771
  function _extractQueryStr(fn, fnName, spec, ctx, args) {
852
772
  let queryStr = spec.query
@@ -874,10 +794,8 @@ function _extractQueryStr(fn, fnName, spec, ctx, args) {
874
794
  *
875
795
  * @private
876
796
  * @this DatastoreShim
877
- *
878
797
  * @param {object} [parameters={}] - The segment parameters to clean up.
879
- *
880
- * @return {object} - The normalized segment parameters.
798
+ * @returns {object} - The normalized segment parameters.
881
799
  */
882
800
  function _normalizeParameters(parameters) {
883
801
  parameters = parameters || Object.create(null)