newrelic 13.2.0 → 13.3.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 (59) hide show
  1. package/NEWS.md +44 -0
  2. package/THIRD_PARTY_NOTICES.md +219 -8
  3. package/api.js +1 -1
  4. package/esm-loader.mjs +6 -1
  5. package/lib/instrumentation/@azure/functions.js +8 -46
  6. package/lib/instrumentation/core/http-outbound.js +26 -10
  7. package/lib/instrumentation/core/http.js +20 -118
  8. package/lib/instrumentations.js +0 -14
  9. package/lib/otel/logs/index.js +80 -0
  10. package/lib/otel/metrics/index.js +119 -0
  11. package/lib/otel/setup-signal.js +37 -0
  12. package/lib/otel/setup.js +15 -25
  13. package/lib/otel/{attr-reconciler.js → traces/attr-reconciler.js} +2 -2
  14. package/lib/otel/{exception-mapping.js → traces/exception-mapping.js} +1 -1
  15. package/lib/otel/traces/index.js +40 -0
  16. package/lib/otel/{rules.js → traces/rules.js} +1 -1
  17. package/lib/otel/{segment-synthesis.js → traces/segment-synthesis.js} +5 -4
  18. package/lib/otel/{segments → traces/segments}/consumer.js +4 -4
  19. package/lib/otel/{segments → traces/segments}/database.js +6 -6
  20. package/lib/otel/{segments → traces/segments}/http-external.js +11 -8
  21. package/lib/otel/traces/segments/index.js +22 -0
  22. package/lib/otel/{segments → traces/segments}/internal.js +1 -1
  23. package/lib/otel/{segments → traces/segments}/producer.js +2 -2
  24. package/lib/otel/{segments → traces/segments}/server.js +4 -4
  25. package/lib/otel/{segments → traces/segments}/utils.js +1 -1
  26. package/lib/otel/{span-processor.js → traces/span-processor.js} +13 -19
  27. package/lib/otel/{transformation-rules.json → traces/transformation-rules.json} +3 -2
  28. package/lib/otel/{utils.js → traces/utils.js} +2 -1
  29. package/lib/serverless/aws-lambda.js +7 -68
  30. package/lib/shim/webframework-shim/middleware.js +1 -1
  31. package/lib/shimmer.js +2 -2
  32. package/lib/subscriber-configs.js +2 -1
  33. package/lib/subscribers/base.js +30 -0
  34. package/lib/subscribers/elasticsearch/config.js +1 -0
  35. package/lib/subscribers/mcp-sdk/client-request.js +66 -0
  36. package/lib/subscribers/mcp-sdk/config.js +13 -75
  37. package/lib/subscribers/openai/base.js +21 -0
  38. package/lib/subscribers/openai/chat-responses.js +15 -0
  39. package/lib/subscribers/openai/chat.js +85 -0
  40. package/lib/subscribers/openai/client.js +31 -0
  41. package/lib/subscribers/openai/config.js +85 -0
  42. package/lib/subscribers/openai/embeddings.js +54 -0
  43. package/lib/subscribers/openai/utils.js +349 -0
  44. package/lib/transaction/index.js +157 -56
  45. package/lib/transaction/trace/segment.js +5 -2
  46. package/lib/util/urltils.js +158 -192
  47. package/lib/utilization/common.js +0 -6
  48. package/package.json +3 -4
  49. package/lib/instrumentation/openai.js +0 -482
  50. package/lib/otel/logs/bootstrap-logs.js +0 -84
  51. package/lib/otel/metrics/bootstrap-metrics.js +0 -117
  52. package/lib/otel/segments/index.js +0 -22
  53. package/lib/patch-module.js +0 -70
  54. package/lib/subscribers/mcp-sdk/client-prompt.js +0 -23
  55. package/lib/subscribers/mcp-sdk/client-resource.js +0 -24
  56. package/lib/subscribers/mcp-sdk/client-tool.js +0 -23
  57. package/lib/subscribers/mcp-sdk/client.js +0 -29
  58. /package/lib/otel/{constants.js → traces/constants.js} +0 -0
  59. /package/lib/otel/{sampler.js → traces/sampler.js} +0 -0
package/NEWS.md CHANGED
@@ -1,3 +1,45 @@
1
+ ### v13.3.0 (2025-09-08)
2
+
3
+ #### Features
4
+
5
+ * Added MCP `StreamableHTTPClientTransport` support ([#3337](https://github.com/newrelic/node-newrelic/pull/3337)) ([7189a35](https://github.com/newrelic/node-newrelic/commit/7189a35d0676a01d995420b2c6f27a54f8eb0307))
6
+
7
+ #### Code refactoring
8
+
9
+ * Removed instances of `url.parse`. Streamlined how http instrumentation creates relevant attributes. ([#3340](https://github.com/newrelic/node-newrelic/pull/3340)) ([1fc1e1a](https://github.com/newrelic/node-newrelic/commit/1fc1e1a4086200bd3fd76081913498d7ca344a3a))
10
+ * Updated `openai` instrumentation to subscribe to events emitted ([#3331](https://github.com/newrelic/node-newrelic/pull/3331)) ([04dd677](https://github.com/newrelic/node-newrelic/commit/04dd6774df87489cce41b0bb2b60c56b79e2265d))
11
+
12
+ #### Documentation
13
+
14
+ * Updated compatibility report ([#3344](https://github.com/newrelic/node-newrelic/pull/3344)) ([e422919](https://github.com/newrelic/node-newrelic/commit/e4229195318b2d2e33cc753b7898357daf72a372))
15
+
16
+ #### Miscellaneous chores
17
+
18
+ * Refactored OTEL bridge signals setup ([#3244](https://github.com/newrelic/node-newrelic/pull/3244)) ([ec8edef](https://github.com/newrelic/node-newrelic/commit/ec8edefdc49de276f30a1fc778f09b0d3042c392))
19
+
20
+ #### Tests
21
+
22
+ * Added more cassandra-driver tests ([#3323](https://github.com/newrelic/node-newrelic/pull/3323)) ([d2e9d10](https://github.com/newrelic/node-newrelic/commit/d2e9d103ee74358e88e53ab89c498f261f387ae5))
23
+ * Fixed long running benchmark test and add `shimmer.subscribers` benchmark test ([#3349](https://github.com/newrelic/node-newrelic/pull/3349)) ([15253c0](https://github.com/newrelic/node-newrelic/commit/15253c08f6d8381f516040e339a0aedaf04e365e))
24
+ * Fixed langchain openai streaming tests by explicitly passing `streaming: true` to chat model ([#3346](https://github.com/newrelic/node-newrelic/pull/3346)) ([4f12499](https://github.com/newrelic/node-newrelic/commit/4f12499c2c9248b7f510c76f19cc8d54eb53da2e))
25
+ * Fixed openai test after migration to tracing channel ([#3336](https://github.com/newrelic/node-newrelic/pull/3336)) ([0d01e29](https://github.com/newrelic/node-newrelic/commit/0d01e299cb84c9715f3136ab458534c72eea3145))
26
+ * Hardened `batch-span-streamer.test.js` to avoid random failures in CI ([#3338](https://github.com/newrelic/node-newrelic/pull/3338)) ([2077ce3](https://github.com/newrelic/node-newrelic/commit/2077ce35db319d0128337faed0ff77b00f76d8f1))
27
+
28
+ #### Continuous integration
29
+
30
+ * Set benchmark host default to staging ([#3332](https://github.com/newrelic/node-newrelic/pull/3332)) ([55f6b8d](https://github.com/newrelic/node-newrelic/commit/55f6b8d757afc1632f1be1c0ef1a4ccab23ca3c4))
31
+ * Updated the redis container to use the official `redis` image as `bitnami/redis` is moving and no reason to use a 3rd party image ([#3342](https://github.com/newrelic/node-newrelic/pull/3342)) ([8ffb393](https://github.com/newrelic/node-newrelic/commit/8ffb393ef5e84b188d899580061b2b57171e8166))
32
+
33
+ ### v13.2.1 (2025-08-21)
34
+
35
+ #### Code refactoring
36
+
37
+ * Updated agent to use `@apm-js-collab/tracing-hooks` for the CJS/ESM registration for tracing channel based instrumentation ([#3324](https://github.com/newrelic/node-newrelic/pull/3324)) ([4b2c14f](https://github.com/newrelic/node-newrelic/commit/4b2c14f35d5c658160ad9420ca562f73ae55bbc0))
38
+
39
+ #### Documentation
40
+
41
+ * Updated compatibility report ([#3330](https://github.com/newrelic/node-newrelic/pull/3330)) ([2831a89](https://github.com/newrelic/node-newrelic/commit/2831a895e0278a05bed8e9f81245c7f9ae515eca))
42
+
1
43
  ### v13.2.0 (2025-08-20)
2
44
 
3
45
  #### Features
@@ -7813,3 +7855,5 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
7813
7855
  [mdn-async-function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
7814
7856
 
7815
7857
 
7858
+
7859
+
@@ -14,6 +14,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
14
14
 
15
15
  **[dependencies](#dependencies)**
16
16
 
17
+ * [@apm-js-collab/tracing-hooks](#apm-js-collabtracing-hooks)
17
18
  * [@grpc/grpc-js](#grpcgrpc-js)
18
19
  * [@grpc/proto-loader](#grpcproto-loader)
19
20
  * [@newrelic/security-agent](#newrelicsecurity-agent)
@@ -95,6 +96,216 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
95
96
 
96
97
  ## dependencies
97
98
 
99
+ ### @apm-js-collab/tracing-hooks
100
+
101
+ This product includes source derived from [@apm-js-collab/tracing-hooks](https://github.com/apm-js-collab/tracing-hooks) ([v0.1.1](https://github.com/apm-js-collab/tracing-hooks/tree/v0.1.1)), distributed under the [Apache-2.0 License](https://github.com/apm-js-collab/tracing-hooks/blob/v0.1.1/LICENSE):
102
+
103
+ ```
104
+
105
+ Apache License
106
+ Version 2.0, January 2004
107
+ http://www.apache.org/licenses/
108
+
109
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
110
+
111
+ 1. Definitions.
112
+
113
+ "License" shall mean the terms and conditions for use, reproduction,
114
+ and distribution as defined by Sections 1 through 9 of this document.
115
+
116
+ "Licensor" shall mean the copyright owner or entity authorized by
117
+ the copyright owner that is granting the License.
118
+
119
+ "Legal Entity" shall mean the union of the acting entity and all
120
+ other entities that control, are controlled by, or are under common
121
+ control with that entity. For the purposes of this definition,
122
+ "control" means (i) the power, direct or indirect, to cause the
123
+ direction or management of such entity, whether by contract or
124
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
125
+ outstanding shares, or (iii) beneficial ownership of such entity.
126
+
127
+ "You" (or "Your") shall mean an individual or Legal Entity
128
+ exercising permissions granted by this License.
129
+
130
+ "Source" form shall mean the preferred form for making modifications,
131
+ including but not limited to software source code, documentation
132
+ source, and configuration files.
133
+
134
+ "Object" form shall mean any form resulting from mechanical
135
+ transformation or translation of a Source form, including but
136
+ not limited to compiled object code, generated documentation,
137
+ and conversions to other media types.
138
+
139
+ "Work" shall mean the work of authorship, whether in Source or
140
+ Object form, made available under the License, as indicated by a
141
+ copyright notice that is included in or attached to the work
142
+ (an example is provided in the Appendix below).
143
+
144
+ "Derivative Works" shall mean any work, whether in Source or Object
145
+ form, that is based on (or derived from) the Work and for which the
146
+ editorial revisions, annotations, elaborations, or other modifications
147
+ represent, as a whole, an original work of authorship. For the purposes
148
+ of this License, Derivative Works shall not include works that remain
149
+ separable from, or merely link (or bind by name) to the interfaces of,
150
+ the Work and Derivative Works thereof.
151
+
152
+ "Contribution" shall mean any work of authorship, including
153
+ the original version of the Work and any modifications or additions
154
+ to that Work or Derivative Works thereof, that is intentionally
155
+ submitted to Licensor for inclusion in the Work by the copyright owner
156
+ or by an individual or Legal Entity authorized to submit on behalf of
157
+ the copyright owner. For the purposes of this definition, "submitted"
158
+ means any form of electronic, verbal, or written communication sent
159
+ to the Licensor or its representatives, including but not limited to
160
+ communication on electronic mailing lists, source code control systems,
161
+ and issue tracking systems that are managed by, or on behalf of, the
162
+ Licensor for the purpose of discussing and improving the Work, but
163
+ excluding communication that is conspicuously marked or otherwise
164
+ designated in writing by the copyright owner as "Not a Contribution."
165
+
166
+ "Contributor" shall mean Licensor and any individual or Legal Entity
167
+ on behalf of whom a Contribution has been received by Licensor and
168
+ subsequently incorporated within the Work.
169
+
170
+ 2. Grant of Copyright License. Subject to the terms and conditions of
171
+ this License, each Contributor hereby grants to You a perpetual,
172
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
173
+ copyright license to reproduce, prepare Derivative Works of,
174
+ publicly display, publicly perform, sublicense, and distribute the
175
+ Work and such Derivative Works in Source or Object form.
176
+
177
+ 3. Grant of Patent License. Subject to the terms and conditions of
178
+ this License, each Contributor hereby grants to You a perpetual,
179
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
180
+ (except as stated in this section) patent license to make, have made,
181
+ use, offer to sell, sell, import, and otherwise transfer the Work,
182
+ where such license applies only to those patent claims licensable
183
+ by such Contributor that are necessarily infringed by their
184
+ Contribution(s) alone or by combination of their Contribution(s)
185
+ with the Work to which such Contribution(s) was submitted. If You
186
+ institute patent litigation against any entity (including a
187
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
188
+ or a Contribution incorporated within the Work constitutes direct
189
+ or contributory patent infringement, then any patent licenses
190
+ granted to You under this License for that Work shall terminate
191
+ as of the date such litigation is filed.
192
+
193
+ 4. Redistribution. You may reproduce and distribute copies of the
194
+ Work or Derivative Works thereof in any medium, with or without
195
+ modifications, and in Source or Object form, provided that You
196
+ meet the following conditions:
197
+
198
+ (a) You must give any other recipients of the Work or
199
+ Derivative Works a copy of this License; and
200
+
201
+ (b) You must cause any modified files to carry prominent notices
202
+ stating that You changed the files; and
203
+
204
+ (c) You must retain, in the Source form of any Derivative Works
205
+ that You distribute, all copyright, patent, trademark, and
206
+ attribution notices from the Source form of the Work,
207
+ excluding those notices that do not pertain to any part of
208
+ the Derivative Works; and
209
+
210
+ (d) If the Work includes a "NOTICE" text file as part of its
211
+ distribution, then any Derivative Works that You distribute must
212
+ include a readable copy of the attribution notices contained
213
+ within such NOTICE file, excluding those notices that do not
214
+ pertain to any part of the Derivative Works, in at least one
215
+ of the following places: within a NOTICE text file distributed
216
+ as part of the Derivative Works; within the Source form or
217
+ documentation, if provided along with the Derivative Works; or,
218
+ within a display generated by the Derivative Works, if and
219
+ wherever such third-party notices normally appear. The contents
220
+ of the NOTICE file are for informational purposes only and
221
+ do not modify the License. You may add Your own attribution
222
+ notices within Derivative Works that You distribute, alongside
223
+ or as an addendum to the NOTICE text from the Work, provided
224
+ that such additional attribution notices cannot be construed
225
+ as modifying the License.
226
+
227
+ You may add Your own copyright statement to Your modifications and
228
+ may provide additional or different license terms and conditions
229
+ for use, reproduction, or distribution of Your modifications, or
230
+ for any such Derivative Works as a whole, provided Your use,
231
+ reproduction, and distribution of the Work otherwise complies with
232
+ the conditions stated in this License.
233
+
234
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
235
+ any Contribution intentionally submitted for inclusion in the Work
236
+ by You to the Licensor shall be under the terms and conditions of
237
+ this License, without any additional terms or conditions.
238
+ Notwithstanding the above, nothing herein shall supersede or modify
239
+ the terms of any separate license agreement you may have executed
240
+ with Licensor regarding such Contributions.
241
+
242
+ 6. Trademarks. This License does not grant permission to use the trade
243
+ names, trademarks, service marks, or product names of the Licensor,
244
+ except as required for reasonable and customary use in describing the
245
+ origin of the Work and reproducing the content of the NOTICE file.
246
+
247
+ 7. Disclaimer of Warranty. Unless required by applicable law or
248
+ agreed to in writing, Licensor provides the Work (and each
249
+ Contributor provides its Contributions) on an "AS IS" BASIS,
250
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
251
+ implied, including, without limitation, any warranties or conditions
252
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
253
+ PARTICULAR PURPOSE. You are solely responsible for determining the
254
+ appropriateness of using or redistributing the Work and assume any
255
+ risks associated with Your exercise of permissions under this License.
256
+
257
+ 8. Limitation of Liability. In no event and under no legal theory,
258
+ whether in tort (including negligence), contract, or otherwise,
259
+ unless required by applicable law (such as deliberate and grossly
260
+ negligent acts) or agreed to in writing, shall any Contributor be
261
+ liable to You for damages, including any direct, indirect, special,
262
+ incidental, or consequential damages of any character arising as a
263
+ result of this License or out of the use or inability to use the
264
+ Work (including but not limited to damages for loss of goodwill,
265
+ work stoppage, computer failure or malfunction, or any and all
266
+ other commercial damages or losses), even if such Contributor
267
+ has been advised of the possibility of such damages.
268
+
269
+ 9. Accepting Warranty or Additional Liability. While redistributing
270
+ the Work or Derivative Works thereof, You may choose to offer,
271
+ and charge a fee for, acceptance of support, warranty, indemnity,
272
+ or other liability obligations and/or rights consistent with this
273
+ License. However, in accepting such obligations, You may act only
274
+ on Your own behalf and on Your sole responsibility, not on behalf
275
+ of any other Contributor, and only if You agree to indemnify,
276
+ defend, and hold each Contributor harmless for any liability
277
+ incurred by, or claims asserted against, such Contributor by reason
278
+ of your accepting any such warranty or additional liability.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ APPENDIX: How to apply the Apache License to your work.
283
+
284
+ To apply the Apache License to your work, attach the following
285
+ boilerplate notice, with the fields enclosed by brackets "[]"
286
+ replaced with your own identifying information. (Don't include
287
+ the brackets!) The text should be enclosed in the appropriate
288
+ comment syntax for the file format. We also recommend that a
289
+ file or class name and description of purpose be included on the
290
+ same "printed page" as the copyright notice for easier
291
+ identification within third-party archives.
292
+
293
+ Copyright 2025-present Datadog, Inc.
294
+
295
+ Licensed under the Apache License, Version 2.0 (the "License");
296
+ you may not use this file except in compliance with the License.
297
+ You may obtain a copy of the License at
298
+
299
+ http://www.apache.org/licenses/LICENSE-2.0
300
+
301
+ Unless required by applicable law or agreed to in writing, software
302
+ distributed under the License is distributed on an "AS IS" BASIS,
303
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
304
+ See the License for the specific language governing permissions and
305
+ limitations under the License.
306
+
307
+ ```
308
+
98
309
  ### @grpc/grpc-js
99
310
 
100
311
  This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.13.4](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.13.4)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.13.4/LICENSE):
@@ -515,7 +726,7 @@ This product includes source derived from [@grpc/proto-loader](https://github.co
515
726
 
516
727
  ### @newrelic/security-agent
517
728
 
518
- This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v2.4.2](https://github.com/newrelic/csec-node-agent/tree/v2.4.2)), distributed under the [UNKNOWN License](https://github.com/newrelic/csec-node-agent/blob/v2.4.2/LICENSE):
729
+ This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v2.4.3](https://github.com/newrelic/csec-node-agent/tree/v2.4.3)), distributed under the [UNKNOWN License](https://github.com/newrelic/csec-node-agent/blob/v2.4.3/LICENSE):
519
730
 
520
731
  ```
521
732
  ## New Relic Software License v1.0
@@ -2322,7 +2533,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2322
2533
 
2323
2534
  ### import-in-the-middle
2324
2535
 
2325
- This product includes source derived from [import-in-the-middle](https://github.com/nodejs/import-in-the-middle) ([v1.14.0](https://github.com/nodejs/import-in-the-middle/tree/v1.14.0)), distributed under the [Apache-2.0 License](https://github.com/nodejs/import-in-the-middle/blob/v1.14.0/LICENSE):
2536
+ This product includes source derived from [import-in-the-middle](https://github.com/nodejs/import-in-the-middle) ([v1.14.2](https://github.com/nodejs/import-in-the-middle/tree/v1.14.2)), distributed under the [Apache-2.0 License](https://github.com/nodejs/import-in-the-middle/blob/v1.14.2/LICENSE):
2326
2537
 
2327
2538
  ```
2328
2539
  Apache License
@@ -2753,7 +2964,7 @@ SOFTWARE.
2753
2964
 
2754
2965
  ### @aws-sdk/client-s3
2755
2966
 
2756
- This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.821.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.821.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.821.0/LICENSE):
2967
+ This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.872.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.872.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.872.0/LICENSE):
2757
2968
 
2758
2969
  ```
2759
2970
  Apache License
@@ -2962,7 +3173,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co
2962
3173
 
2963
3174
  ### @aws-sdk/s3-request-presigner
2964
3175
 
2965
- This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.821.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.821.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.821.0/LICENSE):
3176
+ This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.872.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.872.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.872.0/LICENSE):
2966
3177
 
2967
3178
  ```
2968
3179
  Apache License
@@ -4790,7 +5001,7 @@ SOFTWARE.
4790
5001
 
4791
5002
  ### eslint-plugin-jsdoc
4792
5003
 
4793
- This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v50.7.1](https://github.com/gajus/eslint-plugin-jsdoc/tree/v50.7.1)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v50.7.1/LICENSE):
5004
+ This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v50.8.0](https://github.com/gajus/eslint-plugin-jsdoc/tree/v50.8.0)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v50.8.0/LICENSE):
4794
5005
 
4795
5006
  ```
4796
5007
  Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/)
@@ -4822,7 +5033,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4822
5033
 
4823
5034
  ### eslint
4824
5035
 
4825
- This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.28.0](https://github.com/eslint/eslint/tree/v9.28.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.28.0/LICENSE):
5036
+ This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.33.0](https://github.com/eslint/eslint/tree/v9.33.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.33.0/LICENSE):
4826
5037
 
4827
5038
  ```
4828
5039
  Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
@@ -5149,7 +5360,7 @@ THE SOFTWARE.
5149
5360
 
5150
5361
  ### koa
5151
5362
 
5152
- This product includes source derived from [koa](https://github.com/koajs/koa) ([v2.16.1](https://github.com/koajs/koa/tree/v2.16.1)), distributed under the [MIT License](https://github.com/koajs/koa/blob/v2.16.1/LICENSE):
5363
+ This product includes source derived from [koa](https://github.com/koajs/koa) ([v2.16.2](https://github.com/koajs/koa/tree/v2.16.2)), distributed under the [MIT License](https://github.com/koajs/koa/blob/v2.16.2/LICENSE):
5153
5364
 
5154
5365
  ```
5155
5366
  (The MIT License)
@@ -5435,7 +5646,7 @@ SOFTWARE.
5435
5646
 
5436
5647
  ### protobufjs
5437
5648
 
5438
- This product includes source derived from [protobufjs](https://github.com/protobufjs/protobuf.js) ([v7.5.3](https://github.com/protobufjs/protobuf.js/tree/v7.5.3)), distributed under the [BSD-3-Clause License](https://github.com/protobufjs/protobuf.js/blob/v7.5.3/LICENSE):
5649
+ This product includes source derived from [protobufjs](https://github.com/protobufjs/protobuf.js) ([v7.5.4](https://github.com/protobufjs/protobuf.js/tree/v7.5.4)), distributed under the [BSD-3-Clause License](https://github.com/protobufjs/protobuf.js/blob/v7.5.4/LICENSE):
5439
5650
 
5440
5651
  ```
5441
5652
  This license applies to all parts of protobuf.js except those files
package/api.js CHANGED
@@ -1133,7 +1133,7 @@ API.prototype.endTransaction = function endTransaction() {
1133
1133
  if (tx) {
1134
1134
  if (tx.baseSegment) {
1135
1135
  if (tx.type === 'web') {
1136
- tx.finalizeNameFromUri(tx.url, 0)
1136
+ tx.finalizeNameFromWeb(0)
1137
1137
  }
1138
1138
  tx.baseSegment.end()
1139
1139
  }
package/esm-loader.mjs CHANGED
@@ -5,10 +5,15 @@
5
5
 
6
6
  // eslint-disable-next-line n/no-unsupported-features/node-builtins
7
7
  import { register } from 'node:module'
8
+ import subscriptions from './lib/subscriber-configs.js'
9
+ import createSubscriberConfigs from './lib/subscribers/create-config.js'
8
10
  // Exclusions must be regexes
9
11
  const exclusions = [/@openai\/agents.*/]
12
+ const { packages, instrumentations } = createSubscriberConfigs(subscriptions)
10
13
 
11
- register('./esm-rewriter.mjs', import.meta.url)
14
+ register('@apm-js-collab/tracing-hooks/hook.mjs', import.meta.url, {
15
+ data: { instrumentations, packages }
16
+ })
12
17
  register('import-in-the-middle/hook.mjs', import.meta.url, {
13
18
  data: { exclude: exclusions }
14
19
  })
@@ -6,9 +6,6 @@
6
6
  'use strict'
7
7
 
8
8
  const defaultLogger = require('../../logger').child({ component: 'azure-functions' })
9
- const urltils = require('../../util/urltils')
10
- const headerProcessing = require('../../header-processing')
11
- const synthetics = require('../../synthetics')
12
9
  const { Transform } = require('node:stream')
13
10
 
14
11
  const backgroundRecorder = require('../../metrics/recorders/other.js')
@@ -29,12 +26,8 @@ const RESOURCE_GROUP_NAME = WEBSITE_RESOURCE_GROUP ?? WEBSITE_OWNER_NAME?.split(
29
26
  const AZURE_FUNCTION_APP_NAME = WEBSITE_SITE_NAME
30
27
 
31
28
  let coldStart = true
32
- let _agent
33
- let _logger
34
29
 
35
- module.exports = function initialize(agent, azureFunctions, _moduleName, shim, { logger = defaultLogger } = {}) {
36
- _agent = agent
37
- _logger = logger
30
+ module.exports = function initialize(_agent, azureFunctions, _moduleName, shim, { logger = defaultLogger } = {}) {
38
31
  if (!SUBSCRIPTION_ID || !RESOURCE_GROUP_NAME || !AZURE_FUNCTION_APP_NAME) {
39
32
  logger.warn(
40
33
  {
@@ -91,7 +84,6 @@ function wrapAzureHttpMethods(shim, appMethod) {
91
84
  // Set the transaction name according to our spec (category + function name).
92
85
  tx.setPartialName(`AzureFunction/${context.functionName}`)
93
86
 
94
- const url = new URL(request.url)
95
87
  const segment = tracer.createSegment({
96
88
  name: request.url,
97
89
  recorder: recordWeb,
@@ -100,56 +92,26 @@ function wrapAzureHttpMethods(shim, appMethod) {
100
92
  })
101
93
  segment.start()
102
94
 
95
+ const absoluteUrl = request.url
96
+ const url = new URL(absoluteUrl)
103
97
  const transport = url.protocol === 'https:' ? 'HTTPS' : 'HTTP'
104
- tx.type = TYPES.WEB
98
+ const port = url.port || (transport === 'HTTPS' ? 443 : 80)
105
99
  tx.baseSegment = segment
106
- tx.parsedUrl = url
107
- tx.url = urltils.obfuscatePath(_agent.config, url.pathname)
108
- tx.verb = request.method
109
- if (url.port === '') {
110
- tx.port = transport === 'HTTPS' ? '443' : '80'
111
- } else {
112
- tx.port = url.port
113
- }
100
+ tx.initializeWeb({ absoluteUrl, method: request.method, port, headers: request.headers, transport })
114
101
 
115
- tx.trace.attributes.addAttribute(
116
- DESTS.TRANS_EVENT | DESTS.ERROR_EVENT,
117
- 'request.uri',
118
- tx.url
119
- )
120
- segment.addSpanAttribute('request.uri', tx.url)
121
- if (request.method != null) {
122
- segment.addSpanAttribute('request.method', request.method)
123
- }
124
102
  addAttributes({ transaction: tx, functionContext: context })
125
103
 
126
- const queueTimeStamp = headerProcessing.getQueueTime(_logger, request.headers)
127
- if (queueTimeStamp) {
128
- tx.queueTime = Date.now() - queueTimeStamp
129
- }
130
-
131
- synthetics.assignHeadersToTransaction(_agent.config, tx, request.headers)
132
- if (_agent.config.distributed_tracing.enabled === true) {
133
- tx.acceptDistributedTraceHeaders(transport, request.headers)
134
- }
135
-
136
104
  const newContext = ctx.enterSegment({ segment })
137
105
  const boundHandler = tracer.bindFunction(handler, newContext)
138
106
  const result = await boundHandler(...args)
139
107
 
140
- // Responses should have a shape as described at:
141
- // https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node?tabs=javascript%2Cwindows%2Cazure-cli&pivots=nodejs-model-v4#http-response
142
- if (result?.status) {
143
- tx.trace.attributes.addAttribute(
144
- DESTS.TRANS_COMMON,
145
- 'http.statusCode',
146
- result.status
147
- )
148
- }
149
108
  if (coldStart === true) {
150
109
  tx.trace.attributes.addAttribute(DESTS.TRANS_COMMON, 'faas.coldStart', true)
151
110
  coldStart = false
152
111
  }
112
+ // Responses should have a shape as described at:
113
+ // https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-node?tabs=javascript%2Cwindows%2Cazure-cli&pivots=nodejs-model-v4#http-response
114
+ tx.finalizeWeb({ statusCode: result?.status, headers: result?.headers, end: false })
153
115
  if (result?.body instanceof Transform) {
154
116
  result.body.on('close', () => {
155
117
  tx.end()
@@ -10,7 +10,6 @@ const cat = require('../../util/cat')
10
10
  const urltils = require('../../util/urltils')
11
11
  const logger = require('../../logger').child({ component: 'outbound' })
12
12
  const shimmer = require('../../shimmer')
13
- const url = require('url')
14
13
  const symbols = require('../../symbols')
15
14
  const synthetics = require('../../synthetics')
16
15
  const { URL } = require('node:url')
@@ -245,16 +244,33 @@ function applySegment({ opts, makeRequest, host, port, hostname, segment, config
245
244
  segment.start()
246
245
  const request = makeRequest(opts)
247
246
 
248
- // Attempt to parse into new URL.
249
- // If no href, revert to url.parse.
250
- // Rarely, the href doesn't contain the
251
- // path, so we have to use url.parse to get the path.
252
- const urlObject = (opts?.href?.includes(request.path)) ? new URL(opts.href) : url.parse(request.path, true)
253
- const parsed = urltils.scrubAndParseParameters(urlObject)
254
- const obfuscatedPath = urltils.obfuscatePath(config, parsed.path)
247
+ // Parse the appropriate URL from the request options
248
+ // 1. If the path is a proxy url use the entire path
249
+ // 2. construct url from path, protocol and host if href does not already include path
250
+ // 3. use href to construct url
251
+ let absoluteUrl = null
252
+ if (request?.path?.startsWith('http://') || request?.path?.startsWith('https://')) {
253
+ absoluteUrl = request.path
254
+ } else if (!opts?.href?.includes(request.path)) {
255
+ const protocol = opts.protocol || 'http:'
256
+ absoluteUrl = `${protocol}//${host}${request.path}`
257
+ } else {
258
+ absoluteUrl = opts.href
259
+ }
260
+
261
+ let obfuscatedPath, parsed
262
+ try {
263
+ const urlObject = new URL(absoluteUrl)
264
+ parsed = urltils.scrubAndParseParameters(urlObject)
265
+ obfuscatedPath = urltils.obfuscatePath(config, parsed.path)
266
+ segment.name += obfuscatedPath
267
+ } catch (err) {
268
+ logger.debug('Could not parse URL from request options: %s', err.message)
269
+ obfuscatedPath = request.path
270
+ }
255
271
 
256
272
  const proto = parsed.protocol || opts.protocol || 'http:'
257
- segment.name += obfuscatedPath
273
+
258
274
  segment.captureExternalAttributes({
259
275
  protocol: proto,
260
276
  hostname,
@@ -262,7 +278,7 @@ function applySegment({ opts, makeRequest, host, port, hostname, segment, config
262
278
  method: opts.method,
263
279
  port,
264
280
  path: obfuscatedPath,
265
- queryParams: parsed.parameters
281
+ queryParams: parsed?.parameters
266
282
  })
267
283
  request[symbols.segment] = segment
268
284
  return request