newrelic 13.17.0 → 13.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NEWS.md +92 -31
- package/THIRD_PARTY_NOTICES.md +32 -31
- package/lib/context-manager/context.js +14 -1
- package/lib/feature_flags.js +1 -1
- package/lib/instrumentation/aws-sdk/nr-hooks.js +0 -12
- package/lib/instrumentations.js +1 -6
- package/lib/llm-events/anthropic-sdk/chat-completion-message.js +80 -0
- package/lib/llm-events/anthropic-sdk/chat-completion-summary.js +88 -0
- package/lib/llm-events/anthropic-sdk/error-message.js +30 -0
- package/lib/llm-events/anthropic-sdk/get-usage-tokens.js +28 -0
- package/lib/llm-events/anthropic-sdk/index.js +10 -0
- package/lib/llm-events/aws-bedrock/error-message.js +23 -0
- package/lib/llm-events/aws-bedrock/index.js +1 -0
- package/lib/llm-events/error-message.js +3 -34
- package/lib/llm-events/google-genai/error-message.js +36 -0
- package/lib/llm-events/google-genai/index.js +2 -1
- package/lib/llm-events/langchain/error-message.js +23 -0
- package/lib/llm-events/langchain/index.js +2 -1
- package/lib/message-broker-description.js +123 -0
- package/lib/metrics/names.js +5 -0
- package/lib/otel/traces/constants.js +40 -1
- package/lib/otel/traces/segments/database.js +1 -1
- package/lib/otel/traces/transformation-rules.json +175 -0
- package/lib/spans/span-link.js +4 -2
- package/lib/subscriber-configs.js +8 -1
- package/lib/subscribers/README.md +10 -0
- package/lib/subscribers/ai-monitoring/chat.js +12 -1
- package/lib/subscribers/ai-monitoring/embedding.js +12 -1
- package/lib/subscribers/amqplib/consume.js +16 -2
- package/lib/subscribers/amqplib/send-message.js +13 -2
- package/lib/subscribers/anthropic-sdk/config.js +27 -0
- package/lib/subscribers/anthropic-sdk/create.js +199 -0
- package/lib/subscribers/aws-sdk/config.js +103 -0
- package/lib/subscribers/aws-sdk/index.js +54 -0
- package/lib/subscribers/aws-sdk/legacy-send.js +17 -0
- package/lib/subscribers/aws-sdk/middleware/bedrock/constants.js +29 -0
- package/lib/subscribers/aws-sdk/middleware/bedrock/index.js +130 -0
- package/lib/subscribers/aws-sdk/middleware/bedrock/utils.js +318 -0
- package/lib/subscribers/aws-sdk/middleware/dynamodb/index.js +153 -0
- package/lib/{instrumentation/aws-sdk/v3/lambda.js → subscribers/aws-sdk/middleware/lambda/index.js} +9 -17
- package/lib/subscribers/aws-sdk/middleware/nr-specific/attributes.js +51 -0
- package/lib/subscribers/aws-sdk/middleware/nr-specific/headers.js +30 -0
- package/lib/subscribers/aws-sdk/middleware/nr-specific/index.js +11 -0
- package/lib/subscribers/aws-sdk/middleware/sns/index.js +72 -0
- package/lib/subscribers/aws-sdk/middleware/sqs/index.js +113 -0
- package/lib/subscribers/aws-sdk/send.js +94 -0
- package/lib/subscribers/aws-sdk/utils/attach-headers.js +47 -0
- package/lib/subscribers/aws-sdk/utils/constants.js +12 -0
- package/lib/subscribers/aws-sdk/utils/retrieve-headers.js +29 -0
- package/lib/subscribers/base.js +12 -8
- package/lib/subscribers/bluebird/config.js +21 -0
- package/lib/subscribers/bluebird/instrumentation.js +59 -0
- package/lib/subscribers/google-genai/embed-content.js +5 -1
- package/lib/subscribers/google-genai/generate-content.js +7 -1
- package/lib/subscribers/grpcjs/client.js +126 -0
- package/lib/subscribers/grpcjs/config.js +63 -0
- package/lib/subscribers/grpcjs/http2-stream.js +14 -0
- package/lib/subscribers/grpcjs/resolving-call.js +14 -0
- package/lib/subscribers/grpcjs/server.js +206 -0
- package/lib/subscribers/grpcjs/should-track-error.js +12 -0
- package/lib/subscribers/index.js +37 -0
- package/lib/subscribers/langchain/config.js +22 -2
- package/lib/subscribers/langchain/runnable.js +6 -1
- package/lib/subscribers/langchain/tool.js +1 -2
- package/lib/subscribers/langchain/vectorstore.js +3 -2
- package/lib/subscribers/langgraph/graph-stream.js +1 -1
- package/lib/subscribers/memcached/command.js +69 -0
- package/lib/subscribers/memcached/config.js +23 -0
- package/lib/subscribers/message-consumer.js +8 -6
- package/lib/subscribers/openai/chat.js +1 -6
- package/lib/subscribers/openai/client.js +1 -6
- package/lib/subscribers/openai/config.js +6 -6
- package/lib/subscribers/openai/embeddings.js +1 -6
- package/lib/subscribers/pg/config.js +6 -6
- package/lib/subscribers/pg/connect.js +1 -6
- package/lib/subscribers/pg/query.js +1 -6
- package/lib/subscribers/q/config.js +32 -0
- package/lib/subscribers/q/next-tick.js +21 -0
- package/lib/subscribers/q/run-after.js +14 -0
- package/lib/subscribers/utils.js +0 -1
- package/lib/subscribers/when/config.js +21 -0
- package/lib/subscribers/when/instrumentation.js +33 -0
- package/lib/transaction/index.js +8 -5
- package/load-externals.js +13 -1
- package/package.json +2 -2
- package/lib/instrumentation/aws-sdk/v3/bedrock.js +0 -409
- package/lib/instrumentation/aws-sdk/v3/common.js +0 -99
- package/lib/instrumentation/aws-sdk/v3/dynamodb.js +0 -137
- package/lib/instrumentation/aws-sdk/v3/smithy-client.js +0 -67
- package/lib/instrumentation/aws-sdk/v3/sns.js +0 -74
- package/lib/instrumentation/aws-sdk/v3/sqs.js +0 -86
- package/lib/instrumentation/bluebird.js +0 -109
- package/lib/instrumentation/grpc-js/grpc.js +0 -271
- package/lib/instrumentation/grpc-js/nr-hooks.js +0 -32
- package/lib/instrumentation/memcached.js +0 -84
- package/lib/instrumentation/q.js +0 -29
- package/lib/instrumentation/when/constants.js +0 -66
- package/lib/instrumentation/when/contextualizer.js +0 -181
- package/lib/instrumentation/when/index.js +0 -363
- package/lib/instrumentation/when/nr-hooks.js +0 -16
- /package/lib/{instrumentation/aws-sdk/v3 → subscribers/aws-sdk/middleware/bedrock}/converse-stream-handler.js +0 -0
- /package/lib/{instrumentation/aws-sdk/v3 → subscribers/aws-sdk/middleware/bedrock}/stream-handler.js +0 -0
package/NEWS.md
CHANGED
|
@@ -1,34 +1,95 @@
|
|
|
1
|
-
### v13.
|
|
2
|
-
|
|
3
|
-
#### Features
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
### v13.19.0 (2026-04-13)
|
|
2
|
+
|
|
3
|
+
#### Features
|
|
4
|
+
* 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))
|
|
5
|
+
* 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))
|
|
6
|
+
* Added distributed tracing propagation to SNS ([#3893](https://github.com/newrelic/node-newrelic/pull/3893)) ([8fc1144](https://github.com/newrelic/node-newrelic/commit/8fc11445122181f60404b7a75c35d2d914b0c5d0))
|
|
7
|
+
|
|
8
|
+
#### Code refactoring
|
|
9
|
+
|
|
10
|
+
* Refactor `@aws-sdk` v3 instrumentation to subscribe to events emitted
|
|
11
|
+
* Added `@aws-sdk/smithy-client` subscriber ([#3877](https://github.com/newrelic/node-newrelic/pull/3877)) ([0e350fc](https://github.com/newrelic/node-newrelic/commit/0e350fc92156b73928f37e6d32be0c3ea823d3e4))
|
|
12
|
+
* 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))
|
|
13
|
+
* 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))
|
|
14
|
+
* 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))
|
|
15
|
+
* 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))
|
|
16
|
+
* 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))
|
|
17
|
+
* Refactored SNS instrumentation to subscriber type ([#3876](https://github.com/newrelic/node-newrelic/pull/3876)) ([b9f3326](https://github.com/newrelic/node-newrelic/commit/b9f332644755c8bf89a88f8c786e642797cecf70))
|
|
18
|
+
* Refactored SQS instrumentation to subscriber type ([#3880](https://github.com/newrelic/node-newrelic/pull/3880)) ([de46dee](https://github.com/newrelic/node-newrelic/commit/de46deed6d9e1673e7504b5f48b5836d2c244a68))
|
|
19
|
+
* 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))
|
|
20
|
+
* 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))
|
|
21
|
+
|
|
22
|
+
#### Documentation
|
|
23
|
+
|
|
24
|
+
* Updated compatibility report ([#3874](https://github.com/newrelic/node-newrelic/pull/3874)) ([ae887c4](https://github.com/newrelic/node-newrelic/commit/ae887c42241dad86d222bd31c44b36af8e5ac76f))
|
|
25
|
+
|
|
26
|
+
#### Miscellaneous chores
|
|
27
|
+
|
|
28
|
+
* 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))
|
|
29
|
+
* 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))
|
|
30
|
+
|
|
31
|
+
### v13.18.0 (2026-03-30)
|
|
32
|
+
|
|
33
|
+
#### Features
|
|
34
|
+
|
|
35
|
+
* Instrumented grpc server stream to bind async context to stream event handlers ([#3855](https://github.com/newrelic/node-newrelic/pull/3855)) ([92c70a8](https://github.com/newrelic/node-newrelic/commit/92c70a8c81c7bf26f63cf3f5b94d993ebc88bf51))
|
|
36
|
+
|
|
37
|
+
#### Code refactoring
|
|
38
|
+
|
|
39
|
+
* Refactored `when` instrumentation to subscribe to events emitted ([#3866](https://github.com/newrelic/node-newrelic/pull/3866)) ([1b55c5a](https://github.com/newrelic/node-newrelic/commit/1b55c5ae5df8eb8d20d499e31b80014acd9b7833))
|
|
40
|
+
* Refactored `memcached` instrumentation to subscribe to events emitted ([#3849](https://github.com/newrelic/node-newrelic/pull/3849)) ([915b320](https://github.com/newrelic/node-newrelic/commit/915b320e1b01944fe89754305e146c0c69dca0c6))
|
|
41
|
+
* Refactored `bluebird` instrumentation to subscribe to events emitted ([#3858](https://github.com/newrelic/node-newrelic/pull/3858)) ([e3d84c2](https://github.com/newrelic/node-newrelic/commit/e3d84c285b9b73c2d2e7f690fe449371e92a5b1a))
|
|
42
|
+
* Refactored `q` instrumentation to subscribe to events emitted ([#3853](https://github.com/newrelic/node-newrelic/pull/3853)) ([9fdb0b8](https://github.com/newrelic/node-newrelic/commit/9fdb0b80130998d283d3ec6a2f0e1b39916bd9e5))
|
|
43
|
+
* Refactored `grpc-js` client instrumentation to subscriber type ([#3856](https://github.com/newrelic/node-newrelic/pull/3856)) ([057fca2](https://github.com/newrelic/node-newrelic/commit/057fca295e31a952795d688e7a12228c58d839ba))
|
|
44
|
+
* Refactored `grpc-js` server instrumentation to subscriber type ([#3805](https://github.com/newrelic/node-newrelic/pull/3805)) ([ca3010a](https://github.com/newrelic/node-newrelic/commit/ca3010aca73cf69786794824063b4f2d5ce38d41))
|
|
45
|
+
* Updated `@langchain/core` subscribers to properly instrument the tool class methods ([#3850](https://github.com/newrelic/node-newrelic/pull/3850)) ([2d17eed](https://github.com/newrelic/node-newrelic/commit/2d17eeda540ef99f5ce829499ca1f4b0ef65e1a6))
|
|
46
|
+
|
|
47
|
+
#### Documentation
|
|
48
|
+
|
|
49
|
+
* Updated compatibility report ([#3831](https://github.com/newrelic/node-newrelic/pull/3831)) ([9156a6a](https://github.com/newrelic/node-newrelic/commit/9156a6a239dd57c46524d5d1a43a654dc7a89cb5))
|
|
50
|
+
|
|
51
|
+
#### Miscellaneous chores
|
|
52
|
+
|
|
53
|
+
* Added subscriber packages to `load-externals` ([#3868](https://github.com/newrelic/node-newrelic/pull/3868)) ([83adcc4](https://github.com/newrelic/node-newrelic/commit/83adcc43b061e55b2d9d3df6fafa152b2ed201df))
|
|
54
|
+
|
|
55
|
+
#### Tests
|
|
56
|
+
|
|
57
|
+
* Removed unused context manager feature flag for running versioned tests ([#3851](https://github.com/newrelic/node-newrelic/pull/3851)) ([15c9757](https://github.com/newrelic/node-newrelic/commit/15c9757339e0d811c96ff58fc275386b9fc2a7a4))
|
|
58
|
+
* Updated core tracing cross agent tests ([#3860](https://github.com/newrelic/node-newrelic/pull/3860)) ([08e4570](https://github.com/newrelic/node-newrelic/commit/08e45703852ea556c8518acd0560c57f56ea9c8c))
|
|
59
|
+
* Fixed issue with span links test ([#3863](https://github.com/newrelic/node-newrelic/pull/3863)) ([23a8594](https://github.com/newrelic/node-newrelic/commit/23a8594f7b0078b62c73f73e7afa0411e96ade69))
|
|
60
|
+
* Removed segment duration timing threshold in `memcached` tests ([#3869](https://github.com/newrelic/node-newrelic/pull/3869)) ([bd24410](https://github.com/newrelic/node-newrelic/commit/bd24410f135868a4e86f4c5375baf67cee2ccbc7))
|
|
61
|
+
|
|
62
|
+
### v13.17.0 (2026-03-19)
|
|
63
|
+
|
|
64
|
+
#### Features
|
|
65
|
+
|
|
66
|
+
* Added support for Continuous Profiling ([#3834](https://github.com/newrelic/node-newrelic/pull/3834)) ([6d8d5b5](https://github.com/newrelic/node-newrelic/commit/6d8d5b5df2f459ffca39cc14ef0cdabcf7f22cea))
|
|
67
|
+
* Added server-side configuration for `profiling.enabled` ([#3790](https://github.com/newrelic/node-newrelic/pull/3790)) ([0d44e5b](https://github.com/newrelic/node-newrelic/commit/0d44e5b3b24b60d8b920f7d6a762f208fa4139ca)) ([#3847](https://github.com/newrelic/node-newrelic/pull/3847)) ([e57223c](https://github.com/newrelic/node-newrelic/commit/e57223c7c66ab7fe1f464725efe0474e23326159))
|
|
68
|
+
* Added delay + duration to `ProfilingAggregator` ([#3815](https://github.com/newrelic/node-newrelic/pull/3815)) ([8000665](https://github.com/newrelic/node-newrelic/commit/8000665b1714275f8e019a2f7c911d62ee8dd127))
|
|
69
|
+
* Added supportability metrics for profiling ([#3801](https://github.com/newrelic/node-newrelic/pull/3801)) ([19bbb7e](https://github.com/newrelic/node-newrelic/commit/19bbb7ef426e835a13ec38fc543637bdae57a5fc))
|
|
70
|
+
* Prevented ProfilingAggregator from running in serverless mode ([#3806](https://github.com/newrelic/node-newrelic/pull/3806)) ([e4db0f4](https://github.com/newrelic/node-newrelic/commit/e4db0f469fde9ae6aa4984cb312ee1de269e5c7b))
|
|
71
|
+
* Disabled `profiling.enabled` when high security mode is enabled ([#3803](https://github.com/newrelic/node-newrelic/pull/3803)) ([9d4eebb](https://github.com/newrelic/node-newrelic/commit/9d4eebb11df00fc5729ad178063712734449741a))
|
|
72
|
+
* Added Heap profiler ([#3751](https://github.com/newrelic/node-newrelic/pull/3751)) ([8262f6b](https://github.com/newrelic/node-newrelic/commit/8262f6bb5d7bf0a1c996455d6829883a7ff3b696))
|
|
73
|
+
* Added Cpu Profiler ([#3747](https://github.com/newrelic/node-newrelic/pull/3747)) ([2c2097f](https://github.com/newrelic/node-newrelic/commit/2c2097fdfd4ec924bf24901eecb8ad62a9e4c4f5))
|
|
74
|
+
|
|
75
|
+
**Note**: Continuous Profiling UI is coming soon! While the Node.js agent now supports Continuous Profiling data collection, the visualization experience will debut in Limited Preview starting next week. If you would like to get early access to the profiling dashboards and UI features, please reach out to your Account Executive (AE) about how to opt-in to the preview.
|
|
76
|
+
|
|
77
|
+
#### Code refactoring
|
|
78
|
+
|
|
79
|
+
* Refactor `winston` instrumentation to subscribe to events emitted ([#3808](https://github.com/newrelic/node-newrelic/pull/3808)) ([4af2f48](https://github.com/newrelic/node-newrelic/commit/4af2f48d99b0842085044deb36d14af9e96ac8ed))
|
|
80
|
+
|
|
81
|
+
#### Documentation
|
|
82
|
+
|
|
83
|
+
* Updated compatibility report ([#3824](https://github.com/newrelic/node-newrelic/pull/3824)) ([0cfb356](https://github.com/newrelic/node-newrelic/commit/0cfb356c487fbe47c4ac11095704846d948168fb))
|
|
84
|
+
|
|
85
|
+
#### Tests
|
|
86
|
+
|
|
87
|
+
* Added segment duration tests for `ioredis`/`iovalkey` ([#3825](https://github.com/newrelic/node-newrelic/pull/3825)) ([9738bc8](https://github.com/newrelic/node-newrelic/commit/9738bc88b59c219d896d80e0f8ccb93866cd7f0b))
|
|
88
|
+
* Added segment duration timing tests for `mysql2` ([#3820](https://github.com/newrelic/node-newrelic/pull/3820)) ([bb424ff](https://github.com/newrelic/node-newrelic/commit/bb424ffa59fe55912f1ad711d84b57518dbd778f))
|
|
89
|
+
* Changed structure of bedrock tests to avoid getting instrumented core libraries from first test ([#3838](https://github.com/newrelic/node-newrelic/pull/3838)) ([886a36c](https://github.com/newrelic/node-newrelic/commit/886a36c1607e1a7c0ddc0688f7b8ee62f9a8bf10))
|
|
90
|
+
* Changed structure of lambda and sns tests to avoid getting instrumented core libraries from first test ([#3836](https://github.com/newrelic/node-newrelic/pull/3836)) ([414044d](https://github.com/newrelic/node-newrelic/commit/414044d184be885843a3267097c87954daf408bd))
|
|
91
|
+
* Updated `@aws-sdk/lib-dynamodb` version range ([#3829](https://github.com/newrelic/node-newrelic/pull/3829)) ([d28c938](https://github.com/newrelic/node-newrelic/commit/d28c938fbe823155fedeb5e5f85bd6a98e04ceed))
|
|
92
|
+
|
|
32
93
|
### v13.16.0 (2026-03-11)
|
|
33
94
|
|
|
34
95
|
#### Bug fixes
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
+
|
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Data used across {@link AsyncLocalStorage} invocations.
|
|
10
|
+
*
|
|
11
|
+
* @typedef {object} AsyncContext
|
|
12
|
+
* @property {Transaction} transaction The current transaction or `null`.
|
|
13
|
+
* @property {TraceSegment} segment The current segment or `null`.
|
|
14
|
+
* @property {object} extras Miscellaneous data used during the handling of
|
|
15
|
+
* this context.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Implementation of an {@link AsyncContext}.
|
|
20
|
+
*/
|
|
8
21
|
module.exports = class Context {
|
|
9
22
|
constructor({ transaction, segment, extras = {} } = {}) {
|
|
10
23
|
this._transaction = transaction
|
|
@@ -35,7 +48,7 @@ module.exports = class Context {
|
|
|
35
48
|
* @param {object} params to function
|
|
36
49
|
* @param {TraceSegment} params.segment segment to bind to context
|
|
37
50
|
* @param {Transaction} params.transaction active transaction
|
|
38
|
-
* @returns {
|
|
51
|
+
* @returns {AsyncContext} a newly constructed context
|
|
39
52
|
*/
|
|
40
53
|
enterSegment({ segment, transaction = this.transaction }) {
|
|
41
54
|
return new this.constructor({ transaction, segment, extras: this.extras })
|
package/lib/feature_flags.js
CHANGED
|
@@ -10,7 +10,6 @@ exports.prerelease = {
|
|
|
10
10
|
// internal_test_only is used for testing our feature flag implementation.
|
|
11
11
|
// It is not used to gate any features.
|
|
12
12
|
internal_test_only: false,
|
|
13
|
-
promise_segments: false,
|
|
14
13
|
reverse_naming_rules: false,
|
|
15
14
|
unresolved_promise_cleanup: true,
|
|
16
15
|
kafkajs_instrumentation: false,
|
|
@@ -33,6 +32,7 @@ exports.released = [
|
|
|
33
32
|
'native_metrics',
|
|
34
33
|
'new_promise_tracking',
|
|
35
34
|
'opentelemetry',
|
|
35
|
+
'promise_segments',
|
|
36
36
|
'protocol_17',
|
|
37
37
|
'released',
|
|
38
38
|
'send_request_uri_attribute',
|
|
@@ -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
|
|
package/lib/instrumentations.js
CHANGED
|
@@ -11,21 +11,16 @@ const InstrumentationDescriptor = require('./instrumentation-descriptor')
|
|
|
11
11
|
module.exports = function instrumentations() {
|
|
12
12
|
return {
|
|
13
13
|
'@azure/functions': { type: InstrumentationDescriptor.TYPE_GENERIC },
|
|
14
|
-
'@grpc/grpc-js': { module: './instrumentation/grpc-js' },
|
|
15
14
|
'@hapi/hapi': { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK },
|
|
16
15
|
'@hapi/vision': { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK },
|
|
17
16
|
'@prisma/client': { type: InstrumentationDescriptor.TYPE_DATASTORE },
|
|
18
17
|
'aws-sdk': { module: './instrumentation/aws-sdk' },
|
|
19
|
-
bluebird: { type: InstrumentationDescriptor.TYPE_PROMISE },
|
|
20
18
|
connect: { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK },
|
|
21
19
|
fastify: { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK },
|
|
22
20
|
kafkajs: { type: InstrumentationDescriptor.TYPE_MESSAGE },
|
|
23
21
|
koa: { module: './instrumentation/koa' },
|
|
24
|
-
memcached: { type: InstrumentationDescriptor.TYPE_DATASTORE },
|
|
25
22
|
mongodb: { type: InstrumentationDescriptor.TYPE_DATASTORE },
|
|
26
23
|
next: { module: './instrumentation/nextjs' },
|
|
27
|
-
|
|
28
|
-
restify: { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK },
|
|
29
|
-
when: { module: './instrumentation/when' }
|
|
24
|
+
restify: { type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK }
|
|
30
25
|
}
|
|
31
26
|
}
|
|
@@ -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
|
+
}
|