newrelic 13.4.0 → 13.5.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 (105) hide show
  1. package/NEWS.md +32 -0
  2. package/api.js +1 -1
  3. package/lib/agent.js +2 -2
  4. package/lib/aggregators/event-aggregator.js +0 -2
  5. package/lib/attributes.js +2 -2
  6. package/lib/collector/api.js +1 -1
  7. package/lib/collector/http-agents.js +2 -2
  8. package/lib/collector/serverless.js +1 -1
  9. package/lib/config/build-instrumentation-config.js +13 -3
  10. package/lib/config/default.js +21 -10
  11. package/lib/config/formatters.js +3 -3
  12. package/lib/config/index.js +33 -20
  13. package/lib/harvester.js +1 -1
  14. package/lib/header-processing.js +3 -3
  15. package/lib/health-reporter.js +2 -2
  16. package/lib/instrumentation/@prisma/client.js +1 -1
  17. package/lib/instrumentation/aws-sdk/util.js +3 -3
  18. package/lib/instrumentation/aws-sdk/v2/instrumentation-helper.js +1 -1
  19. package/lib/instrumentation/aws-sdk/v3/bedrock.js +5 -5
  20. package/lib/instrumentation/aws-sdk/v3/common.js +11 -11
  21. package/lib/instrumentation/aws-sdk/v3/dynamodb.js +10 -10
  22. package/lib/instrumentation/aws-sdk/v3/lambda.js +3 -3
  23. package/lib/instrumentation/aws-sdk/v3/sns.js +7 -7
  24. package/lib/instrumentation/aws-sdk/v3/sqs.js +6 -6
  25. package/lib/instrumentation/fastify/spec-builders.js +3 -23
  26. package/lib/instrumentation/fastify.js +22 -93
  27. package/lib/instrumentation/kafkajs/consumer.js +1 -1
  28. package/lib/instrumentation/koa/instrumentation.js +1 -1
  29. package/lib/instrumentation/langchain/runnable.js +1 -1
  30. package/lib/instrumentation/memcached.js +1 -1
  31. package/lib/instrumentation/nextjs/next-server.js +1 -3
  32. package/lib/instrumentation/nextjs/utils.js +2 -2
  33. package/lib/instrumentation/restify.js +2 -2
  34. package/lib/instrumentation/when/contextualizer.js +1 -1
  35. package/lib/instrumentation-descriptor.js +2 -11
  36. package/lib/instrumentations.js +1 -18
  37. package/lib/llm-events/aws-bedrock/chat-completion-summary.js +2 -1
  38. package/lib/metrics/recorders/database-operation.js +2 -3
  39. package/lib/metrics/recorders/middleware.js +1 -2
  40. package/lib/otel/context-manager.js +3 -3
  41. package/lib/otel/traces/segments/database.js +1 -1
  42. package/lib/otel/traces/utils.js +9 -9
  43. package/lib/{adaptive-sampler.js → samplers/adaptive-sampler.js} +8 -0
  44. package/lib/serverless/aws-lambda.js +2 -2
  45. package/lib/shim/datastore-shim.js +1 -1
  46. package/lib/shim/message-shim/consume.js +3 -3
  47. package/lib/shim/promise-shim.js +1 -2
  48. package/lib/shim/shim.js +12 -26
  49. package/lib/shim/specs/class.js +3 -3
  50. package/lib/shim/specs/middleware-mounter.js +2 -2
  51. package/lib/shim/specs/middleware.js +3 -3
  52. package/lib/shim/specs/query.js +1 -1
  53. package/lib/shim/specs/recorder.js +1 -1
  54. package/lib/shim/specs/wrap.js +2 -2
  55. package/lib/shim/webframework-shim/common.js +2 -2
  56. package/lib/shim/webframework-shim/index.js +10 -1
  57. package/lib/shim/webframework-shim/middleware.js +12 -16
  58. package/lib/shimmer.js +56 -103
  59. package/lib/spans/span-context.js +1 -1
  60. package/lib/spans/span-event.js +1 -1
  61. package/lib/spans/streaming-span-event-aggregator.js +4 -1
  62. package/lib/spans/streaming-span-event.js +1 -1
  63. package/lib/subscriber-configs.js +4 -1
  64. package/lib/subscribers/amqplib/config.js +2 -0
  65. package/lib/subscribers/amqplib/connect.js +2 -2
  66. package/lib/subscribers/amqplib/send-or-enqueue.js +0 -2
  67. package/lib/subscribers/base.js +50 -32
  68. package/lib/subscribers/create-config.js +2 -2
  69. package/lib/subscribers/db-operation.js +12 -0
  70. package/lib/subscribers/dc-base.js +89 -0
  71. package/lib/subscribers/fastify/add-hook.js +46 -0
  72. package/lib/subscribers/fastify/common.js +121 -0
  73. package/lib/subscribers/fastify/config.js +39 -0
  74. package/lib/subscribers/fastify/decorate.js +35 -0
  75. package/lib/subscribers/fastify/index.js +31 -0
  76. package/lib/subscribers/mcp-sdk/client-request.js +1 -1
  77. package/lib/subscribers/mcp-sdk/config.js +2 -0
  78. package/lib/subscribers/openai/utils.js +1 -0
  79. package/lib/subscribers/pg/config.js +91 -0
  80. package/lib/subscribers/pg/connect.js +28 -0
  81. package/lib/subscribers/pg/native-connect.js +25 -0
  82. package/lib/subscribers/pg/native-query.js +22 -0
  83. package/lib/subscribers/pg/query.js +66 -0
  84. package/lib/subscribers/pino/index.js +2 -2
  85. package/lib/subscribers/propagation.js +1 -21
  86. package/lib/subscribers/undici/config.js +11 -0
  87. package/lib/subscribers/undici/index.js +195 -0
  88. package/lib/synthetics.js +4 -4
  89. package/lib/tracking-packages.js +25 -0
  90. package/lib/transaction/dt-payload.js +1 -1
  91. package/lib/transaction/index.js +25 -21
  92. package/lib/transaction/name-state.js +2 -2
  93. package/lib/transaction/trace/segment.js +1 -1
  94. package/lib/transaction/tracer/index.js +1 -1
  95. package/lib/util/cat.js +2 -2
  96. package/lib/util/llm-utils.js +3 -3
  97. package/lib/util/logger.js +3 -3
  98. package/lib/util/stream-sink.js +1 -1
  99. package/lib/utilization/docker-info.js +1 -1
  100. package/lib/utilization/ecs-info.js +1 -1
  101. package/lib/w3c/traceparent.js +2 -2
  102. package/lib/w3c/tracestate.js +1 -1
  103. package/package.json +1 -1
  104. package/lib/instrumentation/pg.js +0 -137
  105. package/lib/instrumentation/undici.js +0 -229
package/NEWS.md CHANGED
@@ -1,3 +1,35 @@
1
+ ### v13.5.0 (2025-10-14)
2
+
3
+ #### Code refactoring
4
+
5
+ * Updated `fastify` instrumentation to subscribe to events emitted ([#3407](https://github.com/newrelic/node-newrelic/pull/3407)) ([51e361e](https://github.com/newrelic/node-newrelic/commit/51e361ed736fa1235eeb16f1c5ec833a1b56a0bf))
6
+ * Updated `pg` and `pg-native` instrumentation to subscribe to events emitted ([#3397](https://github.com/newrelic/node-newrelic/pull/3397)) ([04af258](https://github.com/newrelic/node-newrelic/commit/04af2580a554ecabedab447d5edc5cec836d7f40))
7
+
8
+ * Updated `config.instrumentation.timers.enabled` to false to disable `timers.setTimeout` and `timers.setInterval` by default. ([#3414](https://github.com/newrelic/node-newrelic/pull/3414)) ([b925d3d](https://github.com/newrelic/node-newrelic/commit/b925d3d178886e6d4bbd0f2eaa6f51b6fddd7878))
9
+ * To re-enable, set `config.instrumentation.timers.enabled` to `true` in config or set `NEW_RELIC_INSTRUMENTATION_TIMERS_ENABLED=true`
10
+
11
+ #### Documentation
12
+
13
+ * Updated compatibility report ([#3413](https://github.com/newrelic/node-newrelic/pull/3413)) ([fef98dd](https://github.com/newrelic/node-newrelic/commit/fef98ddffddf60b32f162ea87dee2a3a0bdf8048))
14
+
15
+ #### Miscellaneous chores
16
+
17
+ * Added a new diagnostics base class and migrated undici to use new class ([#3408](https://github.com/newrelic/node-newrelic/pull/3408)) ([8047bf1](https://github.com/newrelic/node-newrelic/commit/8047bf165ae5105bb612c1a834d574078d52724d))
18
+ * Created directory for samplers ([#3419](https://github.com/newrelic/node-newrelic/pull/3419)) ([dd2d3df](https://github.com/newrelic/node-newrelic/commit/dd2d3dfe1bb2582de51e07a1cce6077df84f7108))
19
+
20
+ #### Styles
21
+
22
+ * Require `check-types` and `require-returns-type` jsdoc ([#3400](https://github.com/newrelic/node-newrelic/pull/3400)) ([e4cd687](https://github.com/newrelic/node-newrelic/commit/e4cd687c59aeaba6b627403bcb29b4b6576fe4d9))
23
+ * Require jsdoc `check*`, `implements-on-classes`, and some `no-undefined-types` ([#3404](https://github.com/newrelic/node-newrelic/pull/3404)) ([4fa645b](https://github.com/newrelic/node-newrelic/commit/4fa645b91900ff0acbd24b8f50c6fffcd07f3b82))
24
+ * Require jsdoc `require-returns-check` and `require-property-*` ([#3403](https://github.com/newrelic/node-newrelic/pull/3403)) ([1008073](https://github.com/newrelic/node-newrelic/commit/100807342b9c9283f43042024f15bb575de219ee))
25
+
26
+ #### Tests
27
+
28
+ * Added helper to get version of package when package.json not exported, and updated tests that need it ([#3411](https://github.com/newrelic/node-newrelic/pull/3411)) ([5ae02c7](https://github.com/newrelic/node-newrelic/commit/5ae02c7411cd7ae0a45203b025559c5442a7171e))
29
+ * Fixed fastify segment tree assertion when security agent is enabled ([#3422](https://github.com/newrelic/node-newrelic/pull/3422)) ([b2cf6ed](https://github.com/newrelic/node-newrelic/commit/b2cf6ed5d8debae23d0bb31e9a72b325464fadc2))
30
+ * Refactored mcp tests to listen on new port for every streaming test, removed unncessary shutdown of process ([#3420](https://github.com/newrelic/node-newrelic/pull/3420)) ([17db813](https://github.com/newrelic/node-newrelic/commit/17db8133e8e13c970362330885dccf4870942aea))
31
+ * Updated an openai assertion with setTimeout disabled ([#3421](https://github.com/newrelic/node-newrelic/pull/3421)) ([ceec8f9](https://github.com/newrelic/node-newrelic/commit/ceec8f9ef2ac95285dcc1619ef2ee8e187252beb))
32
+
1
33
  ### v13.4.0 (2025-09-29)
2
34
 
3
35
  #### Code refactoring
package/api.js CHANGED
@@ -1937,7 +1937,7 @@ API.prototype.ignoreApdex = function ignoreApdex() {
1937
1937
  * { role: 'user', content: 'Tell me about Node.js.'}
1938
1938
  * ]})
1939
1939
  * })
1940
- * @param {Object} context LLM custom attributes context
1940
+ * @param {object} context LLM custom attributes context
1941
1941
  * @param {Function} callback The function to execute in context.
1942
1942
  */
1943
1943
  API.prototype.withLlmCustomAttributes = function withLlmCustomAttributes(context, callback) {
package/lib/agent.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict'
7
7
 
8
- const AdaptiveSampler = require('./adaptive-sampler')
8
+ const AdaptiveSampler = require('./samplers/adaptive-sampler')
9
9
  const CollectorAPI = require('./collector/api')
10
10
  const ServerlessCollector = require('./collector/serverless')
11
11
  const DESTINATIONS = require('./config/attribute-filter').DESTINATIONS
@@ -169,7 +169,7 @@ const DEFAULT_HARVEST_INTERVAL_MS = 60000
169
169
  * available. Don't try to recover here, because without configuration the
170
170
  * agent can't be brought up to a useful state.
171
171
  *
172
- * @param {object} config Agent configuration object
172
+ * @param {Config} config Agent configuration object
173
173
  */
174
174
  function Agent(config) {
175
175
  EventEmitter.call(this)
@@ -85,8 +85,6 @@ class EventAggregator extends Aggregator {
85
85
 
86
86
  /**
87
87
  * Resets the contents of the aggregator and all counters.
88
- *
89
- * @returns {PriorityQueue} The old collection of aggregated events.
90
88
  */
91
89
  clearEvents() {
92
90
  // ???: might be more efficient to clear here and come up with an efficient way to
package/lib/attributes.js CHANGED
@@ -176,8 +176,8 @@ class Attributes {
176
176
  * Creates a filter function for the given scope.
177
177
  *
178
178
  * @param {string} scope - The scope of the filter to make.
179
- * @returns {Function} A function that performs attribute filtering for the given
180
- * scope.
179
+ * @returns {Function|undefined} A function that performs attribute filtering for the given
180
+ * scope, or undefined if the scope is not recognized.
181
181
  */
182
182
  function makeFilter(scope) {
183
183
  const { attributeFilter } = Config.getInstance()
@@ -153,7 +153,7 @@ CollectorAPI.prototype._updateEndpoints = function _updateEndpoints(endpoint) {
153
153
  /**
154
154
  * Connect to the data collector.
155
155
  *
156
- * @param {function} callback A typical error first callback to be invoked
156
+ * @param {Function} callback A typical error first callback to be invoked
157
157
  * upon successful or unsuccessful connection. The second parameter will be
158
158
  * an instance of {@link CollectorResponse}.
159
159
  *
@@ -19,7 +19,7 @@ let agentProxyWithKeepAlive = null
19
19
  /**
20
20
  * Returns an HTTP agent with keep-alive enabled
21
21
  *
22
- * @param {Object} config configuration for HTTP agent
22
+ * @param {object} config configuration for HTTP agent
23
23
  */
24
24
  exports.keepAliveAgent = function keepAliveAgent(config) {
25
25
  config = config ? config : {}
@@ -45,7 +45,7 @@ exports.keepAliveAgent = function keepAliveAgent(config) {
45
45
  * to the proxy server as to how its connection is made
46
46
  * with New Relic's servers.
47
47
  *
48
- * @param {Object} config configuration for proxy agent
48
+ * @param {object} config configuration for proxy agent
49
49
  */
50
50
  exports.proxyAgent = function proxyAgent(config) {
51
51
  if (agentProxyWithKeepAlive !== null) {
@@ -110,7 +110,7 @@ class ServerlessCollector {
110
110
  * Constructs, serializes, and prints the final consolidated payload to stdout.
111
111
  *
112
112
  * @param {Function} cb The callback to invoke when finished.
113
- * @returns {boolean} indicating if callback was defined and successfully executed
113
+ * @returns {boolean|undefined} indicating if callback was defined and successfully executed
114
114
  */
115
115
  flushPayload(cb) {
116
116
  if (!this.enabled) {
@@ -12,18 +12,28 @@ const corePkgs = Object.keys(coreLibraries)
12
12
  const subscriptions = require('../subscriber-configs')
13
13
  const subscribers = Object.keys(subscriptions)
14
14
  pkgNames.push(...subscribers)
15
- // Manually adding undici as it is registered separately in shimmer
16
- corePkgs.push('undici')
17
15
  // Manually adding domain as it is registered separately in shimmer
18
16
  corePkgs.push('domain')
19
17
  pkgNames.push(...corePkgs)
20
18
 
19
+ // Packages are normally enabled without any extra
20
+ // configuration. This list is a set of packages that
21
+ // we want to be disabled without any extra configuration.
22
+ // Typically, this is because the instrumentation no longer
23
+ // provides useful data. Users can still enable them if they
24
+ // are interested in the instrumentation they provide.
25
+ const disabledPkgs = ['timers']
26
+
21
27
  /**
22
28
  * Builds the stanza for config.instrumentation.*
23
29
  * It defaults every library to true and assigns a boolean
24
30
  * formatter for the environment variable conversion of the values
25
31
  */
26
32
  module.exports = pkgNames.reduce((config, pkg) => {
27
- config[pkg] = { enabled: { formatter: boolean, default: true } }
33
+ let defaultValue = true
34
+ if (disabledPkgs.includes(pkg)) {
35
+ defaultValue = false
36
+ }
37
+ config[pkg] = { enabled: { formatter: boolean, default: defaultValue } }
28
38
  return config
29
39
  }, {})
@@ -1156,16 +1156,27 @@ defaultConfig.definition = () => {
1156
1156
  },
1157
1157
 
1158
1158
  sampler: {
1159
- /**
1160
- * When set to `always_on`, the sampled flag in the `traceparent` header
1161
- * being set to "true" will result in the local transaction being sampled
1162
- * with a priority value of "2". When set to `always_off`, the local
1163
- * transaction will never be sampled. At the default setting, the sampling
1164
- * decision will be determined according to the normal algorithm.
1165
- *
1166
- * This setting takes precedence over the `remote_parent_not_sampled`
1167
- * setting.
1168
- */
1159
+ /**
1160
+ * The sampling target for adaptive sampling is controlled via this attribute when configuring the default/adaptive sampler.
1161
+ * The default sampling target is 10 transactions/min when it is not specified but **MUST** be within the range of [1, 120] (inclusive).
1162
+ * Upon agent connect, the connect response **MUST** provide the value of `sampling_target` based on this configuration setting's value.
1163
+ * The `sampling_target` value from the connect response **SHOULD** be used as the sampling target value for adaptive sampling in the agent.
1164
+ */
1165
+ adaptive_sampling_target: {
1166
+ formatter: int,
1167
+ default: 10
1168
+ },
1169
+
1170
+ /**
1171
+ * When set to `always_on`, the sampled flag in the `traceparent` header
1172
+ * being set to "true" will result in the local transaction being sampled
1173
+ * with a priority value of "2". When set to `always_off`, the local
1174
+ * transaction will never be sampled. At the default setting, the sampling
1175
+ * decision will be determined according to the normal algorithm.
1176
+ *
1177
+ * This setting takes precedence over the `remote_parent_not_sampled`
1178
+ * setting.
1179
+ */
1169
1180
  remote_parent_sampled: {
1170
1181
  formatter: allowList.bind(null, ['always_on', 'always_off', 'default']),
1171
1182
  default: 'default'
@@ -67,7 +67,7 @@ formatters.boolean = function boolean(setting) {
67
67
  *
68
68
  * @param {string} val config setting
69
69
  * @param {logger} logger agent logger instance
70
- * @returns {object}
70
+ * @returns {object|undefined} the parsed value, or undefined if an error occurred
71
71
  */
72
72
  formatters.object = function object(val, logger) {
73
73
  try {
@@ -83,7 +83,7 @@ formatters.object = function object(val, logger) {
83
83
  *
84
84
  * @param {string} val config setting
85
85
  * @param {logger} logger agent logger instance
86
- * @returns {Array}
86
+ * @returns {Array|undefined} The parsed array of objects, or undefined if an error occurred
87
87
  */
88
88
  formatters.objectList = function objectList(val, logger) {
89
89
  try {
@@ -111,7 +111,7 @@ formatters.allowList = function allowList(list, val) {
111
111
  *
112
112
  * @param {string} val valid regex
113
113
  * @param {logger} logger agent logger instance
114
- * @returns {RegExp} regex
114
+ * @returns {RegExp|undefined} regex, or undefined if an error occurred
115
115
  */
116
116
  formatters.regex = function regex(val, logger) {
117
117
  try {
@@ -123,7 +123,8 @@ function Config(config) {
123
123
  this.primary_application_id = null
124
124
  this.trusted_account_ids = null
125
125
  this.trusted_account_key = null
126
- this.sampling_target = 10
126
+
127
+ this.sampling_target = this.distributed_tracing.sampler.adaptive_sampling_target
127
128
  this.sampling_target_period_in_seconds = 60
128
129
  this.max_payload_size_in_bytes = DEFAULT_MAX_PAYLOAD_SIZE_IN_BYTES
129
130
 
@@ -184,9 +185,9 @@ function Config(config) {
184
185
  if (this.security_policies_token) {
185
186
  throw new Error(
186
187
  'Security Policies and High Security Mode cannot both be present ' +
187
- 'in the agent configuration. If Security Policies have been set ' +
188
- 'for your account, please ensure the security_policies_token is ' +
189
- 'set but high_security is disabled (default).'
188
+ 'in the agent configuration. If Security Policies have been set ' +
189
+ 'for your account, please ensure the security_policies_token is ' +
190
+ 'set but high_security is disabled (default).'
190
191
  )
191
192
  }
192
193
  this._applyHighSecurity()
@@ -199,8 +200,20 @@ function Config(config) {
199
200
  this.parsedLabels = parseLabels(this.labels, logger)
200
201
  this.loggingLabels = this._setApplicationLoggingLabels()
201
202
  }
203
+
202
204
  util.inherits(Config, EventEmitter)
203
205
 
206
+ // Expose sampling_target as an accessor that proxies to distributed_tracing.sampler.adaptive_sampling_target.
207
+ Object.defineProperty(Config.prototype, 'sampling_target', {
208
+ get: function () {
209
+ return this.distributed_tracing.sampler.adaptive_sampling_target
210
+ },
211
+ set: function (value) {
212
+ this.distributed_tracing.sampler.adaptive_sampling_target = value
213
+ this.emit('sampling_target', value)
214
+ }
215
+ })
216
+
204
217
  /**
205
218
  * Compares the labels list to the application logging excluded label list and removes any labels that need to be excluded.
206
219
  * Then prefixing each label with "tags."
@@ -694,7 +707,7 @@ function _validateThenUpdateStatusCodes(remote, local, remoteKey, localKey) {
694
707
  if (!(typeof thingToTest === 'string' || typeof thingToTest === 'number')) {
695
708
  logger.warn(
696
709
  'Saw SSC (ignore|expect)_status_code that is not a number or string,' +
697
- 'will not merge: %s',
710
+ 'will not merge: %s',
698
711
  thingToTest
699
712
  )
700
713
  valid = false
@@ -858,7 +871,7 @@ Config.prototype.logDisabled = function logDisabled(json, key) {
858
871
  if (value != null) {
859
872
  logger.debug(
860
873
  'Server-side configuration of %s is currently disabled by local configuration. ' +
861
- '(Server sent value of %s.)',
874
+ '(Server sent value of %s.)',
862
875
  key,
863
876
  value
864
877
  )
@@ -877,7 +890,7 @@ Config.prototype.logUnsupported = function logUnsupported(json, key) {
877
890
  if (value !== null && value !== undefined) {
878
891
  logger.debug(
879
892
  'Server-side configuration of %s is currently not supported by the ' +
880
- 'Node.js agent. (Server sent value of %s.)',
893
+ 'Node.js agent. (Server sent value of %s.)',
881
894
  key,
882
895
  value
883
896
  )
@@ -1218,8 +1231,8 @@ Config.prototype._serverlessLogging = function _serverlessLogging(inputConfig) {
1218
1231
 
1219
1232
  logger.info(
1220
1233
  'Logging is disabled by default when serverless_mode is enabled. ' +
1221
- 'If desired, enable logging via config file or environment variable and ' +
1222
- 'set filepath to a valid path for current environment, stdout or stderr.'
1234
+ 'If desired, enable logging via config file or environment variable and ' +
1235
+ 'set filepath to a valid path for current environment, stdout or stderr.'
1223
1236
  )
1224
1237
  }
1225
1238
  }
@@ -1241,17 +1254,17 @@ Config.prototype._serverlessNativeMetrics = function _serverlessNativeMetrics(in
1241
1254
  ) {
1242
1255
  logger.info(
1243
1256
  'Enabling the native-metrics module when in serverless mode may greatly ' +
1244
- 'increase cold-start times. Given the limited benefit of the VM metrics' +
1245
- 'and general lack of control in a serverless environment, we do not ' +
1246
- 'recommend this trade-off.'
1257
+ 'increase cold-start times. Given the limited benefit of the VM metrics' +
1258
+ 'and general lack of control in a serverless environment, we do not ' +
1259
+ 'recommend this trade-off.'
1247
1260
  )
1248
1261
  } else {
1249
1262
  this.plugins.native_metrics.enabled = false
1250
1263
 
1251
1264
  logger.info(
1252
1265
  'The native-metrics module is disabled by default when serverless_mode ' +
1253
- 'is enabled. If desired, enable the native-metrics module via config file ' +
1254
- 'or environment variable.'
1266
+ 'is enabled. If desired, enable the native-metrics module via config file ' +
1267
+ 'or environment variable.'
1255
1268
  )
1256
1269
  }
1257
1270
  }
@@ -1305,8 +1318,8 @@ Config.prototype._serverlessDT = function _serverlessDT() {
1305
1318
  if (this.distributed_tracing.enabled) {
1306
1319
  logger.warn(
1307
1320
  'Using distributed tracing in serverless mode requires account_id be ' +
1308
- 'defined, either in your newrelic.js file or via environment variables. ' +
1309
- 'Disabling distributed tracing.'
1321
+ 'defined, either in your newrelic.js file or via environment variables. ' +
1322
+ 'Disabling distributed tracing.'
1310
1323
  )
1311
1324
  this.distributed_tracing.enabled = false
1312
1325
  }
@@ -1332,8 +1345,8 @@ Config.prototype._preventServerlessDT = function _preventServerlessDT() {
1332
1345
  if (this[key]) {
1333
1346
  logger.warn(
1334
1347
  key +
1335
- ' was configured locally without enabling serverless_mode. ' +
1336
- 'This local value will be ignored and set by the New Relic servers.'
1348
+ ' was configured locally without enabling serverless_mode. ' +
1349
+ 'This local value will be ignored and set by the New Relic servers.'
1337
1350
  )
1338
1351
  this[key] = null
1339
1352
  }
@@ -1530,7 +1543,7 @@ function _laspReponse(keys) {
1530
1543
  * Applies the server side LASP policies to a local configuration object
1531
1544
  *
1532
1545
  * @param {Agent} agent Agent instance
1533
- * @param {bject} policies server side LASP policy
1546
+ * @param {object} policies server side LASP policy
1534
1547
  * @returns {object} { missingRequired, finalPolicies } list of missing required fields and finalized LASP policy
1535
1548
  */
1536
1549
  Config.prototype._buildLaspPolicy = function _buildLaspPolicy(agent, policies) {
@@ -1670,7 +1683,7 @@ function redactValue(value) {
1670
1683
  * Get a JSONifiable object containing all settings we want to report to the
1671
1684
  * collector and store in the environment_values table.
1672
1685
  *
1673
- * @returns {object} containing simple key-value pairs of settings
1686
+ * @returns {object|undefined} containing simple key-value pairs of settings, or undefined if an error occurred
1674
1687
  */
1675
1688
  Config.prototype.publicSettings = function publicSettings() {
1676
1689
  let settings = Object.create(null)
package/lib/harvester.js CHANGED
@@ -74,7 +74,7 @@ module.exports = class Harvester {
74
74
  /**
75
75
  * Registers an aggregator with the Harvester instance.
76
76
  *
77
- * @param {Object} aggregator Aggregator instance
77
+ * @param {object} aggregator Aggregator instance
78
78
  */
79
79
  add(aggregator) {
80
80
  this.aggregators.push(aggregator)
@@ -15,8 +15,8 @@ const CONTENT_LENGTH_REGEX = /^Content-Length$/i
15
15
  * Queue time is provided by certain providers by stamping the request
16
16
  * header with the time the request arrived at the router.
17
17
  *
18
- * @param {Object} logger Logger instance
19
- * @param {Object} requestHeaders Incoming request headers
18
+ * @param {object} logger Logger instance
19
+ * @param {object} requestHeaders Incoming request headers
20
20
  */
21
21
  function getQueueTime(logger, requestHeaders) {
22
22
  const headerValue = requestHeaders[REQUEST_START_HEADER] || requestHeaders[QUEUE_HEADER]
@@ -62,7 +62,7 @@ function convertUnit(time) {
62
62
  *
63
63
  * If no header is found, returns -1
64
64
  *
65
- * @param {Object} headers Incoming request headers
65
+ * @param {object} headers Incoming request headers
66
66
  */
67
67
  function getContentLengthFromHeaders(headers) {
68
68
  const contentLength = -1
@@ -112,7 +112,7 @@ class HealthReporter {
112
112
  * object that has an `agent_control` property which is an instance of
113
113
  * {@link AgentControlConfig}.
114
114
  * @param {object} [params.logger] A standard logger instance.
115
- * @param {function} [params.setInterval] A function to use as `setInterval`.
115
+ * @param {Function} [params.setInterval] A function to use as `setInterval`.
116
116
  * Must return an interval object that supports the `unref()` method.
117
117
  */
118
118
  constructor({
@@ -217,7 +217,7 @@ class HealthReporter {
217
217
  * initiate an immediate write of the status file, and then invoke the
218
218
  * provided callback.
219
219
  *
220
- * @param {function} done Callback to be invoked after the status file has
220
+ * @param {Function} done Callback to be invoked after the status file has
221
221
  * been updated.
222
222
  */
223
223
  stop(done) {
@@ -75,7 +75,7 @@ function extractQueryArgs(args, pkgVersion) {
75
75
  *
76
76
  * @param {Array} args arguments to a prisma operation
77
77
  * @param {string} pkgVersion prisma version
78
- * @returns {string} query raw query string or model call <collection>.<operation>
78
+ * @returns {string|undefined} query raw query string or model call <collection>.<operation>
79
79
  */
80
80
  function retrieveQuery(args, pkgVersion) {
81
81
  if (Array.isArray(args)) {
@@ -20,9 +20,9 @@ function grabLastUrlSegment(url = '/') {
20
20
  /**
21
21
  * Retrieves the db segment params from endpoint and command parameters
22
22
  *
23
- * @param {Object} endpoint instance of ddb endpoint
24
- * @param {Object} params parameters passed to a ddb command
25
- * @returns {Object}
23
+ * @param {object} endpoint instance of ddb endpoint
24
+ * @param {object} params parameters passed to a ddb command
25
+ * @returns {object}
26
26
  */
27
27
  function setDynamoParameters(endpoint, params) {
28
28
  return new DatastoreParameters({
@@ -8,7 +8,7 @@
8
8
  /**
9
9
  * Series of tests to determine if the library
10
10
  * has the features needed to provide instrumentation.
11
- * @param {Object} AWS AWS SDK object
11
+ * @param {object} AWS AWS SDK object
12
12
  */
13
13
  const instrumentationSupported = function instrumentationSupported(AWS) {
14
14
  // instrumentation requires the serviceClientOperationsMap property
@@ -43,7 +43,7 @@ const CONVERSE_COMMANDS = new Set([
43
43
  /**
44
44
  * Helper to determine if we should instrument the bedrock middleware call
45
45
  *
46
- * @param {Object} config agent configuration
46
+ * @param {object} config agent configuration
47
47
  * @returns {boolean} to instrument or not to instrument
48
48
  */
49
49
  function shouldSkipInstrumentation(config) {
@@ -251,9 +251,9 @@ function createBedrockResponse({ bedrockCommand, response, err }) {
251
251
  * @param {object} params { config, commandName } aws config and command name
252
252
  * @param {string} params.commandName name of command
253
253
  * @param {Shim} shim instance of shim
254
- * @param {function} _original original middleware function
254
+ * @param {Function} _original original middleware function
255
255
  * @param {string} _name function name
256
- * @param {array} args argument passed to middleware
256
+ * @param {Array} args argument passed to middleware
257
257
  * @returns {object} specification object that records middleware as promise
258
258
  * with an after hook to create LLM events
259
259
  */
@@ -357,10 +357,10 @@ function handleResponse({ shim, err, response, segment, transaction, bedrockComm
357
357
  *
358
358
  * @param {Shim} shim instance of shim
359
359
  * @param {object} config AWS configuration object
360
- * @param {function} next the next middleware function in stack
360
+ * @param {Function} next the next middleware function in stack
361
361
  * @param {object} context AWS client context info
362
362
  *
363
- * @returns {function} the next middleware function in stack
363
+ * @returns {Function} the next middleware function in stack
364
364
  */
365
365
  function bedrockMiddleware(shim, config, next, context) {
366
366
  const { commandName } = context
@@ -13,9 +13,9 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
13
13
  * header to all outgoing requests
14
14
  *
15
15
  * @param {Shim} shim instance
16
- * @param {Object} config configuration options
17
- * @param {function} next next function in middleware chain
18
- * @returns {function}
16
+ * @param {object} config configuration options
17
+ * @param {Function} next next function in middleware chain
18
+ * @returns {Function}
19
19
  *
20
20
  */
21
21
  function headerMiddleware(shim, config, next) {
@@ -32,10 +32,10 @@ function headerMiddleware(shim, config, next) {
32
32
  * appropriate segment attributes for the AWS command
33
33
  *
34
34
  * @param {Shim} shim instance
35
- * @param {Object} config AWS command configuration
36
- * @param {function} next next function in middleware chain
37
- * @param {Object} context AWS command context
38
- * @returns {function}
35
+ * @param {object} config AWS command configuration
36
+ * @param {Function} next next function in middleware chain
37
+ * @param {object} context AWS command context
38
+ * @returns {Function}
39
39
  */
40
40
  function attrMiddleware(shim, config, next, context) {
41
41
  return async function wrappedMiddleware(args) {
@@ -55,12 +55,12 @@ function attrMiddleware(shim, config, next, context) {
55
55
  * Adds the necessary aws.* attributes to either the External or first
56
56
  * class operation segment
57
57
  *
58
- * @param {Object} params params object
59
- * @param {Object} params.result result from middleware
60
- * @param {Object} params.config AWS config
58
+ * @param {object} params params object
59
+ * @param {object} params.result result from middleware
60
+ * @param {object} params.config AWS config
61
61
  * @param {string} params.region AWS region
62
62
  * @param {Shim} params.shim Shim instance
63
- * @param {Object} params.context smithy client context
63
+ * @param {object} params.context smithy client context
64
64
  */
65
65
  function addAwsAttributes({ result, config, region, shim, context }) {
66
66
  try {
@@ -13,9 +13,9 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
13
13
  *
14
14
  * @param {Shim} shim Shim instance
15
15
  * @param {original} original Original middleware function
16
- * @param {String} name Name of the calling function
16
+ * @param {string} name Name of the calling function
17
17
  * @param {Array} args Arguments for the middleware function
18
- * @returns {Object}
18
+ * @returns {object}
19
19
  */
20
20
  function getDynamoSpec(shim, original, name, args) {
21
21
  const [{ input }] = args
@@ -35,7 +35,7 @@ function getDynamoSpec(shim, original, name, args) {
35
35
  * unless you provide an endpoint override to your library constructor
36
36
  * This function will derive the endpoint in that scenario by grabbing the region
37
37
  * and building the URL
38
- * @param {Object} config configuration options
38
+ * @param {object} config configuration options
39
39
  */
40
40
  async function getEndpoint(config) {
41
41
  if (typeof config.endpoint === 'function') {
@@ -51,10 +51,10 @@ async function getEndpoint(config) {
51
51
  * when command is in a list of monitored commands.
52
52
  *
53
53
  * @param {Shim} shim Shim instance
54
- * @param {Object} config AWS SDK client configuration
55
- * @param {function} next middleware function
56
- * @param {Object} context Context for the running command
57
- * @returns {function}
54
+ * @param {object} config AWS SDK client configuration
55
+ * @param {Function} next middleware function
56
+ * @param {object} context Context for the running command
57
+ * @returns {Function}
58
58
  */
59
59
  function dynamoMiddleware(shim, config, next, context) {
60
60
  const { commandName } = context
@@ -77,9 +77,9 @@ function dynamoMiddleware(shim, config, next, context) {
77
77
  * cloud.resource_id segment attributes for the AWS command
78
78
  *
79
79
  * @param {Shim} shim Shim instance
80
- * @param {Object} config AWS command configuration
81
- * @param {function} next next function in middleware chain
82
- * @returns {function}
80
+ * @param {object} config AWS command configuration
81
+ * @param {Function} next next function in middleware chain
82
+ * @returns {Function}
83
83
  */
84
84
  function resourceIdMiddlerware(shim, config, next) {
85
85
  return async function wrappedResourceIdMiddlerware(args) {
@@ -11,9 +11,9 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
11
11
  * cloud.resource_id segment attributes for the AWS command
12
12
  *
13
13
  * @param {Shim} shim New Relic agent shim
14
- * @param {Object} config AWS command configuration
15
- * @param {function} next next function in middleware chain
16
- * @returns {function} wrapped version of middleware function
14
+ * @param {object} config AWS command configuration
15
+ * @param {Function} next next function in middleware chain
16
+ * @returns {Function} wrapped version of middleware function
17
17
  */
18
18
  function resourceIdMiddleware(shim, config, next) {
19
19
  return async function wrappedResourceIdMiddleware(args) {
@@ -12,10 +12,10 @@ const InstrumentationDescriptor = require('../../../instrumentation-descriptor')
12
12
  * when command is `PublishCommand`
13
13
  *
14
14
  * @param {Shim} shim instance
15
- * @param {Object} config configuration options
16
- * @param {function} next middleware function
17
- * @param {Object} context context
18
- * @returns {function}
15
+ * @param {object} config configuration options
16
+ * @param {Function} next middleware function
17
+ * @param {object} context context
18
+ * @returns {Function}
19
19
  */
20
20
  function snsMiddleware(shim, config, next, context) {
21
21
  if (context.commandName === 'PublishCommand') {
@@ -30,10 +30,10 @@ function snsMiddleware(shim, config, next, context) {
30
30
  * Returns the spec for PublishCommand
31
31
  *
32
32
  * @param {Shim} shim instance
33
- * @param {function} original original middleware function
33
+ * @param {Function} original original middleware function
34
34
  * @param {string} name function name
35
35
  * @param {Array} args to the middleware function
36
- * @returns {Object}
36
+ * @returns {object}
37
37
  */
38
38
  function getSnsSpec(shim, original, name, args) {
39
39
  const [command] = args
@@ -50,7 +50,7 @@ function getSnsSpec(shim, original, name, args) {
50
50
  * Helper to set the appropriate destinationName based on
51
51
  * the command input
52
52
  *
53
- * @param {Object} params params object
53
+ * @param {object} params params object
54
54
  * @param {string} params.TopicArn TopicArn if available
55
55
  * @param {string} params.TargetArn TargetArn if available
56
56
  */