newrelic 13.18.0 → 13.19.1

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 (69) hide show
  1. package/NEWS.md +41 -0
  2. package/THIRD_PARTY_NOTICES.md +32 -31
  3. package/lib/instrumentation/aws-sdk/nr-hooks.js +0 -12
  4. package/lib/llm-events/anthropic-sdk/chat-completion-message.js +80 -0
  5. package/lib/llm-events/anthropic-sdk/chat-completion-summary.js +88 -0
  6. package/lib/llm-events/anthropic-sdk/error-message.js +30 -0
  7. package/lib/llm-events/anthropic-sdk/get-usage-tokens.js +28 -0
  8. package/lib/llm-events/anthropic-sdk/index.js +10 -0
  9. package/lib/llm-events/aws-bedrock/error-message.js +23 -0
  10. package/lib/llm-events/aws-bedrock/index.js +1 -0
  11. package/lib/llm-events/error-message.js +3 -34
  12. package/lib/llm-events/google-genai/error-message.js +36 -0
  13. package/lib/llm-events/google-genai/index.js +2 -1
  14. package/lib/llm-events/langchain/error-message.js +23 -0
  15. package/lib/llm-events/langchain/index.js +2 -1
  16. package/lib/message-broker-description.js +123 -0
  17. package/lib/metrics/names.js +5 -0
  18. package/lib/otel/traces/constants.js +40 -1
  19. package/lib/otel/traces/segments/database.js +1 -1
  20. package/lib/otel/traces/transformation-rules.json +175 -0
  21. package/lib/subscriber-configs.js +2 -0
  22. package/lib/subscribers/ai-monitoring/chat.js +12 -1
  23. package/lib/subscribers/ai-monitoring/embedding.js +12 -1
  24. package/lib/subscribers/amqplib/consume.js +16 -2
  25. package/lib/subscribers/amqplib/send-message.js +13 -2
  26. package/lib/subscribers/anthropic-sdk/config.js +27 -0
  27. package/lib/subscribers/anthropic-sdk/create.js +199 -0
  28. package/lib/subscribers/aws-sdk/config.js +103 -0
  29. package/lib/subscribers/aws-sdk/index.js +54 -0
  30. package/lib/subscribers/aws-sdk/legacy-send.js +17 -0
  31. package/lib/subscribers/aws-sdk/middleware/bedrock/constants.js +29 -0
  32. package/lib/subscribers/aws-sdk/middleware/bedrock/index.js +130 -0
  33. package/lib/subscribers/aws-sdk/middleware/bedrock/utils.js +318 -0
  34. package/lib/subscribers/aws-sdk/middleware/dynamodb/index.js +153 -0
  35. package/lib/{instrumentation/aws-sdk/v3/lambda.js → subscribers/aws-sdk/middleware/lambda/index.js} +9 -17
  36. package/lib/subscribers/aws-sdk/middleware/nr-specific/attributes.js +51 -0
  37. package/lib/subscribers/aws-sdk/middleware/nr-specific/headers.js +30 -0
  38. package/lib/subscribers/aws-sdk/middleware/nr-specific/index.js +11 -0
  39. package/lib/subscribers/aws-sdk/middleware/sns/index.js +72 -0
  40. package/lib/subscribers/aws-sdk/middleware/sqs/index.js +113 -0
  41. package/lib/subscribers/aws-sdk/send.js +94 -0
  42. package/lib/subscribers/aws-sdk/utils/attach-headers.js +51 -0
  43. package/lib/subscribers/aws-sdk/utils/constants.js +12 -0
  44. package/lib/subscribers/aws-sdk/utils/retrieve-headers.js +29 -0
  45. package/lib/subscribers/google-genai/embed-content.js +5 -1
  46. package/lib/subscribers/google-genai/generate-content.js +7 -1
  47. package/lib/subscribers/langchain/runnable.js +6 -1
  48. package/lib/subscribers/langchain/tool.js +1 -2
  49. package/lib/subscribers/langchain/vectorstore.js +3 -2
  50. package/lib/subscribers/langgraph/graph-stream.js +1 -1
  51. package/lib/subscribers/openai/chat.js +1 -6
  52. package/lib/subscribers/openai/client.js +1 -6
  53. package/lib/subscribers/openai/config.js +6 -6
  54. package/lib/subscribers/openai/embeddings.js +1 -6
  55. package/lib/subscribers/pg/config.js +6 -6
  56. package/lib/subscribers/pg/connect.js +1 -6
  57. package/lib/subscribers/pg/query.js +1 -6
  58. package/lib/subscribers/utils.js +0 -1
  59. package/lib/transaction/index.js +5 -4
  60. package/lib/transaction/trace/index.js +2 -0
  61. package/package.json +2 -2
  62. package/lib/instrumentation/aws-sdk/v3/bedrock.js +0 -409
  63. package/lib/instrumentation/aws-sdk/v3/common.js +0 -99
  64. package/lib/instrumentation/aws-sdk/v3/dynamodb.js +0 -137
  65. package/lib/instrumentation/aws-sdk/v3/smithy-client.js +0 -67
  66. package/lib/instrumentation/aws-sdk/v3/sns.js +0 -74
  67. package/lib/instrumentation/aws-sdk/v3/sqs.js +0 -86
  68. /package/lib/{instrumentation/aws-sdk/v3 → subscribers/aws-sdk/middleware/bedrock}/converse-stream-handler.js +0 -0
  69. /package/lib/{instrumentation/aws-sdk/v3 → subscribers/aws-sdk/middleware/bedrock}/stream-handler.js +0 -0
package/NEWS.md CHANGED
@@ -1,3 +1,44 @@
1
+ ### v13.19.1 (2026-04-15)
2
+
3
+ #### Bug fixes
4
+
5
+ * Fixed detecting AWS SDK message attributes presence ([#3903](https://github.com/newrelic/node-newrelic/pull/3903)) ([e81dc61](https://github.com/newrelic/node-newrelic/commit/e81dc61924f756f8edf5b7ce0770840cdc435d76))
6
+
7
+ #### Tests
8
+
9
+ * Updated `minAgentVersion` for Anthropic versioned tests ([#3900](https://github.com/newrelic/node-newrelic/pull/3900)) ([e1f6c32](https://github.com/newrelic/node-newrelic/commit/e1f6c3295627126dad9333a58a83084312370c5b))
10
+ * Reorganized the test utilities in AWS versioned tests ([#3895](https://github.com/newrelic/node-newrelic/pull/3895)) ([3025571](https://github.com/newrelic/node-newrelic/commit/3025571741c71d8a41968a0c06a412f5a9689bad))
11
+
12
+ ### v13.19.0 (2026-04-13)
13
+
14
+ #### Features
15
+ * Added instrumentation support for `@anthropic-ai/sdk` ([#3881](https://github.com/newrelic/node-newrelic/pull/3881)) ([e8713bb](https://github.com/newrelic/node-newrelic/commit/e8713bbe43d181ea96a33ccd6b241532e41206f4))
16
+ * Updated OTel DB attributes to stable names from semantic conventions 1.40.0 ([#3826](https://github.com/newrelic/node-newrelic/pull/3826)) ([6d3000d](https://github.com/newrelic/node-newrelic/commit/6d3000d8dd699bdf5f3ecf4b4a18b28990234486))
17
+ * Added distributed tracing propagation to SNS ([#3893](https://github.com/newrelic/node-newrelic/pull/3893)) ([8fc1144](https://github.com/newrelic/node-newrelic/commit/8fc11445122181f60404b7a75c35d2d914b0c5d0))
18
+
19
+ #### Code refactoring
20
+
21
+ * Refactor `@aws-sdk` v3 instrumentation to subscribe to events emitted
22
+ * Added `@aws-sdk/smithy-client` subscriber ([#3877](https://github.com/newrelic/node-newrelic/pull/3877)) ([0e350fc](https://github.com/newrelic/node-newrelic/commit/0e350fc92156b73928f37e6d32be0c3ea823d3e4))
23
+ * Added `@smithy/smithy-client` `send` subscriber with AWS Bedrock Middleware ([#3864](https://github.com/newrelic/node-newrelic/pull/3864)) ([5e0a6d1](https://github.com/newrelic/node-newrelic/commit/5e0a6d1cdbfbcc90d397c14e34e82ae86cb101b5))
24
+ * Moved generic AWS `Client` middleware to subscriber ([#3889](https://github.com/newrelic/node-newrelic/pull/3889)) ([3cb1e1b](https://github.com/newrelic/node-newrelic/commit/3cb1e1bf6818d63475f132979e7e4c965ba7add5))
25
+ * Updated `aws-sdk/dynamodb` instrumentation to a subscriber middleware ([#3891](https://github.com/newrelic/node-newrelic/pull/3891)) ([ff677a2](https://github.com/newrelic/node-newrelic/commit/ff677a26a62d4af80de7c92a238a0591a012485d))
26
+ * Updated aws sdk v3 instrumentation to split out bedrock utilities from actual wrapped middleware ([#3883](https://github.com/newrelic/node-newrelic/pull/3883)) ([eed340e](https://github.com/newrelic/node-newrelic/commit/eed340eb6bd66e1821a4f3659fe16e376555fd37))
27
+ * Updated Lambda instrumentation to a subscriber middleware ([#3890](https://github.com/newrelic/node-newrelic/pull/3890)) ([12f8284](https://github.com/newrelic/node-newrelic/commit/12f8284b2946101f295e7fabe439c7db8afb161d))
28
+ * Refactored SNS instrumentation to subscriber type ([#3876](https://github.com/newrelic/node-newrelic/pull/3876)) ([b9f3326](https://github.com/newrelic/node-newrelic/commit/b9f332644755c8bf89a88f8c786e642797cecf70))
29
+ * Refactored SQS instrumentation to subscriber type ([#3880](https://github.com/newrelic/node-newrelic/pull/3880)) ([de46dee](https://github.com/newrelic/node-newrelic/commit/de46deed6d9e1673e7504b5f48b5836d2c244a68))
30
+ * Refactored `LlmErrorMessage` to use vendor-specific subclasses ([#3882](https://github.com/newrelic/node-newrelic/pull/3882)) ([5b0fd2b](https://github.com/newrelic/node-newrelic/commit/5b0fd2ba21a68ab678e05e1bb3533e1547c1f1d5))
31
+ * Refactored `amqplib` to use message broker constants ([#3879](https://github.com/newrelic/node-newrelic/pull/3879)) ([77621fb](https://github.com/newrelic/node-newrelic/commit/77621fbb33169bad90165de95f11c3c4a1b7fc94))
32
+
33
+ #### Documentation
34
+
35
+ * Updated compatibility report ([#3874](https://github.com/newrelic/node-newrelic/pull/3874)) ([ae887c4](https://github.com/newrelic/node-newrelic/commit/ae887c42241dad86d222bd31c44b36af8e5ac76f))
36
+
37
+ #### Miscellaneous chores
38
+
39
+ * Updated `@apm-js-collab/tracing-hooks` to `0.6.0` ([#3884](https://github.com/newrelic/node-newrelic/pull/3884)) ([f6ef470](https://github.com/newrelic/node-newrelic/commit/f6ef470378445180bcd2fc12f5972df868bb74e5))
40
+ * Updated Undici tests to cover version 8 ([#3896](https://github.com/newrelic/node-newrelic/pull/3896)) ([f27e75f](https://github.com/newrelic/node-newrelic/commit/f27e75fcb1cd5b87a3908f1e0f99cd2eb1eaae37))
41
+
1
42
  ### v13.18.0 (2026-03-30)
2
43
 
3
44
  #### Features
@@ -95,7 +95,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
95
95
 
96
96
  ### @apm-js-collab/tracing-hooks
97
97
 
98
- This product includes source derived from [@apm-js-collab/tracing-hooks](https://github.com/apm-js-collab/tracing-hooks) ([v0.3.1](https://github.com/apm-js-collab/tracing-hooks/tree/v0.3.1)), distributed under the [Apache-2.0 License](https://github.com/apm-js-collab/tracing-hooks/blob/v0.3.1/LICENSE):
98
+ This product includes source derived from [@apm-js-collab/tracing-hooks](https://github.com/apm-js-collab/tracing-hooks) ([v0.6.0](https://github.com/apm-js-collab/tracing-hooks/tree/v0.6.0)), distributed under the [Apache-2.0 License](https://github.com/apm-js-collab/tracing-hooks/blob/v0.6.0/LICENSE):
99
99
 
100
100
  ```
101
101
 
@@ -978,7 +978,7 @@ This product includes source derived from [@opentelemetry/api-logs](https://gith
978
978
 
979
979
  ### @opentelemetry/api
980
980
 
981
- This product includes source derived from [@opentelemetry/api](https://github.com/open-telemetry/opentelemetry-js) ([v1.9.0](https://github.com/open-telemetry/opentelemetry-js/tree/v1.9.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v1.9.0/LICENSE):
981
+ This product includes source derived from [@opentelemetry/api](https://github.com/open-telemetry/opentelemetry-js) ([v1.9.1](https://github.com/open-telemetry/opentelemetry-js/tree/v1.9.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v1.9.1/LICENSE):
982
982
 
983
983
  ```
984
984
  Apache License
@@ -1187,7 +1187,7 @@ This product includes source derived from [@opentelemetry/api](https://github.co
1187
1187
 
1188
1188
  ### @opentelemetry/core
1189
1189
 
1190
- This product includes source derived from [@opentelemetry/core](https://github.com/open-telemetry/opentelemetry-js) ([v2.5.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.5.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.5.1/LICENSE):
1190
+ This product includes source derived from [@opentelemetry/core](https://github.com/open-telemetry/opentelemetry-js) ([v2.6.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.6.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.6.1/LICENSE):
1191
1191
 
1192
1192
  ```
1193
1193
  Apache License
@@ -1605,7 +1605,7 @@ This product includes source derived from [@opentelemetry/exporter-metrics-otlp-
1605
1605
 
1606
1606
  ### @opentelemetry/resources
1607
1607
 
1608
- This product includes source derived from [@opentelemetry/resources](https://github.com/open-telemetry/opentelemetry-js) ([v2.5.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.5.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.5.1/LICENSE):
1608
+ This product includes source derived from [@opentelemetry/resources](https://github.com/open-telemetry/opentelemetry-js) ([v2.6.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.6.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.6.1/LICENSE):
1609
1609
 
1610
1610
  ```
1611
1611
  Apache License
@@ -2023,7 +2023,7 @@ This product includes source derived from [@opentelemetry/sdk-logs](https://gith
2023
2023
 
2024
2024
  ### @opentelemetry/sdk-metrics
2025
2025
 
2026
- This product includes source derived from [@opentelemetry/sdk-metrics](https://github.com/open-telemetry/opentelemetry-js) ([v2.5.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.5.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.5.1/LICENSE):
2026
+ This product includes source derived from [@opentelemetry/sdk-metrics](https://github.com/open-telemetry/opentelemetry-js) ([v2.6.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.6.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.6.1/LICENSE):
2027
2027
 
2028
2028
  ```
2029
2029
  Apache License
@@ -2232,7 +2232,7 @@ This product includes source derived from [@opentelemetry/sdk-metrics](https://g
2232
2232
 
2233
2233
  ### @opentelemetry/sdk-trace-base
2234
2234
 
2235
- This product includes source derived from [@opentelemetry/sdk-trace-base](https://github.com/open-telemetry/opentelemetry-js) ([v2.5.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.5.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.5.1/LICENSE):
2235
+ This product includes source derived from [@opentelemetry/sdk-trace-base](https://github.com/open-telemetry/opentelemetry-js) ([v2.6.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.6.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.6.1/LICENSE):
2236
2236
 
2237
2237
  ```
2238
2238
  Apache License
@@ -2961,7 +2961,7 @@ SOFTWARE.
2961
2961
 
2962
2962
  ### @aws-sdk/client-s3
2963
2963
 
2964
- This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.1000.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.1000.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.1000.0/LICENSE):
2964
+ This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.1019.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.1019.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.1019.0/LICENSE):
2965
2965
 
2966
2966
  ```
2967
2967
  Apache License
@@ -3170,7 +3170,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co
3170
3170
 
3171
3171
  ### @aws-sdk/s3-request-presigner
3172
3172
 
3173
- This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.1000.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.1000.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.1000.0/LICENSE):
3173
+ This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.1019.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.1019.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.1019.0/LICENSE):
3174
3174
 
3175
3175
  ```
3176
3176
  Apache License
@@ -4832,27 +4832,27 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4832
4832
  This product includes source derived from [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) ([v4.3.0](https://github.com/ankitskvmdam/clean-jsdoc-theme/tree/v4.3.0)), distributed under the [MIT License](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/v4.3.0/LICENSE):
4833
4833
 
4834
4834
  ```
4835
- MIT License
4836
-
4837
- Copyright (c) 2019-2022 Ankit Kumar (अंकित कुमार)
4838
-
4839
- Permission is hereby granted, free of charge, to any person obtaining a copy
4840
- of this software and associated documentation files (the "Software"), to deal
4841
- in the Software without restriction, including without limitation the rights
4842
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4843
- copies of the Software, and to permit persons to whom the Software is
4844
- furnished to do so, subject to the following conditions:
4845
-
4846
- The above copyright notice and this permission notice shall be included in all
4847
- copies or substantial portions of the Software.
4848
-
4849
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4850
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4851
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4852
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4853
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4854
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4855
- SOFTWARE.
4835
+ MIT License
4836
+
4837
+ Copyright (c) 2019-2022 Ankit Kumar (अंकित कुमार)
4838
+
4839
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4840
+ of this software and associated documentation files (the "Software"), to deal
4841
+ in the Software without restriction, including without limitation the rights
4842
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4843
+ copies of the Software, and to permit persons to whom the Software is
4844
+ furnished to do so, subject to the following conditions:
4845
+
4846
+ The above copyright notice and this permission notice shall be included in all
4847
+ copies or substantial portions of the Software.
4848
+
4849
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4850
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4851
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4852
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4853
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4854
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4855
+ SOFTWARE.
4856
4856
 
4857
4857
  ```
4858
4858
 
@@ -5001,7 +5001,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5001
5001
 
5002
5002
  ### eslint
5003
5003
 
5004
- This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.39.3](https://github.com/eslint/eslint/tree/v9.39.3)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.39.3/LICENSE):
5004
+ This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.39.4](https://github.com/eslint/eslint/tree/v9.39.4)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.39.4/LICENSE):
5005
5005
 
5006
5006
  ```
5007
5007
  Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
@@ -5752,7 +5752,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5752
5752
 
5753
5753
  ### @datadog/pprof
5754
5754
 
5755
- This product includes source derived from [@datadog/pprof](https://github.com/DataDog/pprof-nodejs) ([v5.13.4](https://github.com/DataDog/pprof-nodejs/tree/v5.13.4)), distributed under the [Apache-2.0 License](https://github.com/DataDog/pprof-nodejs/blob/v5.13.4/LICENSE):
5755
+ This product includes source derived from [@datadog/pprof](https://github.com/DataDog/pprof-nodejs) ([v5.14.1](https://github.com/DataDog/pprof-nodejs/tree/v5.14.1)), distributed under the [Apache-2.0 License](https://github.com/DataDog/pprof-nodejs/blob/v5.14.1/LICENSE):
5756
5756
 
5757
5757
  ```
5758
5758
 
@@ -6480,3 +6480,4 @@ Portions copyright Node.js contributors. Depending on your existing libraries an
6480
6480
  your systems may call externally maintained libraries in addition to those listed above.
6481
6481
  See [here](https://nodejs.org/en/docs/meta/topics/dependencies/) and [here](https://github.com/nodejs/node/blob/v4.3.1/LICENSE)
6482
6482
  for additional details regarding externally maintained libraries and certain related licenses and notices.
6483
+
@@ -11,18 +11,6 @@ const instrumentations = [
11
11
  type: InstrumentationDescriptor.TYPE_CONGLOMERATE,
12
12
  moduleName: 'aws-sdk',
13
13
  onRequire: require('./v2/instrumentation')
14
- },
15
- {
16
- type: InstrumentationDescriptor.TYPE_CONGLOMERATE,
17
- moduleName: '@aws-sdk/smithy-client',
18
- onRequire: require('./v3/smithy-client'),
19
- shimName: 'aws-sdk'
20
- },
21
- {
22
- type: InstrumentationDescriptor.TYPE_CONGLOMERATE,
23
- moduleName: '@smithy/smithy-client',
24
- onRequire: require('./v3/smithy-client'),
25
- shimName: 'aws-sdk'
26
14
  }
27
15
  ]
28
16
 
@@ -0,0 +1,80 @@
1
+ /*
2
+ * Copyright 2026 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const LlmChatCompletionMessage = require('../chat-completion-message')
9
+ const getUsageTokens = require('./get-usage-tokens')
10
+
11
+ /**
12
+ * Encapsulates an Anthropic SDK LlmChatCompletionMessage.
13
+ */
14
+ module.exports = class AnthropicLlmChatCompletionMessage extends LlmChatCompletionMessage {
15
+ constructor({
16
+ agent,
17
+ segment,
18
+ transaction,
19
+ request = {},
20
+ response = {},
21
+ sequence = 0,
22
+ content,
23
+ role,
24
+ completionId,
25
+ isResponse
26
+ }) {
27
+ super({
28
+ agent,
29
+ segment,
30
+ transaction,
31
+ vendor: 'anthropic',
32
+ sequence,
33
+ content,
34
+ role,
35
+ completionId,
36
+ isResponse,
37
+ responseModel: response?.model
38
+ })
39
+
40
+ this.setTokenCount(agent, request, response)
41
+ }
42
+
43
+ setTokenCount(agent, request, response) {
44
+ const tokenCB = agent.llm?.tokenCountCallback
45
+
46
+ if (tokenCB) {
47
+ const promptContent = request?.messages
48
+ ?.map((msg) => {
49
+ if (typeof msg.content === 'string') return msg.content
50
+ if (Array.isArray(msg.content)) {
51
+ return msg.content
52
+ .filter((block) => block.type === 'text')
53
+ .map((block) => block.text)
54
+ .join(' ')
55
+ }
56
+ return ''
57
+ })
58
+ .join(' ')
59
+
60
+ const completionContent = response?.content
61
+ ?.filter((block) => block.type === 'text')
62
+ ?.map((block) => block.text)
63
+ ?.join(' ')
64
+
65
+ if (promptContent && completionContent) {
66
+ this.setTokenFromCallback({
67
+ tokenCB,
68
+ reqModel: request.model,
69
+ resModel: this['response.model'],
70
+ promptContent,
71
+ completionContent
72
+ })
73
+ }
74
+ return
75
+ }
76
+
77
+ const tokens = getUsageTokens(response)
78
+ this.setTokenInCompletionMessage(tokens)
79
+ }
80
+ }
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Copyright 2026 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const LlmChatCompletionSummary = require('../chat-completion-summary')
9
+ const getUsageTokens = require('./get-usage-tokens')
10
+
11
+ /**
12
+ * Encapsulates an Anthropic SDK LlmChatCompletionSummary.
13
+ */
14
+ module.exports = class AnthropicLlmChatCompletionSummary extends LlmChatCompletionSummary {
15
+ /**
16
+ * @param {object} params Constructor parameters
17
+ * @param {Agent} params.agent New Relic agent instance
18
+ * @param {TraceSegment} params.segment Current segment
19
+ * @param {Transaction} params.transaction Current and active transaction
20
+ * @param {object} params.request Anthropic SDK request object
21
+ * @param {object} params.response Anthropic SDK response object
22
+ * @param {number} [params.timeOfFirstToken] Timestamp of when the first token was sent, for streaming only.
23
+ * @param {boolean} [params.error] Set to `true` if an error occurred
24
+ */
25
+ constructor({ agent, segment, transaction, request, response, timeOfFirstToken, error }) {
26
+ super({
27
+ agent,
28
+ segment,
29
+ transaction,
30
+ responseModel: response?.model,
31
+ requestModel: request?.model,
32
+ finishReason: response?.stop_reason,
33
+ maxTokens: request?.max_tokens,
34
+ temperature: request?.temperature,
35
+ vendor: 'anthropic',
36
+ timeOfFirstToken,
37
+ error
38
+ })
39
+
40
+ let requestMessagesLength = 0
41
+ if (Array.isArray(request?.messages)) {
42
+ requestMessagesLength = request.messages.length
43
+ }
44
+ // Response is always a single message from the assistant
45
+ const responseMessageCount = response?.content ? 1 : 0
46
+ this['response.number_of_messages'] = requestMessagesLength + responseMessageCount
47
+
48
+ this.setTokens(agent, request, response)
49
+ }
50
+
51
+ setTokens(agent, request, response) {
52
+ const tokenCB = agent.llm?.tokenCountCallback
53
+
54
+ if (tokenCB) {
55
+ const promptContent = request?.messages
56
+ ?.map((msg) => {
57
+ if (typeof msg.content === 'string') return msg.content
58
+ if (Array.isArray(msg.content)) {
59
+ return msg.content
60
+ .filter((block) => block.type === 'text')
61
+ .map((block) => block.text)
62
+ .join(' ')
63
+ }
64
+ return ''
65
+ })
66
+ .join(' ')
67
+
68
+ const completionContent = response?.content
69
+ ?.filter((block) => block.type === 'text')
70
+ ?.map((block) => block.text)
71
+ ?.join(' ')
72
+
73
+ if (promptContent && completionContent) {
74
+ this.setTokenUsageFromCallback({
75
+ tokenCB,
76
+ reqModel: request.model,
77
+ resModel: this['response.model'],
78
+ promptContent,
79
+ completionContent
80
+ })
81
+ }
82
+ return
83
+ }
84
+
85
+ const tokens = getUsageTokens(response)
86
+ this.setTokensInResponse(tokens)
87
+ }
88
+ }
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright 2026 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const LlmErrorMessage = require('../error-message')
9
+
10
+ module.exports = class AnthrophicLlmErrorMessage extends LlmErrorMessage {
11
+ constructor(params = {}) {
12
+ super(params)
13
+ const { cause } = params
14
+ // Anthropic SDK errors seem to have two different formats:
15
+ // `cause.cause` and `cause.error.error`
16
+
17
+ // For errors like 'Connection error', attributes live on `cause.cause`.
18
+ if (cause?.cause?.message) {
19
+ // `cause.cause.message` is more verbose than `cause.message`,
20
+ // so we'll use it instead
21
+ this['error.message'] = cause.cause.message
22
+ }
23
+ // For errors like 'UnprocessableEntityError', there is also
24
+ // `cause.error.error.message` but it is actually less verbose
25
+ // than `cause.message`, so we'll use `cause.message` in this case.
26
+ if (cause?.error?.error?.code) {
27
+ this['error.code'] = cause.error.error.code
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright 2026 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ module.exports = getUsageTokens
9
+
10
+ /**
11
+ * Grabs the prompt, completion, and total token count from the
12
+ * given response object.
13
+ * @param {object} response Anthropic SDK response object
14
+ * @returns {object} { promptTokens, completionTokens, totalTokens }
15
+ */
16
+ function getUsageTokens(response) {
17
+ const { usage } = response
18
+ if (!usage) {
19
+ return { promptTokens: 0, completionTokens: 0, totalTokens: 0 }
20
+ }
21
+ const promptTokens = Number(usage.input_tokens)
22
+ const completionTokens = Number(usage.output_tokens)
23
+ return {
24
+ promptTokens,
25
+ completionTokens,
26
+ totalTokens: promptTokens + completionTokens
27
+ }
28
+ }
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Copyright 2026 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ module.exports = {
7
+ LlmChatCompletionMessage: require('./chat-completion-message'),
8
+ LlmChatCompletionSummary: require('./chat-completion-summary'),
9
+ LlmErrorMessage: require('./error-message')
10
+ }
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright 2026 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const LlmErrorMessage = require('../error-message')
9
+
10
+ /**
11
+ * AWS Bedrock-specific LLM error message.
12
+ * Uses `cause.name` as the error code instead of the default error code resolution.
13
+ *
14
+ * @augments LlmErrorMessage
15
+ */
16
+ module.exports = class AwsBedrockLlmErrorMessage extends LlmErrorMessage {
17
+ constructor(params = {}) {
18
+ super(params)
19
+ if (params.cause?.name) {
20
+ this['error.code'] = params.cause.name
21
+ }
22
+ }
23
+ }
@@ -7,6 +7,7 @@ module.exports = {
7
7
  LlmChatCompletionMessage: require('./chat-completion-message'),
8
8
  LlmChatCompletionSummary: require('./chat-completion-summary'),
9
9
  LlmEmbedding: require('./embedding'),
10
+ LlmErrorMessage: require('./error-message'),
10
11
  // Helper classes to create the Llm events
11
12
  BedrockCommand: require('./bedrock-command'),
12
13
  BedrockResponse: require('./bedrock-response'),
@@ -22,51 +22,20 @@ module.exports = class LlmErrorMessage {
22
22
  * search if it was a vector search event.
23
23
  * @param {LlmTool} [params.tool] Details about the tool event if it was a tool event.
24
24
  * @param {object} [params.aiAgent] Details about the AI agent event if it was an AI agent event.
25
- * @param {boolean} [params.useNameAsCode] defaults to false, only Bedrock sets it to true so far
26
25
  */
27
- constructor({ response, cause, summary = {}, embedding = {}, vectorsearch = {}, tool = {}, aiAgent = {}, useNameAsCode = false } = {}) {
26
+ constructor({ response, cause, summary = {}, embedding = {}, vectorsearch = {}, tool = {}, aiAgent = {} } = {}) {
28
27
  this['http.statusCode'] = response?.statusCode ?? response?.status ?? cause?.status
29
28
  this['error.message'] = cause?.message
30
- this['error.code'] = response?.code ?? cause?.error?.code ?? cause?.code
31
- if (useNameAsCode) {
32
- this['error.code'] = cause?.name
33
- }
34
- if (cause?.['lc_error_code']) {
35
- // this is where langchain error codes live
36
- this['error.code'] = cause['lc_error_code']
37
- }
38
- this['error.param'] = response?.param ?? cause?.error?.param
29
+ this['error.code'] = response?.code ?? cause?.error?.code ?? cause?.code ?? cause?.cause?.code
30
+ this['error.param'] = response?.param ?? cause?.param ?? cause?.error?.param
39
31
  this.completion_id = summary?.id
40
32
  this.embedding_id = embedding?.id
41
33
  this.vector_store_id = vectorsearch?.id
42
34
  this.tool_id = tool?.id
43
35
  this.agent_id = aiAgent?.id
44
-
45
- if (embedding?.vendor === 'gemini' || summary?.vendor === 'gemini') {
46
- this.#handleGemini(cause)
47
- }
48
36
  }
49
37
 
50
38
  get [Symbol.toStringTag]() {
51
39
  return 'LlmErrorMessage'
52
40
  }
53
-
54
- /**
55
- * For `@google/genai` only, `cause` does not have the `error` or `status` fields,
56
- * but it does have `message` with the info we need. So, we need to parse
57
- * the relevant fields from cause.message to get `status` and `error`.
58
- * @param {object} cause error object
59
- */
60
- #handleGemini(cause) {
61
- if (cause?.message) {
62
- try {
63
- const jsonStartIndex = cause.message.indexOf('{')
64
- const jsonString = cause.message.substring(jsonStartIndex)
65
- const parsedError = JSON.parse(jsonString)?.error
66
-
67
- this['http.statusCode'] = parsedError?.code
68
- this['error.code'] = parsedError?.code
69
- } catch { }
70
- }
71
- }
72
41
  }
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright 2026 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const LlmErrorMessage = require('../error-message')
9
+
10
+ /**
11
+ * Google GenAI (Gemini)-specific LLM error message.
12
+ * For `@google/genai`, `cause` does not have the `error` or `status` fields,
13
+ * but it does have `message` with the info we need. Parses the relevant fields
14
+ * from `cause.message` to get `status` and `error`.
15
+ *
16
+ * @augments LlmErrorMessage
17
+ */
18
+ module.exports = class GoogleGenAiLlmErrorMessage extends LlmErrorMessage {
19
+ constructor(params = {}) {
20
+ super(params)
21
+ if (params.cause?.message === null) return
22
+
23
+ try {
24
+ const jsonStartIndex = params.cause.message.indexOf('{')
25
+ const jsonString = params.cause.message.substring(jsonStartIndex)
26
+ const parsedError = JSON.parse(jsonString)?.error
27
+
28
+ if (parsedError?.code) {
29
+ this['http.statusCode'] = parsedError.code
30
+ this['error.code'] = parsedError.code
31
+ }
32
+ } catch (error) {
33
+ this['error.message'] = `failed to parse cause.message: ${error.message}`
34
+ }
35
+ }
36
+ }
@@ -6,5 +6,6 @@
6
6
  module.exports = {
7
7
  LlmChatCompletionMessage: require('./chat-completion-message'),
8
8
  LlmChatCompletionSummary: require('./chat-completion-summary'),
9
- LlmEmbedding: require('./embedding')
9
+ LlmEmbedding: require('./embedding'),
10
+ LlmErrorMessage: require('./error-message')
10
11
  }
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright 2026 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const LlmErrorMessage = require('../error-message')
9
+
10
+ /**
11
+ * LangChain-specific LLM error message.
12
+ * Uses `cause.lc_error_code` as the error code when present.
13
+ *
14
+ * @augments LlmErrorMessage
15
+ */
16
+ module.exports = class LangChainLlmErrorMessage extends LlmErrorMessage {
17
+ constructor(params = {}) {
18
+ super(params)
19
+ if (params.cause?.['lc_error_code']) {
20
+ this['error.code'] = params.cause['lc_error_code']
21
+ }
22
+ }
23
+ }
@@ -8,5 +8,6 @@ module.exports = {
8
8
  LlmChatCompletionSummary: require('./chat-completion-summary'),
9
9
  LlmTool: require('./tool'),
10
10
  LlmVectorSearch: require('./vector-search'),
11
- LlmVectorSearchResult: require('./vector-search-result')
11
+ LlmVectorSearchResult: require('./vector-search-result'),
12
+ LlmErrorMessage: require('./error-message')
12
13
  }