newrelic 11.4.0 → 11.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 (50) hide show
  1. package/NEWS.md +80 -20
  2. package/README.md +3 -3
  3. package/THIRD_PARTY_NOTICES.md +115 -115
  4. package/api.js +108 -3
  5. package/lib/adaptive-sampler.js +1 -1
  6. package/lib/agent.js +2 -0
  7. package/lib/collector/remote-method.js +1 -1
  8. package/lib/config/default.js +14 -0
  9. package/lib/config/hsm.js +3 -0
  10. package/lib/instrumentation/@elastic/elasticsearch.js +2 -2
  11. package/lib/instrumentation/@nestjs/core.js +1 -1
  12. package/lib/instrumentation/@prisma/client.js +1 -1
  13. package/lib/instrumentation/cassandra-driver.js +1 -1
  14. package/lib/instrumentation/fastify.js +1 -1
  15. package/lib/instrumentation/grpc-js/grpc.js +1 -1
  16. package/lib/instrumentation/mongodb.js +1 -1
  17. package/lib/instrumentation/openai.js +329 -0
  18. package/lib/instrumentation/pino/pino.js +1 -1
  19. package/lib/instrumentations.js +1 -0
  20. package/lib/llm-events/openai/chat-completion-message.js +20 -0
  21. package/lib/llm-events/openai/chat-completion-summary.js +20 -0
  22. package/lib/llm-events/openai/embedding.js +15 -0
  23. package/lib/llm-events/openai/error-message.js +30 -0
  24. package/lib/llm-events/openai/event.js +56 -0
  25. package/lib/llm-events/openai/feedback-message.js +20 -0
  26. package/lib/llm-events/openai/index.js +20 -0
  27. package/lib/llm-events/tracked-ids.js +27 -0
  28. package/lib/logger.js +1 -1
  29. package/lib/metrics/names.js +6 -1
  30. package/lib/metrics/normalizer/rule.js +1 -1
  31. package/lib/metrics/normalizer.js +2 -2
  32. package/lib/shim/conglomerate-shim.js +3 -2
  33. package/lib/shim/datastore-shim.js +3 -2
  34. package/lib/shim/index.js +11 -8
  35. package/lib/shim/message-shim.js +3 -2
  36. package/lib/shim/promise-shim.js +4 -3
  37. package/lib/shim/shim.js +24 -22
  38. package/lib/shim/transaction-shim.js +7 -5
  39. package/lib/shim/webframework-shim.js +9 -5
  40. package/lib/shimmer.js +19 -13
  41. package/lib/spans/streaming-span-event-aggregator.js +1 -1
  42. package/lib/symbols.js +2 -0
  43. package/lib/timer.js +3 -3
  44. package/lib/transaction/index.js +5 -0
  45. package/lib/util/flatten.js +1 -1
  46. package/lib/util/objects.js +1 -1
  47. package/lib/util/process-version.js +2 -2
  48. package/lib/util/properties.js +2 -2
  49. package/lib/util/urltils.js +4 -4
  50. package/package.json +3 -3
package/NEWS.md CHANGED
@@ -1,18 +1,78 @@
1
- ### v11.4.0 (2023-10-25)
2
-
3
- #### Features
4
-
5
- * Added support for parsing container ids from docker versions using cgroups v2. ([#1830](https://github.com/newrelic/node-newrelic/pull/1830)) ([9892901](https://github.com/newrelic/node-newrelic/commit/98929013da3e62e2223f94531b8d6f59eecfc35b))
6
-
7
- #### Miscellaneous chores
8
-
9
- * [Snyk] Upgraded @grpc/grpc-js from 1.9.2 to 1.9.4. ([#1823](https://github.com/newrelic/node-newrelic/pull/1823)) ([81f9450](https://github.com/newrelic/node-newrelic/commit/81f945033376e4d33651d1e42afc30aea19dbdeb))
10
- * **deps:** Updated aws-sdk, koa, superagent ([#1831](https://github.com/newrelic/node-newrelic/pull/1831)) ([8b4e963](https://github.com/newrelic/node-newrelic/commit/8b4e963e84d34e4727b9fda3aa630ef119aa3905))
11
-
12
- #### Tests
13
-
14
- * Increased timeout for integration tests to avoid random failures. ([#1827](https://github.com/newrelic/node-newrelic/pull/1827)) ([5202048](https://github.com/newrelic/node-newrelic/commit/52020485191868f479092ae4860019acf105b3eb))
15
-
1
+ ### v11.6.0 (2023-11-29)
2
+
3
+ #### Features
4
+
5
+ * Added instrumentation for `openai`.
6
+ * This feature is in limited preview and will be off by default.
7
+ * Aside from creating spans for chat completions and embeddings, it will create custom events that drive the [New Relic AI Monitoring](https://newrelic.com/platform/ai-monitoring).
8
+ * Added instrumentation for chat completion streams ([#1884](https://github.com/newrelic/node-newrelic/pull/1884)) ([404e317](https://github.com/newrelic/node-newrelic/commit/404e31737092fd7e6cd66b38d17507fb4375e079))
9
+ * Added instrumentation for openai chat completion creation ([#1862](https://github.com/newrelic/node-newrelic/pull/1862)) ([34dcd70](https://github.com/newrelic/node-newrelic/commit/34dcd7015b379982b90716a87763576cafe9cbd1))
10
+ * Added instrumentation for openai embedding creation ([#1872](https://github.com/newrelic/node-newrelic/pull/1872)) ([1c62321](https://github.com/newrelic/node-newrelic/commit/1c62321a4320a81a6a25aa064e3cdb42d6fbf851))
11
+ * Added `ai_monitoring.enabled` configuration.([#1873](https://github.com/newrelic/node-newrelic/pull/1873)) ([52bf9f3](https://github.com/newrelic/node-newrelic/commit/52bf9f362884f481a6dcc955be4fb1267458def8))
12
+ * Added `Nodejs/ML/OpenAI/<version>` metric every time a chat completion or embedding occurs.([#1886](https://github.com/newrelic/node-newrelic/pull/1886)) ([d11d100](https://github.com/newrelic/node-newrelic/commit/d11d100a37ad04201a9065363b1bc6b2d6fe36f2))
13
+ * Added `setLlmMetadata` API to allow users to specify metadata for LLM events ([#1863](https://github.com/newrelic/node-newrelic/pull/1863)) ([85979d7](https://github.com/newrelic/node-newrelic/commit/85979d752ee4b47db5e50c48953dcf62ea23a9fa))
14
+ * Ensure API errors are tracked ([#1880](https://github.com/newrelic/node-newrelic/pull/1880)) ([289c2a2](https://github.com/newrelic/node-newrelic/commit/289c2a295b157b18c5ccf7da2e68391e5fb3cba6))
15
+ * Added `getLlmMessageIds` and `recordLlmFeedbackEvent` API methods for tracking LLM feedback ([#1868](https://github.com/newrelic/node-newrelic/pull/1868)) ([1681e4b](https://github.com/newrelic/node-newrelic/commit/1681e4bbaa60264a0638790424d3e5370b1ee7bf))
16
+ * Added openai LLM events. ([#1857](https://github.com/newrelic/node-newrelic/pull/1857)) ([a7786f3](https://github.com/newrelic/node-newrelic/commit/a7786f3e033e33a7a1652cf55b7e3bece9b01378))
17
+ * Added pkgVersion to shim instances to facilitate semver checking without having to re-parse the package.json ([#1883](https://github.com/newrelic/node-newrelic/pull/1883)) ([4ddfd81](https://github.com/newrelic/node-newrelic/commit/4ddfd81a7c8c707d216c97a49a83ab96b20d59ba))
18
+
19
+ #### Bug fixes
20
+
21
+ * Updated isSimpleObject util to only check plain objects not arrays ([#1865](https://github.com/newrelic/node-newrelic/pull/1865)) ([8baa5bc](https://github.com/newrelic/node-newrelic/commit/8baa5bc7daa58d6db3c0c5d2687892fa189f54b5))
22
+
23
+ #### Security improvements
24
+
25
+ * Set log file permissions to read/write for Node process only ([#1854](https://github.com/newrelic/node-newrelic/pull/1854)) ([1b93ec9](https://github.com/newrelic/node-newrelic/commit/1b93ec942809505ae84aebba3b195b503a58f67d))
26
+
27
+ #### Code refactoring
28
+
29
+ * Improved custom event attributes checking when using api.recordCustomEvent ([#1870](https://github.com/newrelic/node-newrelic/pull/1870)) ([20e7f1d](https://github.com/newrelic/node-newrelic/commit/20e7f1ddf51c48f88339dcab496fe4fc49684bec))
30
+
31
+ #### Miscellaneous chores
32
+
33
+ * **dep:** Updated @newrelic/security-agent to v0.5.0 ([#1877](https://github.com/newrelic/node-newrelic/pull/1877)) ([2882236](https://github.com/newrelic/node-newrelic/commit/2882236b9f6d3a626bda0bbc0783ed829bdcdf9b))
34
+ * **dev-deps:** bump axios and @slack/bolt ([#1871](https://github.com/newrelic/node-newrelic/pull/1871)) ([2d00b02](https://github.com/newrelic/node-newrelic/commit/2d00b02c8f341a919c12ee62081cf77b4ccff30c))
35
+ * **docs:** Updated links in documentation to https ([#1888](https://github.com/newrelic/node-newrelic/pull/1888)) ([f1913ea](https://github.com/newrelic/node-newrelic/commit/f1913ea9aff12051167e11b2c3ca899a5e8324fc))
36
+ * Fixed bool -> boolean in jsdoc ([#1853](https://github.com/newrelic/node-newrelic/pull/1853)) ([3c00e55](https://github.com/newrelic/node-newrelic/commit/3c00e55291ef8a54e64339519700384c06cc5d71))
37
+
38
+ #### Tests
39
+
40
+ * Added streaming responses to mock OpenAI sever ([#1881](https://github.com/newrelic/node-newrelic/pull/1881)) ([86d83f2](https://github.com/newrelic/node-newrelic/commit/86d83f20028ec8a135241d4ad92032488ff5ad3a))
41
+ * Added unit tests for LLM API methods ([#1878](https://github.com/newrelic/node-newrelic/pull/1878)) ([3d8b987](https://github.com/newrelic/node-newrelic/commit/3d8b987408512e0643b4daed078a6fd7ebe363ca))
42
+ * Added a mock server for openai testing ([#1858](https://github.com/newrelic/node-newrelic/pull/1858)) ([3b1f5e6](https://github.com/newrelic/node-newrelic/commit/3b1f5e69950385a9f8482d33ebb783c8cf054e57))
43
+ * Fixed shadowed variable lint error in pino versioned tests ([#1859](https://github.com/newrelic/node-newrelic/pull/1859)) ([e1b21eb](https://github.com/newrelic/node-newrelic/commit/e1b21eb8ed87297b5e55ee2c86e33bc2594d8d8b))
44
+ * Updated openai versioned tests to properly work with the legacy context manager ([#1876](https://github.com/newrelic/node-newrelic/pull/1876)) ([a879700](https://github.com/newrelic/node-newrelic/commit/a87970019dab2fa2a393f2f10e8da2cf03338c87))
45
+
46
+ #### Continuous integration
47
+
48
+ * Made release note date always in pacific time ([#1855](https://github.com/newrelic/node-newrelic/pull/1855)) ([6d7dc69](https://github.com/newrelic/node-newrelic/commit/6d7dc69ccb71b2778da28598c50b65842ac4e3f7))
49
+ * Remove updating staging with newly release agent version ([#1887](https://github.com/newrelic/node-newrelic/pull/1887)) ([9d38faa](https://github.com/newrelic/node-newrelic/commit/9d38faa3de07d0dc194fddc7317908adfc51b627))
50
+
51
+ ### v11.5.0 (2023-10-30)
52
+
53
+ #### Miscellaneous chores
54
+
55
+ * **dep:** Updated @newrelic/security-agent to v0.4.0 ([#1837](https://github.com/newrelic/node-newrelic/pull/1837)) ([fb06ac9](https://github.com/newrelic/node-newrelic/commit/fb06ac930269b784fcea6c2b8ea5e54158677ec4))
56
+
57
+ #### Continuous integration
58
+
59
+ * Disable fail-fast on nightly versioned test runs ([#1836](https://github.com/newrelic/node-newrelic/pull/1836)) ([fe1b4fc](https://github.com/newrelic/node-newrelic/commit/fe1b4fc4c00b2e4ea4c7b6fa5a8c1cd6e864145a))
60
+
61
+ ### v11.4.0 (2023-10-25)
62
+
63
+ #### Features
64
+
65
+ * Added support for parsing container ids from docker versions using cgroups v2. ([#1830](https://github.com/newrelic/node-newrelic/pull/1830)) ([9892901](https://github.com/newrelic/node-newrelic/commit/98929013da3e62e2223f94531b8d6f59eecfc35b))
66
+
67
+ #### Miscellaneous chores
68
+
69
+ * [Snyk] Upgraded @grpc/grpc-js from 1.9.2 to 1.9.4. ([#1823](https://github.com/newrelic/node-newrelic/pull/1823)) ([81f9450](https://github.com/newrelic/node-newrelic/commit/81f945033376e4d33651d1e42afc30aea19dbdeb))
70
+ * **deps:** Updated aws-sdk, koa, superagent ([#1831](https://github.com/newrelic/node-newrelic/pull/1831)) ([8b4e963](https://github.com/newrelic/node-newrelic/commit/8b4e963e84d34e4727b9fda3aa630ef119aa3905))
71
+
72
+ #### Tests
73
+
74
+ * Increased timeout for integration tests to avoid random failures. ([#1827](https://github.com/newrelic/node-newrelic/pull/1827)) ([5202048](https://github.com/newrelic/node-newrelic/commit/52020485191868f479092ae4860019acf105b3eb))
75
+
16
76
  ### v11.3.0 (2023-10-23)
17
77
 
18
78
  #### Features
@@ -3663,7 +3723,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
3663
3723
  used for instrumenting web frameworks like `restify` or `express`.
3664
3724
 
3665
3725
  Documentation and tutorials for the new API can be found on our GitHub
3666
- documentation page: http://newrelic.github.io/node-newrelic/
3726
+ documentation page: https://newrelic.github.io/node-newrelic/
3667
3727
 
3668
3728
  * Rewrote built-in instrumentation using the new `Shim` classes.
3669
3729
 
@@ -3752,7 +3812,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
3752
3812
  meaning every instrumentation will create Middleware metrics for your server.
3753
3813
 
3754
3814
  Tutorials on using the new instrumentation shim can be found on our API docs:
3755
- http://newrelic.github.io/node-newrelic/.
3815
+ https://newrelic.github.io/node-newrelic/.
3756
3816
 
3757
3817
  * Removed `express_segments` feature flag.
3758
3818
 
@@ -4579,7 +4639,7 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
4579
4639
 
4580
4640
  * Advanced Analytics for APM Errors
4581
4641
 
4582
- With this release, the agent reports [TransactionError events](https://docs.newrelic.com/docs/insights/new-relic-insights/decorating-events/error-event-default-attributes-insights). These new events power the beta feature [Advanced Analytics for APM Errors](https://docs.newrelic.com/docs/apm/applications-menu/events/view-apm-errors-error-traces) (apply [here](https://discuss.newrelic.com/t/join-the-apm-errors-beta-of-real-time-analytics/31123) to participate). The error events are also available today through [New Relic Insights](http://newrelic.com/insights).
4642
+ With this release, the agent reports [TransactionError events](https://docs.newrelic.com/docs/insights/new-relic-insights/decorating-events/error-event-default-attributes-insights). These new events power the beta feature [Advanced Analytics for APM Errors](https://docs.newrelic.com/docs/apm/applications-menu/events/view-apm-errors-error-traces) (apply [here](https://discuss.newrelic.com/t/join-the-apm-errors-beta-of-real-time-analytics/31123) to participate). The error events are also available today through [New Relic Insights](https://newrelic.com/insights).
4583
4643
 
4584
4644
  Advanced Analytics for APM Errors lets you see all of your errors with
4585
4645
  granular detail, filter and group by any attribute to analyze them, and take
@@ -5369,9 +5429,9 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
5369
5429
  10,000 per minute. After that events are statistically sampled. Event data
5370
5430
  includes transaction timing, transaction name, and any custom parameters. You
5371
5431
  can read what is sent in more detail
5372
- [here](http://docs.newrelic.com/docs/insights/basic-attributes#transaction-defaults).
5432
+ [here](https://docs.newrelic.com/docs/insights/basic-attributes#transaction-defaults).
5373
5433
 
5374
- You can read more about Insights [here](http://newrelic.com/insights).
5434
+ You can read more about Insights [here](https://newrelic.com/insights).
5375
5435
  Documentation for configuring this feature can be found
5376
5436
  [here](https://docs.newrelic.com/docs/nodejs/customizing-your-nodejs-config-file#tx_events).
5377
5437
 
package/README.md CHANGED
@@ -158,7 +158,7 @@ These are the steps to work on core agent features, with more detail below:
158
158
  $ git clone git@github.com:your-user-name/node-newrelic.git
159
159
  $ cd node-newrelic
160
160
 
161
- 2. Install the project's dependences:
161
+ 2. Install the project's dependencies:
162
162
 
163
163
  $ npm install
164
164
 
@@ -184,7 +184,7 @@ Here are some resources for learning more about the agent:
184
184
 
185
185
  - [New Relic's official Node.js agent documentation](https://docs.newrelic.com/docs/agents/nodejs-agent)
186
186
 
187
- - [Developer docs](http://newrelic.github.io/node-newrelic/)
187
+ - [Developer docs](https://newrelic.github.io/node-newrelic/)
188
188
 
189
189
  - [Configuring the agent using `newrelic.js` or environment variables](https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration)
190
190
 
@@ -242,7 +242,7 @@ To [all contributors](https://github.com/newrelic/node-newrelic/graphs/contribut
242
242
 
243
243
  ## License
244
244
 
245
- The Node.js agent is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
245
+ The Node.js agent is licensed under the [Apache 2.0](https://apache.org/licenses/LICENSE-2.0.txt) License.
246
246
 
247
247
  The Node.js agent also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in [the third-party notices document](https://github.com/newrelic/node-newrelic/blob/main/THIRD_PARTY_NOTICES.md).
248
248
 
@@ -927,7 +927,7 @@ Apache License
927
927
 
928
928
  ### @newrelic/security-agent
929
929
 
930
- This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v0.3.0](https://github.com/newrelic/csec-node-agent/tree/v0.3.0)), distributed under the [New Relic Pre-Release License](https://github.com/newrelic/csec-node-agent/blob/v0.3.0/LICENSE):
930
+ This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v0.5.0](https://github.com/newrelic/csec-node-agent/tree/v0.5.0)), distributed under the [New Relic Pre-Release License](https://github.com/newrelic/csec-node-agent/blob/v0.5.0/LICENSE):
931
931
 
932
932
  ```
933
933
  ## New Relic Pre-Release Software Notice
@@ -2161,7 +2161,7 @@ THE SOFTWARE.
2161
2161
 
2162
2162
  ### @slack/bolt
2163
2163
 
2164
- This product includes source derived from [@slack/bolt](https://github.com/slackapi/bolt) ([v3.13.3](https://github.com/slackapi/bolt/tree/v3.13.3)), distributed under the [MIT License](https://github.com/slackapi/bolt/blob/v3.13.3/LICENSE):
2164
+ This product includes source derived from [@slack/bolt](https://github.com/slackapi/bolt) ([v3.15.0](https://github.com/slackapi/bolt/tree/v3.15.0)), distributed under the [MIT License](https://github.com/slackapi/bolt/blob/v3.15.0/LICENSE):
2165
2165
 
2166
2166
  ```
2167
2167
  The MIT License (MIT)
@@ -2302,27 +2302,27 @@ SOFTWARE.
2302
2302
  This product includes source derived from [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) ([v4.2.10](https://github.com/ankitskvmdam/clean-jsdoc-theme/tree/v4.2.10)), distributed under the [MIT License](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/v4.2.10/LICENSE):
2303
2303
 
2304
2304
  ```
2305
- MIT License
2306
-
2307
- Copyright (c) 2019-2022 Ankit Kumar (अंकित कुमार)
2308
-
2309
- Permission is hereby granted, free of charge, to any person obtaining a copy
2310
- of this software and associated documentation files (the "Software"), to deal
2311
- in the Software without restriction, including without limitation the rights
2312
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2313
- copies of the Software, and to permit persons to whom the Software is
2314
- furnished to do so, subject to the following conditions:
2315
-
2316
- The above copyright notice and this permission notice shall be included in all
2317
- copies or substantial portions of the Software.
2318
-
2319
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2320
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2321
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2322
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2323
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2324
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2325
- SOFTWARE.
2305
+ MIT License
2306
+
2307
+ Copyright (c) 2019-2022 Ankit Kumar (अंकित कुमार)
2308
+
2309
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2310
+ of this software and associated documentation files (the "Software"), to deal
2311
+ in the Software without restriction, including without limitation the rights
2312
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2313
+ copies of the Software, and to permit persons to whom the Software is
2314
+ furnished to do so, subject to the following conditions:
2315
+
2316
+ The above copyright notice and this permission notice shall be included in all
2317
+ copies or substantial portions of the Software.
2318
+
2319
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2320
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2321
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2322
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2323
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2324
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2325
+ SOFTWARE.
2326
2326
 
2327
2327
  ```
2328
2328
 
@@ -4375,13 +4375,13 @@ License: MIT
4375
4375
  By: DY
4376
4376
  Repository: <git@github.com:dfcreative/color-name.git>
4377
4377
 
4378
- > The MIT License (MIT)
4379
- > Copyright (c) 2015 Dmitry Ivanov
4380
- >
4381
- > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4382
- >
4383
- > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
4384
- >
4378
+ > The MIT License (MIT)
4379
+ > Copyright (c) 2015 Dmitry Ivanov
4380
+ >
4381
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4382
+ >
4383
+ > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
4384
+ >
4385
4385
  > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4386
4386
 
4387
4387
  ----------------------------------------
@@ -8615,17 +8615,17 @@ License: 0BSD
8615
8615
  By: Microsoft Corp.
8616
8616
  Repository: <https://github.com/Microsoft/tslib.git>
8617
8617
 
8618
- > Copyright (c) Microsoft Corporation.
8619
- >
8620
- > Permission to use, copy, modify, and/or distribute this software for any
8621
- > purpose with or without fee is hereby granted.
8622
- >
8623
- > THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8624
- > REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
8625
- > AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
8626
- > INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
8627
- > LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
8628
- > OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
8618
+ > Copyright (c) Microsoft Corporation.
8619
+ >
8620
+ > Permission to use, copy, modify, and/or distribute this software for any
8621
+ > purpose with or without fee is hereby granted.
8622
+ >
8623
+ > THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8624
+ > REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
8625
+ > AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
8626
+ > INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
8627
+ > LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
8628
+ > OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
8629
8629
  > PERFORMANCE OF THIS SOFTWARE.
8630
8630
 
8631
8631
  ----------------------------------------
@@ -8636,26 +8636,26 @@ License: MIT
8636
8636
  By: Klaus Meinhardt
8637
8637
  Repository: <https://github.com/ajafff/tsutils>
8638
8638
 
8639
- > The MIT License (MIT)
8640
- >
8641
- > Copyright (c) 2017 Klaus Meinhardt
8642
- >
8643
- > Permission is hereby granted, free of charge, to any person obtaining a copy
8644
- > of this software and associated documentation files (the "Software"), to deal
8645
- > in the Software without restriction, including without limitation the rights
8646
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8647
- > copies of the Software, and to permit persons to whom the Software is
8648
- > furnished to do so, subject to the following conditions:
8649
- >
8650
- > The above copyright notice and this permission notice shall be included in all
8651
- > copies or substantial portions of the Software.
8652
- >
8653
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8654
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8655
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8656
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8657
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8658
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
8639
+ > The MIT License (MIT)
8640
+ >
8641
+ > Copyright (c) 2017 Klaus Meinhardt
8642
+ >
8643
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
8644
+ > of this software and associated documentation files (the "Software"), to deal
8645
+ > in the Software without restriction, including without limitation the rights
8646
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8647
+ > copies of the Software, and to permit persons to whom the Software is
8648
+ > furnished to do so, subject to the following conditions:
8649
+ >
8650
+ > The above copyright notice and this permission notice shall be included in all
8651
+ > copies or substantial portions of the Software.
8652
+ >
8653
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8654
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8655
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8656
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8657
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8658
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
8659
8659
  > SOFTWARE.
8660
8660
 
8661
8661
  ----------------------------------------
@@ -8666,60 +8666,60 @@ License: Apache-2.0
8666
8666
  By: Microsoft Corp.
8667
8667
  Repository: <https://github.com/Microsoft/TypeScript.git>
8668
8668
 
8669
- > Apache License
8670
- >
8671
- > Version 2.0, January 2004
8672
- >
8673
- > http://www.apache.org/licenses/
8674
- >
8675
- > TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8676
- >
8677
- > 1. Definitions.
8678
- >
8679
- > "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
8680
- >
8681
- > "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
8682
- >
8683
- > "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
8684
- >
8685
- > "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
8686
- >
8687
- > "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
8688
- >
8689
- > "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
8690
- >
8691
- > "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
8692
- >
8693
- > "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
8694
- >
8695
- > "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
8696
- >
8697
- > "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
8698
- >
8699
- > 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
8700
- >
8701
- > 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
8702
- >
8703
- > 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
8704
- >
8705
- > You must give any other recipients of the Work or Derivative Works a copy of this License; and
8706
- >
8707
- > You must cause any modified files to carry prominent notices stating that You changed the files; and
8708
- >
8709
- > You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
8710
- >
8711
- > If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
8712
- >
8713
- > 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
8714
- >
8715
- > 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
8716
- >
8717
- > 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8718
- >
8719
- > 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
8720
- >
8721
- > 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
8722
- >
8669
+ > Apache License
8670
+ >
8671
+ > Version 2.0, January 2004
8672
+ >
8673
+ > http://www.apache.org/licenses/
8674
+ >
8675
+ > TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8676
+ >
8677
+ > 1. Definitions.
8678
+ >
8679
+ > "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
8680
+ >
8681
+ > "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
8682
+ >
8683
+ > "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
8684
+ >
8685
+ > "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
8686
+ >
8687
+ > "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
8688
+ >
8689
+ > "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
8690
+ >
8691
+ > "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
8692
+ >
8693
+ > "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
8694
+ >
8695
+ > "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
8696
+ >
8697
+ > "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
8698
+ >
8699
+ > 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
8700
+ >
8701
+ > 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
8702
+ >
8703
+ > 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
8704
+ >
8705
+ > You must give any other recipients of the Work or Derivative Works a copy of this License; and
8706
+ >
8707
+ > You must cause any modified files to carry prominent notices stating that You changed the files; and
8708
+ >
8709
+ > You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
8710
+ >
8711
+ > If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
8712
+ >
8713
+ > 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
8714
+ >
8715
+ > 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
8716
+ >
8717
+ > 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8718
+ >
8719
+ > 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
8720
+ >
8721
+ > 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
8722
+ >
8723
8723
  > END OF TERMS AND CONDITIONS
8724
8724
 
8725
8725
  ----------------------------------------
package/api.js CHANGED
@@ -23,6 +23,7 @@ const {
23
23
  assignCLMSymbol,
24
24
  addCLMAttributes: maybeAddCLMAttributes
25
25
  } = require('./lib/util/code-level-metrics')
26
+ const { LlmFeedbackMessage } = require('./lib/llm-events/openai')
26
27
 
27
28
  const ATTR_DEST = require('./lib/config/attribute-filter').DESTINATIONS
28
29
  const MODULE_TYPE = require('./lib/shim/constants').MODULE_TYPE
@@ -30,6 +31,7 @@ const NAMES = require('./lib/metrics/names')
30
31
  const obfuscate = require('./lib/util/sql/obfuscate')
31
32
  const { DESTINATIONS } = require('./lib/config/attribute-filter')
32
33
  const parse = require('module-details-from-path')
34
+ const { isSimpleObject } = require('./lib/util/objects')
33
35
 
34
36
  /*
35
37
  *
@@ -59,7 +61,7 @@ const CUSTOM_EVENT_TYPE_REGEX = /^[a-zA-Z0-9:_ ]+$/
59
61
 
60
62
  /**
61
63
  * The exported New Relic API. This contains all of the functions meant to be
62
- * used by New Relic customers. For now, that means transaction naming.
64
+ * used by New Relic customers.
63
65
  *
64
66
  * You do not need to directly instantiate this class, as an instance of this is
65
67
  * the return from `require('newrelic')`.
@@ -1272,9 +1274,9 @@ API.prototype.recordCustomEvent = function recordCustomEvent(eventType, attribut
1272
1274
  fail = true
1273
1275
  }
1274
1276
  // If they don't pass an attributes object, or the attributes argument is not
1275
- // an object, or if it is an object and but is actually an array, log a
1277
+ // an object, or if it is an object but is actually an array, log a
1276
1278
  // warning and set the fail bit.
1277
- if (!attributes || typeof attributes !== 'object' || Array.isArray(attributes)) {
1279
+ if (isSimpleObject(attributes) === false) {
1278
1280
  logger.warn(
1279
1281
  'recordCustomEvent requires an object for its second argument, got %s (%s)',
1280
1282
  stringify(attributes),
@@ -1536,6 +1538,85 @@ API.prototype.getTraceMetadata = function getTraceMetadata() {
1536
1538
  return metadata
1537
1539
  }
1538
1540
 
1541
+ /**
1542
+ * Get a set of tracked identifiers
1543
+ *
1544
+ * @param {object} params Input parameters.
1545
+ * @param {string} params.responseId The LLM generated identifier for the
1546
+ * response.
1547
+ * @returns {LlmTrackedIds|undefined} The tracked identifiers.
1548
+ */
1549
+ API.prototype.getLlmMessageIds = function getLlmMessageIds({ responseId } = {}) {
1550
+ this.agent.metrics
1551
+ .getOrCreateMetric(`${NAMES.SUPPORTABILITY.API}/getLlmMessageIds`)
1552
+ .incrementCallCount()
1553
+
1554
+ if (this.agent.config?.ai_monitoring?.enabled !== true) {
1555
+ logger.warn('getLlmMessageIds invoked but ai_monitoring is disabled.')
1556
+ return
1557
+ }
1558
+
1559
+ const tx = this.agent.tracer.getTransaction()
1560
+ if (!tx) {
1561
+ logger.warn('getLlmMessageIds must be called within the scope of a transaction.')
1562
+ return
1563
+ }
1564
+ return tx.llm.responses.get(responseId)
1565
+ }
1566
+
1567
+ /**
1568
+ * Record a LLM feedback event which can be viewed in New Relic API Monitoring.
1569
+ *
1570
+ * @param {object} params Input parameters.
1571
+ * @param {string} [params.conversationId=""] If available, the unique
1572
+ * identifier for the LLM conversation that triggered the event.
1573
+ * @param {string} [params.requestId=""] If available, the request identifier
1574
+ * from the remote service.
1575
+ * @param {string} params.messageId Identifier for the message being rated.
1576
+ * Obtained from {@link getLlmMessageIds}.
1577
+ * @param {string} params.category A tag for the event.
1578
+ * @param {string} params.rating A indicator of how useful the message was.
1579
+ * @param {string} [params.message=""] The message that triggered the event.
1580
+ * @param {object} [params.metadata={}] Additional key-value pairs to associate
1581
+ * with the recorded event.
1582
+ */
1583
+ API.prototype.recordLlmFeedbackEvent = function recordLlmFeedbackEvent({
1584
+ conversationId = '',
1585
+ requestId = '',
1586
+ messageId,
1587
+ category,
1588
+ rating,
1589
+ message = '',
1590
+ metadata = {}
1591
+ } = {}) {
1592
+ this.agent.metrics
1593
+ .getOrCreateMetric(`${NAMES.SUPPORTABILITY.API}/recordLlmFeedbackEvent`)
1594
+ .incrementCallCount()
1595
+
1596
+ if (this.agent.config?.ai_monitoring?.enabled !== true) {
1597
+ logger.warn('recordLlmFeedbackEvent invoked but ai_monitoring is disabled.')
1598
+ return
1599
+ }
1600
+
1601
+ const tx = this.agent.tracer.getTransaction()
1602
+ if (!tx) {
1603
+ logger.warn(
1604
+ 'No message feedback events will be recorded. recordLlmFeedbackEvent must be called within the scope of a transaction.'
1605
+ )
1606
+ return
1607
+ }
1608
+
1609
+ const feedback = new LlmFeedbackMessage({
1610
+ conversationId,
1611
+ requestId,
1612
+ messageId,
1613
+ category,
1614
+ rating,
1615
+ message
1616
+ })
1617
+ this.recordCustomEvent('LlmFeedbackMessage', { ...metadata, ...feedback })
1618
+ }
1619
+
1539
1620
  /**
1540
1621
  * Shuts down the agent.
1541
1622
  *
@@ -1788,4 +1869,28 @@ API.prototype.setErrorGroupCallback = function setErrorGroupCallback(callback) {
1788
1869
  this.agent.errors.errorGroupCallback = callback
1789
1870
  }
1790
1871
 
1872
+ /**
1873
+ * Function for assigning metadata to all LLM events. This should only
1874
+ * be called once in your application and before executing any openai, bedrock,
1875
+ * langchain, generative AI methods.
1876
+ *
1877
+ * If passing in metadata via `api.recordLlmFeedbackEvent`, it will take precedence
1878
+ * over what is assigned via this method.
1879
+ *
1880
+ * @param {object} metadata key/value metadata to be assigned to all LLM Events on creation
1881
+ * @example
1882
+ * newrelic.setLlmMetadata({ type: 'openai', framework: 'express', region: 'us' })
1883
+ */
1884
+ API.prototype.setLlmMetadata = function setLlmMetadata(metadata) {
1885
+ const metric = this.agent.metrics.getOrCreateMetric(NAMES.SUPPORTABILITY.API + '/setLlmMetadata')
1886
+ metric.incrementCallCount()
1887
+
1888
+ if (!isSimpleObject(metadata)) {
1889
+ logger.warn('metadata must be an object, not assigning LLM metadata.')
1890
+ return
1891
+ }
1892
+
1893
+ this.agent.llm.metadata = metadata
1894
+ }
1895
+
1791
1896
  module.exports = API
@@ -79,7 +79,7 @@ class AdaptiveSampler {
79
79
  * the number of objects sampled in this window.
80
80
  *
81
81
  * @param {number} roll - The number to compare against the threshold
82
- * @returns {bool} True if the object should be sampled.
82
+ * @returns {boolean} True if the object should be sampled.
83
83
  */
84
84
  shouldSample(roll) {
85
85
  ++this._seen