newrelic 13.4.0 → 13.6.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 (173) hide show
  1. package/NEWS.md +72 -0
  2. package/api.js +4 -4
  3. package/lib/agent.js +4 -4
  4. package/lib/aggregators/event-aggregator.js +0 -2
  5. package/lib/aggregators/log-aggregator.js +2 -2
  6. package/lib/attributes.js +2 -2
  7. package/lib/collector/api.js +7 -7
  8. package/lib/collector/http-agents.js +2 -2
  9. package/lib/collector/remote-method.js +1 -1
  10. package/lib/collector/serverless.js +1 -1
  11. package/lib/config/attribute-filter.js +7 -7
  12. package/lib/config/build-instrumentation-config.js +13 -3
  13. package/lib/config/default.js +26 -15
  14. package/lib/config/formatters.js +3 -3
  15. package/lib/config/hsm.js +1 -1
  16. package/lib/config/index.js +61 -46
  17. package/lib/config/merge-server-config.js +6 -6
  18. package/lib/core-instrumentation.js +4 -0
  19. package/lib/db/query-parsers/elasticsearch.js +5 -4
  20. package/lib/db/query-parsers/sql.js +1 -1
  21. package/lib/environment.js +16 -16
  22. package/lib/errors/index.js +1 -1
  23. package/lib/harvester.js +8 -6
  24. package/lib/header-attributes.js +3 -3
  25. package/lib/header-processing.js +3 -3
  26. package/lib/health-reporter.js +2 -2
  27. package/lib/instrumentation/@google/genai.js +6 -9
  28. package/lib/instrumentation/@prisma/client.js +1 -1
  29. package/lib/instrumentation/aws-sdk/util.js +3 -3
  30. package/lib/instrumentation/aws-sdk/v2/instrumentation-helper.js +1 -1
  31. package/lib/instrumentation/aws-sdk/v3/bedrock.js +16 -14
  32. package/lib/instrumentation/aws-sdk/v3/common.js +11 -11
  33. package/lib/instrumentation/aws-sdk/v3/dynamodb.js +10 -10
  34. package/lib/instrumentation/aws-sdk/v3/lambda.js +3 -3
  35. package/lib/instrumentation/aws-sdk/v3/sns.js +7 -7
  36. package/lib/instrumentation/aws-sdk/v3/sqs.js +6 -6
  37. package/lib/instrumentation/bunyan.js +1 -5
  38. package/lib/instrumentation/core/child_process.js +4 -4
  39. package/lib/instrumentation/core/fs.js +2 -2
  40. package/lib/instrumentation/core/http2.js +266 -0
  41. package/lib/instrumentation/core/timers.js +4 -4
  42. package/lib/instrumentation/fastify/spec-builders.js +3 -23
  43. package/lib/instrumentation/fastify.js +23 -94
  44. package/lib/instrumentation/grpc-js/grpc.js +7 -7
  45. package/lib/instrumentation/kafkajs/consumer.js +1 -1
  46. package/lib/instrumentation/koa/instrumentation.js +1 -1
  47. package/lib/instrumentation/koa/route-instrumentation.js +16 -18
  48. package/lib/instrumentation/langchain/runnable.js +3 -3
  49. package/lib/instrumentation/langchain/vectorstore.js +3 -2
  50. package/lib/instrumentation/memcached.js +1 -1
  51. package/lib/instrumentation/nextjs/next-server.js +1 -3
  52. package/lib/instrumentation/nextjs/utils.js +2 -2
  53. package/lib/instrumentation/restify.js +2 -2
  54. package/lib/instrumentation/when/contextualizer.js +1 -1
  55. package/lib/instrumentation/when/index.js +5 -5
  56. package/lib/instrumentation/winston.js +1 -1
  57. package/lib/instrumentation-descriptor.js +2 -11
  58. package/lib/instrumentation-tracker.js +2 -2
  59. package/lib/instrumentations.js +1 -19
  60. package/lib/llm-events/aws-bedrock/bedrock-response.js +9 -0
  61. package/lib/llm-events/aws-bedrock/chat-completion-message.js +32 -4
  62. package/lib/llm-events/aws-bedrock/chat-completion-summary.js +32 -2
  63. package/lib/llm-events/aws-bedrock/embedding.js +37 -4
  64. package/lib/llm-events/aws-bedrock/stream-handler.js +22 -0
  65. package/lib/llm-events/aws-bedrock/utils.js +59 -1
  66. package/lib/llm-events/google-genai/chat-completion-message.js +33 -5
  67. package/lib/llm-events/google-genai/chat-completion-summary.js +33 -0
  68. package/lib/llm-events/google-genai/embedding.js +34 -4
  69. package/lib/llm-events/google-genai/utils.js +32 -0
  70. package/lib/llm-events/openai/chat-completion-message.js +33 -6
  71. package/lib/llm-events/openai/chat-completion-summary.js +36 -0
  72. package/lib/llm-events/openai/embedding.js +34 -4
  73. package/lib/llm-events/openai/utils.js +34 -0
  74. package/lib/llm-events/utils.js +110 -0
  75. package/lib/metrics/index.js +7 -7
  76. package/lib/metrics/normalizer/tx_segment.js +26 -28
  77. package/lib/metrics/normalizer.js +9 -7
  78. package/lib/metrics/recorders/database-operation.js +2 -3
  79. package/lib/metrics/recorders/distributed-trace.js +2 -2
  80. package/lib/metrics/recorders/middleware.js +1 -2
  81. package/lib/otel/context-manager.js +3 -3
  82. package/lib/otel/traces/rules.js +2 -2
  83. package/lib/otel/traces/segments/database.js +1 -1
  84. package/lib/otel/traces/utils.js +9 -9
  85. package/lib/{adaptive-sampler.js → samplers/adaptive-sampler.js} +8 -0
  86. package/lib/serverless/aws-lambda.js +9 -9
  87. package/lib/shim/datastore-shim.js +9 -9
  88. package/lib/shim/message-shim/consume.js +3 -3
  89. package/lib/shim/message-shim/index.js +8 -8
  90. package/lib/shim/message-shim/subscribe-consume.js +12 -10
  91. package/lib/shim/promise-shim.js +4 -5
  92. package/lib/shim/shim.js +23 -35
  93. package/lib/shim/specs/class.js +3 -3
  94. package/lib/shim/specs/middleware-mounter.js +2 -2
  95. package/lib/shim/specs/middleware.js +3 -3
  96. package/lib/shim/specs/query.js +1 -1
  97. package/lib/shim/specs/recorder.js +1 -1
  98. package/lib/shim/specs/wrap.js +2 -2
  99. package/lib/shim/transaction-shim.js +7 -7
  100. package/lib/shim/webframework-shim/common.js +2 -2
  101. package/lib/shim/webframework-shim/index.js +18 -10
  102. package/lib/shim/webframework-shim/middleware.js +12 -16
  103. package/lib/shimmer.js +75 -129
  104. package/lib/spans/span-context.js +1 -1
  105. package/lib/spans/span-event.js +1 -1
  106. package/lib/spans/streaming-span-event-aggregator.js +4 -1
  107. package/lib/spans/streaming-span-event.js +1 -1
  108. package/lib/stats/apdex.js +1 -1
  109. package/lib/subscriber-configs.js +5 -1
  110. package/lib/subscribers/amqplib/config.js +2 -0
  111. package/lib/subscribers/amqplib/connect.js +2 -2
  112. package/lib/subscribers/amqplib/send-or-enqueue.js +0 -2
  113. package/lib/subscribers/base.js +50 -32
  114. package/lib/subscribers/create-config.js +2 -2
  115. package/lib/subscribers/db-operation.js +12 -0
  116. package/lib/subscribers/dc-base.js +91 -0
  117. package/lib/subscribers/express/config.js +102 -0
  118. package/lib/subscribers/express/param.js +22 -0
  119. package/lib/subscribers/express/render.js +28 -0
  120. package/lib/subscribers/express/route.js +55 -0
  121. package/lib/subscribers/express/router-param.js +24 -0
  122. package/lib/subscribers/express/router-route.js +24 -0
  123. package/lib/subscribers/express/router-use.js +24 -0
  124. package/lib/subscribers/express/use.js +44 -0
  125. package/lib/subscribers/fastify/add-hook.js +45 -0
  126. package/lib/subscribers/fastify/config.js +39 -0
  127. package/lib/subscribers/fastify/decorate.js +33 -0
  128. package/lib/subscribers/fastify/index.js +32 -0
  129. package/lib/subscribers/ioredis/config.js +3 -3
  130. package/lib/subscribers/ioredis/index.js +24 -1
  131. package/lib/subscribers/mcp-sdk/client-request.js +1 -1
  132. package/lib/subscribers/mcp-sdk/config.js +2 -0
  133. package/lib/subscribers/middleware-wrapper.js +269 -0
  134. package/lib/subscribers/middleware.js +20 -0
  135. package/lib/subscribers/openai/base.js +5 -6
  136. package/lib/subscribers/openai/utils.js +6 -4
  137. package/lib/subscribers/pg/config.js +91 -0
  138. package/lib/subscribers/pg/connect.js +28 -0
  139. package/lib/subscribers/pg/native-connect.js +25 -0
  140. package/lib/subscribers/pg/native-query.js +22 -0
  141. package/lib/subscribers/pg/query.js +66 -0
  142. package/lib/subscribers/pino/index.js +2 -2
  143. package/lib/subscribers/propagation.js +1 -21
  144. package/lib/subscribers/undici/config.js +11 -0
  145. package/lib/subscribers/undici/index.js +195 -0
  146. package/lib/synthetics.js +4 -4
  147. package/lib/system-metrics-sampler.js +5 -5
  148. package/lib/tracking-packages.js +25 -0
  149. package/lib/transaction/dt-payload.js +1 -1
  150. package/lib/transaction/index.js +32 -28
  151. package/lib/transaction/name-state.js +6 -6
  152. package/lib/transaction/trace/aggregator.js +1 -1
  153. package/lib/transaction/trace/index.js +3 -1
  154. package/lib/transaction/trace/segment.js +3 -3
  155. package/lib/transaction/tracer/index.js +1 -1
  156. package/lib/uninstrumented.js +4 -4
  157. package/lib/util/cat.js +2 -2
  158. package/lib/util/hashes.js +4 -4
  159. package/lib/util/label-parser.js +7 -7
  160. package/lib/util/llm-utils.js +3 -3
  161. package/lib/util/logger.js +6 -6
  162. package/lib/util/process-version.js +1 -1
  163. package/lib/util/stream-sink.js +1 -1
  164. package/lib/utilization/docker-info.js +2 -2
  165. package/lib/utilization/ecs-info.js +1 -1
  166. package/lib/utilization/index.js +2 -2
  167. package/lib/w3c/traceparent.js +2 -2
  168. package/lib/w3c/tracestate.js +1 -1
  169. package/newrelic.js +1 -1
  170. package/package.json +1 -1
  171. package/lib/instrumentation/express.js +0 -176
  172. package/lib/instrumentation/pg.js +0 -137
  173. package/lib/instrumentation/undici.js +0 -229
package/NEWS.md CHANGED
@@ -1,3 +1,72 @@
1
+ ### v13.6.0 (2025-10-27)
2
+
3
+ #### Features
4
+
5
+ * Added instrumentation for http2 client methods ([#3284](https://github.com/newrelic/node-newrelic/pull/3284)) ([bda7aea](https://github.com/newrelic/node-newrelic/commit/bda7aeaac16ce9f54bd28de72aa7465be96cd157))
6
+
7
+ #### Bug fixes
8
+
9
+ * Updated `ioredis` instrumentation to handle breakage of errors when using `.pipeline`. ([#3457](https://github.com/newrelic/node-newrelic/pull/3457)) ([49f4d93](https://github.com/newrelic/node-newrelic/commit/49f4d93a59045f35406dfdbd3248dca0652727d6))
10
+ * Updated `openai` `instrumentStream` function to handle empty chunk when `include_usage` is set ([#3427](https://github.com/newrelic/node-newrelic/pull/3427)) ([f804940](https://github.com/newrelic/node-newrelic/commit/f8049405003f0811450f75468e0bddfb1f05ec2b))
11
+
12
+ #### Code refactoring
13
+
14
+ * Update `express` instrumentation to subscribe to events emitted ([#3424](https://github.com/newrelic/node-newrelic/pull/3424)) ([bbf3d01](https://github.com/newrelic/node-newrelic/commit/bbf3d010bc402953e53cae5200af6bfb55a6446d))
15
+ * Updated instances in instrumentation of `Array.forEach` for a more performant for...of or for index loop ([#3463](https://github.com/newrelic/node-newrelic/pull/3463)) ([99484ce](https://github.com/newrelic/node-newrelic/commit/99484ce0e7a963fbbc3cbc22f4956ce19e5eecc2))
16
+ * Updated instances of `Array.forEach` for a more performant for...of or for index loop ([#3440](https://github.com/newrelic/node-newrelic/pull/3440)) ([48c37bf](https://github.com/newrelic/node-newrelic/commit/48c37bf7f85291553666d4512ca995b6a5b136a2))
17
+ * Updated token calculation for `aws-bedrock` LLM Events ([#3445](https://github.com/newrelic/node-newrelic/pull/3445)) ([9450181](https://github.com/newrelic/node-newrelic/commit/945018171da713487a0b5b674e68bdbb211e655e))
18
+ * Updated token calculation for `google-genai` LLM Events ([#3431](https://github.com/newrelic/node-newrelic/pull/3431)) ([41d32be](https://github.com/newrelic/node-newrelic/commit/41d32befe1d9c3201b62253a5de76c918d98a025))
19
+ * Updated token calculation for `openai` LLM Events ([#3430](https://github.com/newrelic/node-newrelic/pull/3430)) ([b8678cc](https://github.com/newrelic/node-newrelic/commit/b8678cc92bb986eae7efec4b516f66406307e841))
20
+
21
+ #### Documentation
22
+
23
+ * Updated compatibility report ([#3459](https://github.com/newrelic/node-newrelic/pull/3459)) ([f253b97](https://github.com/newrelic/node-newrelic/commit/f253b97c039caa9e9110055d93e0c32e2d6911a8))
24
+
25
+ #### Miscellaneous chores
26
+
27
+ * Update release workflows ([#3444](https://github.com/newrelic/node-newrelic/pull/3444)) ([d1ec158](https://github.com/newrelic/node-newrelic/commit/d1ec158f46d034160b665f8b0785c020ba39b820))
28
+
29
+ #### Tests
30
+
31
+ * Added a `randomString` helper to agent_helper and use it in ioredis to avoid flappy tests, also updated local instances of random strings in kafka, elasticsearch and opensearch tests ([#3462](https://github.com/newrelic/node-newrelic/pull/3462)) ([4deb6d8](https://github.com/newrelic/node-newrelic/commit/4deb6d80d9daa7fd9d4c077a5cc52f358ed44e61))
32
+ * Fixed conflict between ioredis and ioredis-esm by running `flushdb` instead of `flushall` to avoid index getting removed mid test ([#3464](https://github.com/newrelic/node-newrelic/pull/3464)) ([5e3f0a8](https://github.com/newrelic/node-newrelic/commit/5e3f0a81bfcf8bc8cf04559f29d3a76c1262bcc7))
33
+ * Fixed express async error test to purposely misspell a method to emit a crash ([#3435](https://github.com/newrelic/node-newrelic/pull/3435)) ([ff9f064](https://github.com/newrelic/node-newrelic/commit/ff9f0646c4fc23e367c1e190eb8091423c690103))
34
+ * Moved aws-sdk-v3 common.js requirement of semver ([#3461](https://github.com/newrelic/node-newrelic/pull/3461)) ([6a380ef](https://github.com/newrelic/node-newrelic/commit/6a380ef580268be131417587a2dda5adf3545e68))
35
+ * Pinned Next.js tests to <16.0.0 ([#3446](https://github.com/newrelic/node-newrelic/pull/3446)) ([10787a1](https://github.com/newrelic/node-newrelic/commit/10787a1f4e325b7321173ee5b2fab0809af5e8d1))
36
+ * Updated minimum tested version of `@langchain/core` to 1.0.0 ([#3437](https://github.com/newrelic/node-newrelic/pull/3437)) ([b61f67a](https://github.com/newrelic/node-newrelic/commit/b61f67a4c6d59f0b2a49e0de93a6d38e56d214fd))
37
+
38
+ ### v13.5.0 (2025-10-14)
39
+
40
+ #### Code refactoring
41
+
42
+ * 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))
43
+ * 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))
44
+
45
+ * 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))
46
+ * To re-enable, set `config.instrumentation.timers.enabled` to `true` in config or set `NEW_RELIC_INSTRUMENTATION_TIMERS_ENABLED=true`
47
+
48
+ #### Documentation
49
+
50
+ * Updated compatibility report ([#3413](https://github.com/newrelic/node-newrelic/pull/3413)) ([fef98dd](https://github.com/newrelic/node-newrelic/commit/fef98ddffddf60b32f162ea87dee2a3a0bdf8048))
51
+
52
+ #### Miscellaneous chores
53
+
54
+ * 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))
55
+ * Created directory for samplers ([#3419](https://github.com/newrelic/node-newrelic/pull/3419)) ([dd2d3df](https://github.com/newrelic/node-newrelic/commit/dd2d3dfe1bb2582de51e07a1cce6077df84f7108))
56
+
57
+ #### Styles
58
+
59
+ * 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))
60
+ * 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))
61
+ * 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))
62
+
63
+ #### Tests
64
+
65
+ * 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))
66
+ * 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))
67
+ * 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))
68
+ * 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))
69
+
1
70
  ### v13.4.0 (2025-09-29)
2
71
 
3
72
  #### Code refactoring
@@ -7928,3 +7997,6 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
7928
7997
 
7929
7998
 
7930
7999
 
8000
+
8001
+
8002
+
package/api.js CHANGED
@@ -1813,16 +1813,16 @@ API.prototype.setUserID = function setUserID(id) {
1813
1813
  */
1814
1814
  function _filterAttributes(attributes, name) {
1815
1815
  const filteredAttributes = Object.create(null)
1816
- Object.keys(attributes).forEach((attributeKey) => {
1816
+ for (const attributeKey of Object.keys(attributes)) {
1817
1817
  if (!isValidType(attributes[attributeKey])) {
1818
1818
  logger.info(
1819
1819
  `Omitting attribute ${attributeKey} from ${name} call, type must ` +
1820
1820
  'be boolean, number, or string'
1821
1821
  )
1822
- return
1822
+ continue
1823
1823
  }
1824
1824
  filteredAttributes[attributeKey] = attributes[attributeKey]
1825
- })
1825
+ }
1826
1826
  return filteredAttributes
1827
1827
  }
1828
1828
 
@@ -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)
@@ -444,7 +444,7 @@ Agent.prototype._scheduleHarvests = function _scheduleHarvests(shouldImmediately
444
444
 
445
445
  const agent = this
446
446
 
447
- // For data collection that streams immediately, dont delay capture/sending until
447
+ // For data collection that streams immediately, don't delay capture/sending until
448
448
  // the harvest of everything else has completed.
449
449
  agent.startStreaming()
450
450
 
@@ -564,7 +564,7 @@ Agent.prototype._resetCustomEvents = function resetCustomEvents() {
564
564
  * @fires Agent#harvestFinished
565
565
  */
566
566
  Agent.prototype.harvestSync = function harvestSync() {
567
- logger.trace('Peparing to harvest.')
567
+ logger.trace('Preparing to harvest.')
568
568
 
569
569
  if (!this.collector.isConnected()) {
570
570
  throw new Error('Sync harvest not connected/enabled!')
@@ -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
@@ -81,9 +81,9 @@ class LogAggregator extends EventAggregator {
81
81
  }
82
82
 
83
83
  addBatch(logs, priority) {
84
- logs.forEach((logLine) => {
84
+ for (const logLine of logs) {
85
85
  super.add(logLine, priority)
86
- })
86
+ }
87
87
  }
88
88
 
89
89
  reconfigure(config) {
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()
@@ -63,15 +63,15 @@ const AGENT_RUN_BEHAVIOR = CollectorResponse.AGENT_RUN_BEHAVIOR
63
63
  function dumpErrors(errors, name) {
64
64
  let index = 1
65
65
 
66
- errors.forEach(function forEachError(error) {
66
+ for (const error of errors) {
67
67
  logger.trace(error, 'Error %s during %s:', index++, name)
68
68
 
69
69
  if (error.laterErrors) {
70
- error.laterErrors.forEach(function forEachLaterError(laterError) {
70
+ for (const laterError of error.laterErrors) {
71
71
  logger.trace(laterError, 'Error %s during %s:', index++, name)
72
- })
72
+ }
73
73
  }
74
- })
74
+ }
75
75
  }
76
76
 
77
77
  /**
@@ -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
  *
@@ -421,9 +421,9 @@ CollectorAPI.prototype._onConnect = function _onConnect(callback, error, res) {
421
421
 
422
422
  // Log "Reporting to..." message from connect response.
423
423
  if (config.messages) {
424
- config.messages.forEach((element) => {
424
+ for (const element of config.messages) {
425
425
  logger.info(element.message)
426
- })
426
+ }
427
427
  }
428
428
 
429
429
  // Store request headers for future collector requests if they're present
@@ -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) {
@@ -260,7 +260,7 @@ RemoteMethod.prototype._safeRequest = function _safeRequest(options) {
260
260
  level = 'info'
261
261
  }
262
262
 
263
- // check if trace is enabled or audit log(aka info in this case) before attemping
263
+ // check if trace is enabled or audit log(aka info in this case) before attempting
264
264
  // to get the body length or parse the path with redacted key
265
265
  if (logger.traceEnabled() || level === 'info') {
266
266
  const logBody = Buffer.isBuffer(options.body) ? 'Buffer ' + options.body.length : options.body
@@ -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) {
@@ -70,12 +70,12 @@ function AttributeFilter(config) {
70
70
  this._rules.global = Object.create(null)
71
71
 
72
72
  // And all the destination rules.
73
- DESTINATION_DETAILS.forEach(function forEachDestination(dest) {
73
+ for (const dest of DESTINATION_DETAILS) {
74
74
  config.on(dest.name + '.attributes.enabled', updater)
75
75
  config.on(dest.name + '.attributes.include', updater)
76
76
  config.on(dest.name + '.attributes.exclude', updater)
77
77
  this._rules[dest.name] = Object.create(null)
78
- }, this)
78
+ }
79
79
 
80
80
  // Now pull in all the rules.
81
81
  this.update()
@@ -184,10 +184,10 @@ AttributeFilter.prototype.update = function update() {
184
184
  this._cachedCount = 0
185
185
 
186
186
  // And all the destination rules.
187
- DESTINATION_DETAILS.forEach(function forEachDestination(dest) {
187
+ for (const dest of DESTINATION_DETAILS) {
188
188
  const name = dest.name
189
189
  if (!this.config[name].attributes.enabled) {
190
- return
190
+ continue
191
191
  }
192
192
 
193
193
  this._enabledDestinations |= dest.id
@@ -196,7 +196,7 @@ AttributeFilter.prototype.update = function update() {
196
196
  )
197
197
  this._rules[name].exclude = _importRules(this.config[name].attributes.exclude)
198
198
  this._cache[name] = Object.create(null)
199
- }, this)
199
+ }
200
200
  }
201
201
 
202
202
  /**
@@ -291,13 +291,13 @@ function _importRules(rules) {
291
291
  }
292
292
  const exactRules = []
293
293
  const wildcardRules = []
294
- rules.forEach(function separateRules(rule) {
294
+ for (const rule of rules) {
295
295
  if (rule[rule.length - 1] === '*') {
296
296
  wildcardRules.push(rule)
297
297
  } else {
298
298
  exactRules.push(rule)
299
299
  }
300
- })
300
+ }
301
301
 
302
302
  if (exactRules.length) {
303
303
  out.exact = new RegExp('^' + _convertRulesToRegex(exactRules) + '$')
@@ -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
  }, {})
@@ -323,7 +323,7 @@ defaultConfig.definition = () => {
323
323
  */
324
324
  diagnostics: {
325
325
  formatter: boolean,
326
- deafult: false
326
+ default: false
327
327
  }
328
328
  },
329
329
  audit_log: {
@@ -1145,7 +1145,7 @@ defaultConfig.definition = () => {
1145
1145
  /**
1146
1146
  * Controls whether the agent will generate spans for in-process actions.
1147
1147
  * When disabled, this will only create spans for entry and exit spans.
1148
- * entry spans - initial actions for web servers and messsage queue consumption.
1148
+ * entry spans - initial actions for web servers and message queue consumption.
1149
1149
  * exit spans - all outgoing calls to external services(external and database calls)
1150
1150
  */
1151
1151
  in_process_spans: {
@@ -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'
@@ -1388,7 +1399,7 @@ defaultConfig.definition = () => {
1388
1399
  /**
1389
1400
  * Obfuscates URL parameters
1390
1401
  * for outgoing and incoming requests
1391
- * for distrubuted tracing attributes - both transaction and span attributes
1402
+ * for distributed tracing attributes - both transaction and span attributes
1392
1403
  * for transaction trace transaction details
1393
1404
  */
1394
1405
  url_obfuscation: {
@@ -1418,7 +1429,7 @@ defaultConfig.definition = () => {
1418
1429
 
1419
1430
  /**
1420
1431
  * A string containing a replacement value for URL parameters
1421
- * can contain refferences to capture groups in the pattern
1432
+ * can contain references to capture groups in the pattern
1422
1433
  */
1423
1434
  replacement: {
1424
1435
  default: ''
@@ -1488,7 +1499,7 @@ defaultConfig.definition = () => {
1488
1499
  },
1489
1500
 
1490
1501
  /**
1491
- * Unique test identifier when runnning IAST with CI/CD
1502
+ * Unique test identifier when running IAST with CI/CD
1492
1503
  */
1493
1504
  iast_test_identifier: '',
1494
1505
 
@@ -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 {
package/lib/config/hsm.js CHANGED
@@ -71,7 +71,7 @@ const REDACT_BEFORE_SEND = new Set([
71
71
  'certificates' // should be public but in case user mistake and also these are huge
72
72
  ])
73
73
 
74
- // process.domain needs to be stripped befeore sending
74
+ // process.domain needs to be stripped before sending
75
75
  const REMOVE_BEFORE_SEND = new Set(['domain'])
76
76
 
77
77
  exports.HIGH_SECURITY_SETTINGS = HIGH_SECURITY_SETTINGS