newrelic 13.16.0 → 13.18.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 (61) hide show
  1. package/NEWS.md +62 -0
  2. package/THIRD_PARTY_NOTICES.md +235 -25
  3. package/lib/agent.js +16 -0
  4. package/lib/aggregators/base-aggregator.js +21 -0
  5. package/lib/aggregators/profiling-aggregator.js +17 -6
  6. package/lib/collector/remote-method.js +7 -2
  7. package/lib/config/default.js +0 -25
  8. package/lib/config/hsm.js +3 -0
  9. package/lib/config/index.js +9 -0
  10. package/lib/context-manager/context.js +14 -1
  11. package/lib/feature_flags.js +1 -1
  12. package/lib/harvester.js +5 -4
  13. package/lib/instrumentations.js +1 -7
  14. package/lib/metrics/names.js +8 -0
  15. package/lib/profiling/index.js +45 -16
  16. package/lib/profiling/metrics.js +76 -0
  17. package/lib/profiling/profilers/base.js +3 -7
  18. package/lib/profiling/profilers/cpu.js +47 -0
  19. package/lib/profiling/profilers/heap.js +38 -0
  20. package/lib/profiling/profilers/index.js +12 -0
  21. package/lib/spans/span-link.js +4 -2
  22. package/lib/subscriber-configs.js +8 -2
  23. package/lib/subscribers/README.md +10 -0
  24. package/lib/subscribers/application-logs.js +8 -0
  25. package/lib/subscribers/base.js +12 -8
  26. package/lib/subscribers/bluebird/config.js +21 -0
  27. package/lib/subscribers/bluebird/instrumentation.js +59 -0
  28. package/lib/subscribers/grpcjs/client.js +126 -0
  29. package/lib/subscribers/grpcjs/config.js +63 -0
  30. package/lib/subscribers/grpcjs/http2-stream.js +14 -0
  31. package/lib/subscribers/grpcjs/resolving-call.js +14 -0
  32. package/lib/subscribers/grpcjs/server.js +206 -0
  33. package/lib/subscribers/grpcjs/should-track-error.js +12 -0
  34. package/lib/subscribers/index.js +37 -0
  35. package/lib/subscribers/langchain/config.js +22 -2
  36. package/lib/subscribers/memcached/command.js +69 -0
  37. package/lib/subscribers/memcached/config.js +23 -0
  38. package/lib/subscribers/message-consumer.js +8 -6
  39. package/lib/subscribers/mysql2/config.js +9 -10
  40. package/lib/subscribers/q/config.js +32 -0
  41. package/lib/subscribers/q/next-tick.js +21 -0
  42. package/lib/subscribers/q/run-after.js +14 -0
  43. package/lib/subscribers/when/config.js +21 -0
  44. package/lib/subscribers/when/instrumentation.js +33 -0
  45. package/lib/subscribers/winston/config.js +40 -0
  46. package/lib/subscribers/winston/configure.js +51 -0
  47. package/lib/subscribers/winston/create-logger.js +42 -0
  48. package/lib/{instrumentation → subscribers/winston}/nr-winston-transport.js +2 -2
  49. package/lib/transaction/index.js +3 -1
  50. package/load-externals.js +13 -1
  51. package/package.json +2 -1
  52. package/lib/instrumentation/bluebird.js +0 -109
  53. package/lib/instrumentation/grpc-js/grpc.js +0 -271
  54. package/lib/instrumentation/grpc-js/nr-hooks.js +0 -32
  55. package/lib/instrumentation/memcached.js +0 -84
  56. package/lib/instrumentation/q.js +0 -29
  57. package/lib/instrumentation/when/constants.js +0 -66
  58. package/lib/instrumentation/when/contextualizer.js +0 -181
  59. package/lib/instrumentation/when/index.js +0 -363
  60. package/lib/instrumentation/when/nr-hooks.js +0 -16
  61. package/lib/instrumentation/winston.js +0 -195
package/NEWS.md CHANGED
@@ -1,3 +1,65 @@
1
+ ### v13.18.0 (2026-03-30)
2
+
3
+ #### Features
4
+
5
+ * 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))
6
+
7
+ #### Code refactoring
8
+
9
+ * 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))
10
+ * 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))
11
+ * 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))
12
+ * 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))
13
+ * 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))
14
+ * 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))
15
+ * 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))
16
+
17
+ #### Documentation
18
+
19
+ * Updated compatibility report ([#3831](https://github.com/newrelic/node-newrelic/pull/3831)) ([9156a6a](https://github.com/newrelic/node-newrelic/commit/9156a6a239dd57c46524d5d1a43a654dc7a89cb5))
20
+
21
+ #### Miscellaneous chores
22
+
23
+ * Added subscriber packages to `load-externals` ([#3868](https://github.com/newrelic/node-newrelic/pull/3868)) ([83adcc4](https://github.com/newrelic/node-newrelic/commit/83adcc43b061e55b2d9d3df6fafa152b2ed201df))
24
+
25
+ #### Tests
26
+
27
+ * 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))
28
+ * Updated core tracing cross agent tests ([#3860](https://github.com/newrelic/node-newrelic/pull/3860)) ([08e4570](https://github.com/newrelic/node-newrelic/commit/08e45703852ea556c8518acd0560c57f56ea9c8c))
29
+ * Fixed issue with span links test ([#3863](https://github.com/newrelic/node-newrelic/pull/3863)) ([23a8594](https://github.com/newrelic/node-newrelic/commit/23a8594f7b0078b62c73f73e7afa0411e96ade69))
30
+ * 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))
31
+
32
+ ### v13.17.0 (2026-03-19)
33
+
34
+ #### Features
35
+
36
+ * Added support for Continuous Profiling ([#3834](https://github.com/newrelic/node-newrelic/pull/3834)) ([6d8d5b5](https://github.com/newrelic/node-newrelic/commit/6d8d5b5df2f459ffca39cc14ef0cdabcf7f22cea))
37
+ * 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))
38
+ * Added delay + duration to `ProfilingAggregator` ([#3815](https://github.com/newrelic/node-newrelic/pull/3815)) ([8000665](https://github.com/newrelic/node-newrelic/commit/8000665b1714275f8e019a2f7c911d62ee8dd127))
39
+ * Added supportability metrics for profiling ([#3801](https://github.com/newrelic/node-newrelic/pull/3801)) ([19bbb7e](https://github.com/newrelic/node-newrelic/commit/19bbb7ef426e835a13ec38fc543637bdae57a5fc))
40
+ * 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))
41
+ * 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))
42
+ * Added Heap profiler ([#3751](https://github.com/newrelic/node-newrelic/pull/3751)) ([8262f6b](https://github.com/newrelic/node-newrelic/commit/8262f6bb5d7bf0a1c996455d6829883a7ff3b696))
43
+ * Added Cpu Profiler ([#3747](https://github.com/newrelic/node-newrelic/pull/3747)) ([2c2097f](https://github.com/newrelic/node-newrelic/commit/2c2097fdfd4ec924bf24901eecb8ad62a9e4c4f5))
44
+
45
+ **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.
46
+
47
+ #### Code refactoring
48
+
49
+ * 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))
50
+
51
+ #### Documentation
52
+
53
+ * Updated compatibility report ([#3824](https://github.com/newrelic/node-newrelic/pull/3824)) ([0cfb356](https://github.com/newrelic/node-newrelic/commit/0cfb356c487fbe47c4ac11095704846d948168fb))
54
+
55
+ #### Tests
56
+
57
+ * 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))
58
+ * 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))
59
+ * 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))
60
+ * 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))
61
+ * 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))
62
+
1
63
  ### v13.16.0 (2026-03-11)
2
64
 
3
65
  #### Bug fixes
@@ -81,6 +81,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
81
81
 
82
82
  **[optionalDependencies](#optionalDependencies)**
83
83
 
84
+ * [@datadog/pprof](#datadogpprof)
84
85
  * [@newrelic/fn-inspect](#newrelicfn-inspect)
85
86
  * [@newrelic/native-metrics](#newrelicnative-metrics)
86
87
  * [@prisma/prisma-fmt-wasm](#prismaprisma-fmt-wasm)
@@ -94,7 +95,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
94
95
 
95
96
  ### @apm-js-collab/tracing-hooks
96
97
 
97
- This product includes source derived from [@apm-js-collab/tracing-hooks](https://github.com/apm-js-collab/tracing-hooks) ([v0.4.0](https://github.com/apm-js-collab/tracing-hooks/tree/v0.4.0)), distributed under the [Apache-2.0 License](https://github.com/apm-js-collab/tracing-hooks/blob/v0.4.0/LICENSE):
98
+ This product includes source derived from [@apm-js-collab/tracing-hooks](https://github.com/apm-js-collab/tracing-hooks) ([v0.3.1](https://github.com/apm-js-collab/tracing-hooks/tree/v0.3.1)), distributed under the [Apache-2.0 License](https://github.com/apm-js-collab/tracing-hooks/blob/v0.3.1/LICENSE):
98
99
 
99
100
  ```
100
101
 
@@ -2960,7 +2961,7 @@ SOFTWARE.
2960
2961
 
2961
2962
  ### @aws-sdk/client-s3
2962
2963
 
2963
- This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.996.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.996.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.996.0/LICENSE):
2964
+ This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.1000.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.1000.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.1000.0/LICENSE):
2964
2965
 
2965
2966
  ```
2966
2967
  Apache License
@@ -3169,7 +3170,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co
3169
3170
 
3170
3171
  ### @aws-sdk/s3-request-presigner
3171
3172
 
3172
- This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.996.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.996.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.996.0/LICENSE):
3173
+ This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.1000.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.1000.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.1000.0/LICENSE):
3173
3174
 
3174
3175
  ```
3175
3176
  Apache License
@@ -4831,27 +4832,27 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4831
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):
4832
4833
 
4833
4834
  ```
4834
- MIT License
4835
-
4836
- Copyright (c) 2019-2022 Ankit Kumar (अंकित कुमार)
4837
-
4838
- Permission is hereby granted, free of charge, to any person obtaining a copy
4839
- of this software and associated documentation files (the "Software"), to deal
4840
- in the Software without restriction, including without limitation the rights
4841
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4842
- copies of the Software, and to permit persons to whom the Software is
4843
- furnished to do so, subject to the following conditions:
4844
-
4845
- The above copyright notice and this permission notice shall be included in all
4846
- copies or substantial portions of the Software.
4847
-
4848
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4849
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4850
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4851
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4852
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4853
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4854
- 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.
4855
4856
 
4856
4857
  ```
4857
4858
 
@@ -5749,6 +5750,216 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5749
5750
 
5750
5751
  ## optionalDependencies
5751
5752
 
5753
+ ### @datadog/pprof
5754
+
5755
+ This product includes source derived from [@datadog/pprof](https://github.com/DataDog/pprof-nodejs) ([v5.13.4](https://github.com/DataDog/pprof-nodejs/tree/v5.13.4)), distributed under the [Apache-2.0 License](https://github.com/DataDog/pprof-nodejs/blob/v5.13.4/LICENSE):
5756
+
5757
+ ```
5758
+
5759
+ Apache License
5760
+ Version 2.0, January 2004
5761
+ http://www.apache.org/licenses/
5762
+
5763
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
5764
+
5765
+ 1. Definitions.
5766
+
5767
+ "License" shall mean the terms and conditions for use, reproduction,
5768
+ and distribution as defined by Sections 1 through 9 of this document.
5769
+
5770
+ "Licensor" shall mean the copyright owner or entity authorized by
5771
+ the copyright owner that is granting the License.
5772
+
5773
+ "Legal Entity" shall mean the union of the acting entity and all
5774
+ other entities that control, are controlled by, or are under common
5775
+ control with that entity. For the purposes of this definition,
5776
+ "control" means (i) the power, direct or indirect, to cause the
5777
+ direction or management of such entity, whether by contract or
5778
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
5779
+ outstanding shares, or (iii) beneficial ownership of such entity.
5780
+
5781
+ "You" (or "Your") shall mean an individual or Legal Entity
5782
+ exercising permissions granted by this License.
5783
+
5784
+ "Source" form shall mean the preferred form for making modifications,
5785
+ including but not limited to software source code, documentation
5786
+ source, and configuration files.
5787
+
5788
+ "Object" form shall mean any form resulting from mechanical
5789
+ transformation or translation of a Source form, including but
5790
+ not limited to compiled object code, generated documentation,
5791
+ and conversions to other media types.
5792
+
5793
+ "Work" shall mean the work of authorship, whether in Source or
5794
+ Object form, made available under the License, as indicated by a
5795
+ copyright notice that is included in or attached to the work
5796
+ (an example is provided in the Appendix below).
5797
+
5798
+ "Derivative Works" shall mean any work, whether in Source or Object
5799
+ form, that is based on (or derived from) the Work and for which the
5800
+ editorial revisions, annotations, elaborations, or other modifications
5801
+ represent, as a whole, an original work of authorship. For the purposes
5802
+ of this License, Derivative Works shall not include works that remain
5803
+ separable from, or merely link (or bind by name) to the interfaces of,
5804
+ the Work and Derivative Works thereof.
5805
+
5806
+ "Contribution" shall mean any work of authorship, including
5807
+ the original version of the Work and any modifications or additions
5808
+ to that Work or Derivative Works thereof, that is intentionally
5809
+ submitted to Licensor for inclusion in the Work by the copyright owner
5810
+ or by an individual or Legal Entity authorized to submit on behalf of
5811
+ the copyright owner. For the purposes of this definition, "submitted"
5812
+ means any form of electronic, verbal, or written communication sent
5813
+ to the Licensor or its representatives, including but not limited to
5814
+ communication on electronic mailing lists, source code control systems,
5815
+ and issue tracking systems that are managed by, or on behalf of, the
5816
+ Licensor for the purpose of discussing and improving the Work, but
5817
+ excluding communication that is conspicuously marked or otherwise
5818
+ designated in writing by the copyright owner as "Not a Contribution."
5819
+
5820
+ "Contributor" shall mean Licensor and any individual or Legal Entity
5821
+ on behalf of whom a Contribution has been received by Licensor and
5822
+ subsequently incorporated within the Work.
5823
+
5824
+ 2. Grant of Copyright License. Subject to the terms and conditions of
5825
+ this License, each Contributor hereby grants to You a perpetual,
5826
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
5827
+ copyright license to reproduce, prepare Derivative Works of,
5828
+ publicly display, publicly perform, sublicense, and distribute the
5829
+ Work and such Derivative Works in Source or Object form.
5830
+
5831
+ 3. Grant of Patent License. Subject to the terms and conditions of
5832
+ this License, each Contributor hereby grants to You a perpetual,
5833
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
5834
+ (except as stated in this section) patent license to make, have made,
5835
+ use, offer to sell, sell, import, and otherwise transfer the Work,
5836
+ where such license applies only to those patent claims licensable
5837
+ by such Contributor that are necessarily infringed by their
5838
+ Contribution(s) alone or by combination of their Contribution(s)
5839
+ with the Work to which such Contribution(s) was submitted. If You
5840
+ institute patent litigation against any entity (including a
5841
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
5842
+ or a Contribution incorporated within the Work constitutes direct
5843
+ or contributory patent infringement, then any patent licenses
5844
+ granted to You under this License for that Work shall terminate
5845
+ as of the date such litigation is filed.
5846
+
5847
+ 4. Redistribution. You may reproduce and distribute copies of the
5848
+ Work or Derivative Works thereof in any medium, with or without
5849
+ modifications, and in Source or Object form, provided that You
5850
+ meet the following conditions:
5851
+
5852
+ (a) You must give any other recipients of the Work or
5853
+ Derivative Works a copy of this License; and
5854
+
5855
+ (b) You must cause any modified files to carry prominent notices
5856
+ stating that You changed the files; and
5857
+
5858
+ (c) You must retain, in the Source form of any Derivative Works
5859
+ that You distribute, all copyright, patent, trademark, and
5860
+ attribution notices from the Source form of the Work,
5861
+ excluding those notices that do not pertain to any part of
5862
+ the Derivative Works; and
5863
+
5864
+ (d) If the Work includes a "NOTICE" text file as part of its
5865
+ distribution, then any Derivative Works that You distribute must
5866
+ include a readable copy of the attribution notices contained
5867
+ within such NOTICE file, excluding those notices that do not
5868
+ pertain to any part of the Derivative Works, in at least one
5869
+ of the following places: within a NOTICE text file distributed
5870
+ as part of the Derivative Works; within the Source form or
5871
+ documentation, if provided along with the Derivative Works; or,
5872
+ within a display generated by the Derivative Works, if and
5873
+ wherever such third-party notices normally appear. The contents
5874
+ of the NOTICE file are for informational purposes only and
5875
+ do not modify the License. You may add Your own attribution
5876
+ notices within Derivative Works that You distribute, alongside
5877
+ or as an addendum to the NOTICE text from the Work, provided
5878
+ that such additional attribution notices cannot be construed
5879
+ as modifying the License.
5880
+
5881
+ You may add Your own copyright statement to Your modifications and
5882
+ may provide additional or different license terms and conditions
5883
+ for use, reproduction, or distribution of Your modifications, or
5884
+ for any such Derivative Works as a whole, provided Your use,
5885
+ reproduction, and distribution of the Work otherwise complies with
5886
+ the conditions stated in this License.
5887
+
5888
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
5889
+ any Contribution intentionally submitted for inclusion in the Work
5890
+ by You to the Licensor shall be under the terms and conditions of
5891
+ this License, without any additional terms or conditions.
5892
+ Notwithstanding the above, nothing herein shall supersede or modify
5893
+ the terms of any separate license agreement you may have executed
5894
+ with Licensor regarding such Contributions.
5895
+
5896
+ 6. Trademarks. This License does not grant permission to use the trade
5897
+ names, trademarks, service marks, or product names of the Licensor,
5898
+ except as required for reasonable and customary use in describing the
5899
+ origin of the Work and reproducing the content of the NOTICE file.
5900
+
5901
+ 7. Disclaimer of Warranty. Unless required by applicable law or
5902
+ agreed to in writing, Licensor provides the Work (and each
5903
+ Contributor provides its Contributions) on an "AS IS" BASIS,
5904
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
5905
+ implied, including, without limitation, any warranties or conditions
5906
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
5907
+ PARTICULAR PURPOSE. You are solely responsible for determining the
5908
+ appropriateness of using or redistributing the Work and assume any
5909
+ risks associated with Your exercise of permissions under this License.
5910
+
5911
+ 8. Limitation of Liability. In no event and under no legal theory,
5912
+ whether in tort (including negligence), contract, or otherwise,
5913
+ unless required by applicable law (such as deliberate and grossly
5914
+ negligent acts) or agreed to in writing, shall any Contributor be
5915
+ liable to You for damages, including any direct, indirect, special,
5916
+ incidental, or consequential damages of any character arising as a
5917
+ result of this License or out of the use or inability to use the
5918
+ Work (including but not limited to damages for loss of goodwill,
5919
+ work stoppage, computer failure or malfunction, or any and all
5920
+ other commercial damages or losses), even if such Contributor
5921
+ has been advised of the possibility of such damages.
5922
+
5923
+ 9. Accepting Warranty or Additional Liability. While redistributing
5924
+ the Work or Derivative Works thereof, You may choose to offer,
5925
+ and charge a fee for, acceptance of support, warranty, indemnity,
5926
+ or other liability obligations and/or rights consistent with this
5927
+ License. However, in accepting such obligations, You may act only
5928
+ on Your own behalf and on Your sole responsibility, not on behalf
5929
+ of any other Contributor, and only if You agree to indemnify,
5930
+ defend, and hold each Contributor harmless for any liability
5931
+ incurred by, or claims asserted against, such Contributor by reason
5932
+ of your accepting any such warranty or additional liability.
5933
+
5934
+ END OF TERMS AND CONDITIONS
5935
+
5936
+ APPENDIX: How to apply the Apache License to your work.
5937
+
5938
+ To apply the Apache License to your work, attach the following
5939
+ boilerplate notice, with the fields enclosed by brackets "[]"
5940
+ replaced with your own identifying information. (Don't include
5941
+ the brackets!) The text should be enclosed in the appropriate
5942
+ comment syntax for the file format. We also recommend that a
5943
+ file or class name and description of purpose be included on the
5944
+ same "printed page" as the copyright notice for easier
5945
+ identification within third-party archives.
5946
+
5947
+ Copyright [yyyy] [name of copyright owner]
5948
+
5949
+ Licensed under the Apache License, Version 2.0 (the "License");
5950
+ you may not use this file except in compliance with the License.
5951
+ You may obtain a copy of the License at
5952
+
5953
+ http://www.apache.org/licenses/LICENSE-2.0
5954
+
5955
+ Unless required by applicable law or agreed to in writing, software
5956
+ distributed under the License is distributed on an "AS IS" BASIS,
5957
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5958
+ See the License for the specific language governing permissions and
5959
+ limitations under the License.
5960
+
5961
+ ```
5962
+
5752
5963
  ### @newrelic/fn-inspect
5753
5964
 
5754
5965
  This product includes source derived from [@newrelic/fn-inspect](https://github.com/newrelic-forks/node-fn-inspect) ([v4.4.0](https://github.com/newrelic-forks/node-fn-inspect/tree/v4.4.0)), distributed under the [MIT License](https://github.com/newrelic-forks/node-fn-inspect/blob/v4.4.0/LICENSE):
@@ -6269,4 +6480,3 @@ Portions copyright Node.js contributors. Depending on your existing libraries an
6269
6480
  your systems may call externally maintained libraries in addition to those listed above.
6270
6481
  See [here](https://nodejs.org/en/docs/meta/topics/dependencies/) and [here](https://github.com/nodejs/node/blob/v4.3.1/LICENSE)
6271
6482
  for additional details regarding externally maintained libraries and certain related licenses and notices.
6272
-
package/lib/agent.js CHANGED
@@ -41,6 +41,8 @@ const Harvester = require('./harvester')
41
41
  const { createFeatureUsageMetrics } = require('./util/application-logging')
42
42
  const HealthReporter = require('./health-reporter')
43
43
  const Samplers = require('./samplers')
44
+ const ProfilingAggregator = require('./aggregators/profiling-aggregator')
45
+ const { createStartupProfilingMetrics } = require('./profiling/metrics')
44
46
 
45
47
  // Map of valid states to whether or not data collection is valid
46
48
  const STATES = {
@@ -302,6 +304,19 @@ function Agent(config) {
302
304
  this.harvester
303
305
  )
304
306
 
307
+ this.profilingData = new ProfilingAggregator(
308
+ {
309
+ config,
310
+ delay: config.profiling.delay,
311
+ duration: config.profiling.duration,
312
+ periodMs: DEFAULT_HARVEST_INTERVAL_MS,
313
+ method: 'pprof_data',
314
+ isAsync: !config.serverless_mode.enabled,
315
+ enabled: (config) => config.profiling.enabled && config.serverless_mode.enabled === false
316
+ },
317
+ this
318
+ )
319
+
305
320
  // Set up all the configuration events the agent needs to listen for.
306
321
  this._listenForConfigChanges()
307
322
 
@@ -421,6 +436,7 @@ Agent.prototype.startStreaming = function startStreaming() {
421
436
  Agent.prototype.onConnect = function onConnect(shouldImmediatelyHarvest, callback) {
422
437
  this.harvester.update(this.config)
423
438
  createFeatureUsageMetrics(this)
439
+ createStartupProfilingMetrics(this)
424
440
 
425
441
  if (this.config.certificates && this.config.certificates.length > 0) {
426
442
  this.metrics.getOrCreateMetric(NAMES.FEATURES.CERTIFICATES).incrementCallCount()
@@ -184,6 +184,8 @@ class Aggregator extends EventEmitter {
184
184
  this.method = opts.method
185
185
  this.collector = collector
186
186
  this.sendTimer = null
187
+ this.delayTimeout = null
188
+ this.durationTimeout = null
187
189
  harvester.add(this)
188
190
  }
189
191
 
@@ -211,6 +213,16 @@ class Aggregator extends EventEmitter {
211
213
 
212
214
  logger.trace(`${this.method} aggregator stopped.`)
213
215
  }
216
+
217
+ if (this.delayTimeout) {
218
+ clearTimeout(this.delayTimeout)
219
+ this.delayTimeout = null
220
+ }
221
+
222
+ if (this.durationTimeout) {
223
+ clearTimeout(this.durationTimeout)
224
+ this.durationTimeout = null
225
+ }
214
226
  }
215
227
 
216
228
  _merge() {
@@ -221,6 +233,15 @@ class Aggregator extends EventEmitter {
221
233
  throw new Error('add is not implemented')
222
234
  }
223
235
 
236
+ /**
237
+ * This is used to mark an aggregator as done. It will never start again in the same running
238
+ * instance of the agent. This is to prevent a delay + duration running again during a soft
239
+ * restart where the connect service tells the agent to restart.
240
+ */
241
+ end() {
242
+ this.isEnabled = () => false
243
+ }
244
+
224
245
  _toPayload(callback) {
225
246
  try {
226
247
  callback(null, this._toPayloadSync())
@@ -28,7 +28,7 @@ class ProfilingAggregator extends BaseAggregator {
28
28
  opts.method = opts.method || 'pprof_data'
29
29
  super(opts, collector, harvester)
30
30
  this.agent = agent
31
- this.profilingManager = new ProfilingManager(agent)
31
+ this.profilingManager = new ProfilingManager({ agent, samplingInterval: opts.periodMs })
32
32
  this.pprofData = null
33
33
  }
34
34
 
@@ -57,6 +57,11 @@ class ProfilingAggregator extends BaseAggregator {
57
57
  }
58
58
  }
59
59
 
60
+ /**
61
+ * This overrides the default `stop` method
62
+ * as we want to clear the setInterval but also stop
63
+ * all the registered profilers
64
+ */
60
65
  stop() {
61
66
  super.stop()
62
67
  this.profilingManager.stop()
@@ -67,12 +72,18 @@ class ProfilingAggregator extends BaseAggregator {
67
72
  * and collects data for the given time period. Then asynchronously
68
73
  * calls send which takes care of sending the data to the collector
69
74
  */
70
- collectData() {
71
- const self = this
72
- for (const pprofData of this.profilingManager.collect()) {
75
+ async collectData() {
76
+ let profilingData = []
77
+ try {
78
+ profilingData = await this.profilingManager.collect()
79
+ } catch (err) {
80
+ logger.error(err, 'Failed to collect profiling data')
81
+ }
82
+
83
+ for (const pprofData of profilingData) {
73
84
  if (pprofData) {
74
- self.pprofData = pprofData
75
- self.send()
85
+ this.pprofData = pprofData
86
+ this.send()
76
87
  }
77
88
  }
78
89
  }
@@ -62,7 +62,11 @@ RemoteMethod.prototype.updateEndpoint = function updateEndpoint(endpoint) {
62
62
  RemoteMethod.prototype.serialize = function serialize(payload, callback) {
63
63
  let res
64
64
  try {
65
- res = stringify(payload, (key, value) => (typeof value === 'bigint' ? value.toString() : value))
65
+ if (this._contentType === 'application/octet-stream') {
66
+ res = payload
67
+ } else {
68
+ res = stringify(payload, (key, value) => (typeof value === 'bigint' ? value.toString() : value))
69
+ }
66
70
  } catch (error) {
67
71
  logger.error(error, 'Unable to serialize payload for method %s.', this.name)
68
72
  return process.nextTick(function onNextTick() {
@@ -147,7 +151,8 @@ RemoteMethod.prototype._post = function _post(data, nrHeaders, callback) {
147
151
 
148
152
  // Check trace enabled first since we're creating an object for this log message.
149
153
  if (logger.traceEnabled()) {
150
- logger.trace({ data, compressed: options.compressed }, 'Calling %s on collector API', this.name)
154
+ const logData = Buffer.isBuffer(data) ? 'Buffer ' + data.length : data
155
+ logger.trace({ data: logData, compressed: options.compressed }, 'Calling %s on collector API', this.name)
151
156
  }
152
157
 
153
158
  if (options.compressed) {
@@ -1261,13 +1261,6 @@ defaultConfig.definition = () => {
1261
1261
  formatter: boolean,
1262
1262
  default: false
1263
1263
  },
1264
- /**
1265
- * Harvest and ingest profile data every n milliseconds
1266
- */
1267
- sample_interval: {
1268
- formatter: int,
1269
- default: 100
1270
- },
1271
1264
  /**
1272
1265
  * List of profile type names to enable. Only cpu and heap profiles are currently supported
1273
1266
  */
@@ -1288,24 +1281,6 @@ defaultConfig.definition = () => {
1288
1281
  duration: {
1289
1282
  formatter: int,
1290
1283
  default: 0
1291
- },
1292
- /**
1293
- * Restart the cpu profiler every n milliseconds to report its data
1294
- */
1295
- cpu: {
1296
- report_interval: {
1297
- formatter: int,
1298
- default: 0
1299
- }
1300
- },
1301
- /**
1302
- * Restart heap profiler every n milliseconds to report its data
1303
- */
1304
- heap: {
1305
- report_interval: {
1306
- formatter: int,
1307
- default: 0
1308
- }
1309
1284
  }
1310
1285
  },
1311
1286
 
package/lib/config/hsm.js CHANGED
@@ -58,6 +58,9 @@ const HIGH_SECURITY_SETTINGS = {
58
58
  },
59
59
  ai_monitoring: {
60
60
  enabled: false
61
+ },
62
+ profiling: {
63
+ enabled: false
61
64
  }
62
65
  }
63
66
 
@@ -618,6 +618,15 @@ Config.prototype._fromServer = function _fromServer(params, key) {
618
618
  }
619
619
  break
620
620
 
621
+ case 'profiling.enabled':
622
+ this._updateNestedIfChanged(
623
+ params,
624
+ this.profiling,
625
+ 'profiling.enabled',
626
+ 'enabled'
627
+ )
628
+ break
629
+
621
630
  // These settings are not allowed from the server.
622
631
  case 'attributes.enabled':
623
632
  case 'attributes.exclude':
@@ -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 {Context} a newly constructed context
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 })
@@ -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',