newrelic 13.0.0 → 13.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NEWS.md CHANGED
@@ -1,3 +1,49 @@
1
+ ### v13.1.0 (2025-08-13)
2
+
3
+ #### Features
4
+
5
+ * Added support for OTEL logs API ([#3228](https://github.com/newrelic/node-newrelic/pull/3228)) ([19a9c78](https://github.com/newrelic/node-newrelic/commit/19a9c788c27f084618093d94a31b7badd5fcafd9))
6
+ * Added supportability metrics when instrumentation has been disabled for a package ([#3252](https://github.com/newrelic/node-newrelic/pull/3252)) ([6098a5b](https://github.com/newrelic/node-newrelic/commit/6098a5b24497029686f0253d68e2d3138e84a27b))
7
+ * Disabled timers instrumentation by default in the sample configuration ([#3253](https://github.com/newrelic/node-newrelic/pull/3253)) ([72eb8d4](https://github.com/newrelic/node-newrelic/commit/72eb8d4450e2f2eb958d5faf472a94c2b93b0b81))
8
+
9
+ #### Bug fixes
10
+
11
+ * Fixed `transaction.url` obfuscation ([#3280](https://github.com/newrelic/node-newrelic/pull/3280)) ([dc09492](https://github.com/newrelic/node-newrelic/commit/dc09492228e0ddae2598e0edd5403bd01cd3bbcd))
12
+
13
+ #### Code refactoring
14
+
15
+ * Updated `http-outbound` to parse url only once ([#3270](https://github.com/newrelic/node-newrelic/pull/3270)) ([5bb0f8d](https://github.com/newrelic/node-newrelic/commit/5bb0f8d79ab9cf7100d323166302b509edce3ff1))
16
+
17
+ #### Documentation
18
+
19
+ * Updated distributed tracing example target to use the correct repo ([#3254](https://github.com/newrelic/node-newrelic/pull/3254)) ([1fb3859](https://github.com/newrelic/node-newrelic/commit/1fb3859ed905c03d601a5344436037969fcc1256))
20
+ * Updated compatibility report ([#3299](https://github.com/newrelic/node-newrelic/pull/3299)) ([8b85342](https://github.com/newrelic/node-newrelic/commit/8b85342f35c7fe92287b227f48fb2d14079070bf))
21
+ * Updated compatibility report ([#3267](https://github.com/newrelic/node-newrelic/pull/3267)) ([2712c94](https://github.com/newrelic/node-newrelic/commit/2712c94a07c13cea6dd7a488e6df960daba55307))
22
+ * Updated compatibility report ([#3265](https://github.com/newrelic/node-newrelic/pull/3265)) ([daedadd](https://github.com/newrelic/node-newrelic/commit/daedadde1766ddb8b0d94b6d9599bdd246073576))
23
+ * Updated compatibility report ([#3261](https://github.com/newrelic/node-newrelic/pull/3261)) ([bd7d3fa](https://github.com/newrelic/node-newrelic/commit/bd7d3fa1bed4ce312ef7609fc2dd87aa348ed2b6))
24
+ * Updated compatibility report ([#3246](https://github.com/newrelic/node-newrelic/pull/3246)) ([c289fb5](https://github.com/newrelic/node-newrelic/commit/c289fb5d241c85c6ff4d20c5a54222178475ce33))
25
+ * Updated compatibility report ([#3241](https://github.com/newrelic/node-newrelic/pull/3241)) ([64529e1](https://github.com/newrelic/node-newrelic/commit/64529e189e409cfedf552f8c212a36997df408b4))
26
+
27
+ #### Miscellaneous chores
28
+
29
+ * Added guardrail for OTEL bridge ([#3283](https://github.com/newrelic/node-newrelic/pull/3283)) ([ff71865](https://github.com/newrelic/node-newrelic/commit/ff718658754d711b3b837e5ad633a8da4feeba7e))
30
+ * Refactored API bootstrapping ([#3281](https://github.com/newrelic/node-newrelic/pull/3281)) ([97be8f6](https://github.com/newrelic/node-newrelic/commit/97be8f6b67c364a5a720d2889989ce3dfacb2cf5))
31
+
32
+
33
+ #### Tests
34
+
35
+ * Cleaned up engines and version ranges in versioned tests ([#3260](https://github.com/newrelic/node-newrelic/pull/3260)) ([c7fd60e](https://github.com/newrelic/node-newrelic/commit/c7fd60e938aaaf9b13dc4055f6aff02508ae554c))
36
+ * Fixed failing http benchmark test ([#3258](https://github.com/newrelic/node-newrelic/pull/3258)) ([7e8cd48](https://github.com/newrelic/node-newrelic/commit/7e8cd480786f7d971a8c6263c6cc82e92fbc0fe1))
37
+ * Fixed a failing span-event benchmark test ([#3255](https://github.com/newrelic/node-newrelic/pull/3255)) ([05b955f](https://github.com/newrelic/node-newrelic/commit/05b955fb6ff2a470b82436964eeeaed8e93962ae))
38
+ * Fixed CI issues with latest 24 ([#3277](https://github.com/newrelic/node-newrelic/pull/3277)) ([960d169](https://github.com/newrelic/node-newrelic/commit/960d169122fc821a432eb7c200ba713963b66289))
39
+ * Fixed tests that assumed timers instrumentation was always enabled ([#3257](https://github.com/newrelic/node-newrelic/pull/3257)) ([40cfda1](https://github.com/newrelic/node-newrelic/commit/40cfda159a86f7c83bdfc783480ad56183098b45))
40
+ * Forced install of peer deps on nestjs test app ([#3269](https://github.com/newrelic/node-newrelic/pull/3269)) ([4e454ff](https://github.com/newrelic/node-newrelic/commit/4e454ffabef4aa6a731bc07bb730d29e726b4713))
41
+
42
+ #### Continuous integration
43
+
44
+ * Updated CI to fail if benchmark tests fail ([#3256](https://github.com/newrelic/node-newrelic/pull/3256)) ([a6a7a15](https://github.com/newrelic/node-newrelic/commit/a6a7a15d1d8d1241ca88c9d3c33ec537fe5c0164))
45
+ * Added sending benchmark metrics to NR One ([#3285](https://github.com/newrelic/node-newrelic/pull/3285)) ([7fc8e40](https://github.com/newrelic/node-newrelic/commit/7fc8e40e3d9995fd161b85e4e0ef92501aed9369))
46
+
1
47
  ### v13.0.0 (2025-07-23)
2
48
  #### ⚠ BREAKING CHANGES
3
49
 
@@ -17,10 +17,12 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
17
17
  * [@grpc/grpc-js](#grpcgrpc-js)
18
18
  * [@grpc/proto-loader](#grpcproto-loader)
19
19
  * [@newrelic/security-agent](#newrelicsecurity-agent)
20
+ * [@opentelemetry/api-logs](#opentelemetryapi-logs)
20
21
  * [@opentelemetry/api](#opentelemetryapi)
21
22
  * [@opentelemetry/core](#opentelemetrycore)
22
23
  * [@opentelemetry/exporter-metrics-otlp-proto](#opentelemetryexporter-metrics-otlp-proto)
23
24
  * [@opentelemetry/resources](#opentelemetryresources)
25
+ * [@opentelemetry/sdk-logs](#opentelemetrysdk-logs)
24
26
  * [@opentelemetry/sdk-metrics](#opentelemetrysdk-metrics)
25
27
  * [@opentelemetry/sdk-trace-base](#opentelemetrysdk-trace-base)
26
28
  * [@tyriar/fibonacci-heap](#tyriarfibonacci-heap)
@@ -95,7 +97,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
95
97
 
96
98
  ### @grpc/grpc-js
97
99
 
98
- This product includes source derived from [@grpc/grpc-js](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js) ([v1.13.3](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/tree/v1.13.3)), distributed under the [Apache-2.0 License](https://github.com/grpc/grpc-node/tree/master/packages/grpc-js/blob/v1.13.3/LICENSE):
100
+ 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):
99
101
 
100
102
  ```
101
103
  Apache License
@@ -555,6 +557,215 @@ This license terminates when the Software stops being provided by New Relic or w
555
557
  3. The Software may contain third-party software, including open source software (“OSS”). The third party software is governed by its own license and subject to its own terms, disclosed in the provided licensing information associated with the third party components. If a source code disclosure is required under the terms of the license covering any OSS component, the source code can be requested of New Relic by emailing opensource@newrelic.com.
556
558
 
557
559
 
560
+ ```
561
+
562
+ ### @opentelemetry/api-logs
563
+
564
+ This product includes source derived from [@opentelemetry/api-logs](https://github.com/open-telemetry/opentelemetry-js) ([v0.203.0](https://github.com/open-telemetry/opentelemetry-js/tree/v0.203.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v0.203.0/LICENSE):
565
+
566
+ ```
567
+ Apache License
568
+ Version 2.0, January 2004
569
+ http://www.apache.org/licenses/
570
+
571
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
572
+
573
+ 1. Definitions.
574
+
575
+ "License" shall mean the terms and conditions for use, reproduction,
576
+ and distribution as defined by Sections 1 through 9 of this document.
577
+
578
+ "Licensor" shall mean the copyright owner or entity authorized by
579
+ the copyright owner that is granting the License.
580
+
581
+ "Legal Entity" shall mean the union of the acting entity and all
582
+ other entities that control, are controlled by, or are under common
583
+ control with that entity. For the purposes of this definition,
584
+ "control" means (i) the power, direct or indirect, to cause the
585
+ direction or management of such entity, whether by contract or
586
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
587
+ outstanding shares, or (iii) beneficial ownership of such entity.
588
+
589
+ "You" (or "Your") shall mean an individual or Legal Entity
590
+ exercising permissions granted by this License.
591
+
592
+ "Source" form shall mean the preferred form for making modifications,
593
+ including but not limited to software source code, documentation
594
+ source, and configuration files.
595
+
596
+ "Object" form shall mean any form resulting from mechanical
597
+ transformation or translation of a Source form, including but
598
+ not limited to compiled object code, generated documentation,
599
+ and conversions to other media types.
600
+
601
+ "Work" shall mean the work of authorship, whether in Source or
602
+ Object form, made available under the License, as indicated by a
603
+ copyright notice that is included in or attached to the work
604
+ (an example is provided in the Appendix below).
605
+
606
+ "Derivative Works" shall mean any work, whether in Source or Object
607
+ form, that is based on (or derived from) the Work and for which the
608
+ editorial revisions, annotations, elaborations, or other modifications
609
+ represent, as a whole, an original work of authorship. For the purposes
610
+ of this License, Derivative Works shall not include works that remain
611
+ separable from, or merely link (or bind by name) to the interfaces of,
612
+ the Work and Derivative Works thereof.
613
+
614
+ "Contribution" shall mean any work of authorship, including
615
+ the original version of the Work and any modifications or additions
616
+ to that Work or Derivative Works thereof, that is intentionally
617
+ submitted to Licensor for inclusion in the Work by the copyright owner
618
+ or by an individual or Legal Entity authorized to submit on behalf of
619
+ the copyright owner. For the purposes of this definition, "submitted"
620
+ means any form of electronic, verbal, or written communication sent
621
+ to the Licensor or its representatives, including but not limited to
622
+ communication on electronic mailing lists, source code control systems,
623
+ and issue tracking systems that are managed by, or on behalf of, the
624
+ Licensor for the purpose of discussing and improving the Work, but
625
+ excluding communication that is conspicuously marked or otherwise
626
+ designated in writing by the copyright owner as "Not a Contribution."
627
+
628
+ "Contributor" shall mean Licensor and any individual or Legal Entity
629
+ on behalf of whom a Contribution has been received by Licensor and
630
+ subsequently incorporated within the Work.
631
+
632
+ 2. Grant of Copyright License. Subject to the terms and conditions of
633
+ this License, each Contributor hereby grants to You a perpetual,
634
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
635
+ copyright license to reproduce, prepare Derivative Works of,
636
+ publicly display, publicly perform, sublicense, and distribute the
637
+ Work and such Derivative Works in Source or Object form.
638
+
639
+ 3. Grant of Patent License. Subject to the terms and conditions of
640
+ this License, each Contributor hereby grants to You a perpetual,
641
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
642
+ (except as stated in this section) patent license to make, have made,
643
+ use, offer to sell, sell, import, and otherwise transfer the Work,
644
+ where such license applies only to those patent claims licensable
645
+ by such Contributor that are necessarily infringed by their
646
+ Contribution(s) alone or by combination of their Contribution(s)
647
+ with the Work to which such Contribution(s) was submitted. If You
648
+ institute patent litigation against any entity (including a
649
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
650
+ or a Contribution incorporated within the Work constitutes direct
651
+ or contributory patent infringement, then any patent licenses
652
+ granted to You under this License for that Work shall terminate
653
+ as of the date such litigation is filed.
654
+
655
+ 4. Redistribution. You may reproduce and distribute copies of the
656
+ Work or Derivative Works thereof in any medium, with or without
657
+ modifications, and in Source or Object form, provided that You
658
+ meet the following conditions:
659
+
660
+ (a) You must give any other recipients of the Work or
661
+ Derivative Works a copy of this License; and
662
+
663
+ (b) You must cause any modified files to carry prominent notices
664
+ stating that You changed the files; and
665
+
666
+ (c) You must retain, in the Source form of any Derivative Works
667
+ that You distribute, all copyright, patent, trademark, and
668
+ attribution notices from the Source form of the Work,
669
+ excluding those notices that do not pertain to any part of
670
+ the Derivative Works; and
671
+
672
+ (d) If the Work includes a "NOTICE" text file as part of its
673
+ distribution, then any Derivative Works that You distribute must
674
+ include a readable copy of the attribution notices contained
675
+ within such NOTICE file, excluding those notices that do not
676
+ pertain to any part of the Derivative Works, in at least one
677
+ of the following places: within a NOTICE text file distributed
678
+ as part of the Derivative Works; within the Source form or
679
+ documentation, if provided along with the Derivative Works; or,
680
+ within a display generated by the Derivative Works, if and
681
+ wherever such third-party notices normally appear. The contents
682
+ of the NOTICE file are for informational purposes only and
683
+ do not modify the License. You may add Your own attribution
684
+ notices within Derivative Works that You distribute, alongside
685
+ or as an addendum to the NOTICE text from the Work, provided
686
+ that such additional attribution notices cannot be construed
687
+ as modifying the License.
688
+
689
+ You may add Your own copyright statement to Your modifications and
690
+ may provide additional or different license terms and conditions
691
+ for use, reproduction, or distribution of Your modifications, or
692
+ for any such Derivative Works as a whole, provided Your use,
693
+ reproduction, and distribution of the Work otherwise complies with
694
+ the conditions stated in this License.
695
+
696
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
697
+ any Contribution intentionally submitted for inclusion in the Work
698
+ by You to the Licensor shall be under the terms and conditions of
699
+ this License, without any additional terms or conditions.
700
+ Notwithstanding the above, nothing herein shall supersede or modify
701
+ the terms of any separate license agreement you may have executed
702
+ with Licensor regarding such Contributions.
703
+
704
+ 6. Trademarks. This License does not grant permission to use the trade
705
+ names, trademarks, service marks, or product names of the Licensor,
706
+ except as required for reasonable and customary use in describing the
707
+ origin of the Work and reproducing the content of the NOTICE file.
708
+
709
+ 7. Disclaimer of Warranty. Unless required by applicable law or
710
+ agreed to in writing, Licensor provides the Work (and each
711
+ Contributor provides its Contributions) on an "AS IS" BASIS,
712
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
713
+ implied, including, without limitation, any warranties or conditions
714
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
715
+ PARTICULAR PURPOSE. You are solely responsible for determining the
716
+ appropriateness of using or redistributing the Work and assume any
717
+ risks associated with Your exercise of permissions under this License.
718
+
719
+ 8. Limitation of Liability. In no event and under no legal theory,
720
+ whether in tort (including negligence), contract, or otherwise,
721
+ unless required by applicable law (such as deliberate and grossly
722
+ negligent acts) or agreed to in writing, shall any Contributor be
723
+ liable to You for damages, including any direct, indirect, special,
724
+ incidental, or consequential damages of any character arising as a
725
+ result of this License or out of the use or inability to use the
726
+ Work (including but not limited to damages for loss of goodwill,
727
+ work stoppage, computer failure or malfunction, or any and all
728
+ other commercial damages or losses), even if such Contributor
729
+ has been advised of the possibility of such damages.
730
+
731
+ 9. Accepting Warranty or Additional Liability. While redistributing
732
+ the Work or Derivative Works thereof, You may choose to offer,
733
+ and charge a fee for, acceptance of support, warranty, indemnity,
734
+ or other liability obligations and/or rights consistent with this
735
+ License. However, in accepting such obligations, You may act only
736
+ on Your own behalf and on Your sole responsibility, not on behalf
737
+ of any other Contributor, and only if You agree to indemnify,
738
+ defend, and hold each Contributor harmless for any liability
739
+ incurred by, or claims asserted against, such Contributor by reason
740
+ of your accepting any such warranty or additional liability.
741
+
742
+ END OF TERMS AND CONDITIONS
743
+
744
+ APPENDIX: How to apply the Apache License to your work.
745
+
746
+ To apply the Apache License to your work, attach the following
747
+ boilerplate notice, with the fields enclosed by brackets "[]"
748
+ replaced with your own identifying information. (Don't include
749
+ the brackets!) The text should be enclosed in the appropriate
750
+ comment syntax for the file format. We also recommend that a
751
+ file or class name and description of purpose be included on the
752
+ same "printed page" as the copyright notice for easier
753
+ identification within third-party archives.
754
+
755
+ Copyright [yyyy] [name of copyright owner]
756
+
757
+ Licensed under the Apache License, Version 2.0 (the "License");
758
+ you may not use this file except in compliance with the License.
759
+ You may obtain a copy of the License at
760
+
761
+ http://www.apache.org/licenses/LICENSE-2.0
762
+
763
+ Unless required by applicable law or agreed to in writing, software
764
+ distributed under the License is distributed on an "AS IS" BASIS,
765
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
766
+ See the License for the specific language governing permissions and
767
+ limitations under the License.
768
+
558
769
  ```
559
770
 
560
771
  ### @opentelemetry/api
@@ -1393,6 +1604,215 @@ This product includes source derived from [@opentelemetry/resources](https://git
1393
1604
 
1394
1605
  ```
1395
1606
 
1607
+ ### @opentelemetry/sdk-logs
1608
+
1609
+ This product includes source derived from [@opentelemetry/sdk-logs](https://github.com/open-telemetry/opentelemetry-js) ([v0.203.0](https://github.com/open-telemetry/opentelemetry-js/tree/v0.203.0)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v0.203.0/LICENSE):
1610
+
1611
+ ```
1612
+ Apache License
1613
+ Version 2.0, January 2004
1614
+ http://www.apache.org/licenses/
1615
+
1616
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1617
+
1618
+ 1. Definitions.
1619
+
1620
+ "License" shall mean the terms and conditions for use, reproduction,
1621
+ and distribution as defined by Sections 1 through 9 of this document.
1622
+
1623
+ "Licensor" shall mean the copyright owner or entity authorized by
1624
+ the copyright owner that is granting the License.
1625
+
1626
+ "Legal Entity" shall mean the union of the acting entity and all
1627
+ other entities that control, are controlled by, or are under common
1628
+ control with that entity. For the purposes of this definition,
1629
+ "control" means (i) the power, direct or indirect, to cause the
1630
+ direction or management of such entity, whether by contract or
1631
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
1632
+ outstanding shares, or (iii) beneficial ownership of such entity.
1633
+
1634
+ "You" (or "Your") shall mean an individual or Legal Entity
1635
+ exercising permissions granted by this License.
1636
+
1637
+ "Source" form shall mean the preferred form for making modifications,
1638
+ including but not limited to software source code, documentation
1639
+ source, and configuration files.
1640
+
1641
+ "Object" form shall mean any form resulting from mechanical
1642
+ transformation or translation of a Source form, including but
1643
+ not limited to compiled object code, generated documentation,
1644
+ and conversions to other media types.
1645
+
1646
+ "Work" shall mean the work of authorship, whether in Source or
1647
+ Object form, made available under the License, as indicated by a
1648
+ copyright notice that is included in or attached to the work
1649
+ (an example is provided in the Appendix below).
1650
+
1651
+ "Derivative Works" shall mean any work, whether in Source or Object
1652
+ form, that is based on (or derived from) the Work and for which the
1653
+ editorial revisions, annotations, elaborations, or other modifications
1654
+ represent, as a whole, an original work of authorship. For the purposes
1655
+ of this License, Derivative Works shall not include works that remain
1656
+ separable from, or merely link (or bind by name) to the interfaces of,
1657
+ the Work and Derivative Works thereof.
1658
+
1659
+ "Contribution" shall mean any work of authorship, including
1660
+ the original version of the Work and any modifications or additions
1661
+ to that Work or Derivative Works thereof, that is intentionally
1662
+ submitted to Licensor for inclusion in the Work by the copyright owner
1663
+ or by an individual or Legal Entity authorized to submit on behalf of
1664
+ the copyright owner. For the purposes of this definition, "submitted"
1665
+ means any form of electronic, verbal, or written communication sent
1666
+ to the Licensor or its representatives, including but not limited to
1667
+ communication on electronic mailing lists, source code control systems,
1668
+ and issue tracking systems that are managed by, or on behalf of, the
1669
+ Licensor for the purpose of discussing and improving the Work, but
1670
+ excluding communication that is conspicuously marked or otherwise
1671
+ designated in writing by the copyright owner as "Not a Contribution."
1672
+
1673
+ "Contributor" shall mean Licensor and any individual or Legal Entity
1674
+ on behalf of whom a Contribution has been received by Licensor and
1675
+ subsequently incorporated within the Work.
1676
+
1677
+ 2. Grant of Copyright License. Subject to the terms and conditions of
1678
+ this License, each Contributor hereby grants to You a perpetual,
1679
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1680
+ copyright license to reproduce, prepare Derivative Works of,
1681
+ publicly display, publicly perform, sublicense, and distribute the
1682
+ Work and such Derivative Works in Source or Object form.
1683
+
1684
+ 3. Grant of Patent License. Subject to the terms and conditions of
1685
+ this License, each Contributor hereby grants to You a perpetual,
1686
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1687
+ (except as stated in this section) patent license to make, have made,
1688
+ use, offer to sell, sell, import, and otherwise transfer the Work,
1689
+ where such license applies only to those patent claims licensable
1690
+ by such Contributor that are necessarily infringed by their
1691
+ Contribution(s) alone or by combination of their Contribution(s)
1692
+ with the Work to which such Contribution(s) was submitted. If You
1693
+ institute patent litigation against any entity (including a
1694
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
1695
+ or a Contribution incorporated within the Work constitutes direct
1696
+ or contributory patent infringement, then any patent licenses
1697
+ granted to You under this License for that Work shall terminate
1698
+ as of the date such litigation is filed.
1699
+
1700
+ 4. Redistribution. You may reproduce and distribute copies of the
1701
+ Work or Derivative Works thereof in any medium, with or without
1702
+ modifications, and in Source or Object form, provided that You
1703
+ meet the following conditions:
1704
+
1705
+ (a) You must give any other recipients of the Work or
1706
+ Derivative Works a copy of this License; and
1707
+
1708
+ (b) You must cause any modified files to carry prominent notices
1709
+ stating that You changed the files; and
1710
+
1711
+ (c) You must retain, in the Source form of any Derivative Works
1712
+ that You distribute, all copyright, patent, trademark, and
1713
+ attribution notices from the Source form of the Work,
1714
+ excluding those notices that do not pertain to any part of
1715
+ the Derivative Works; and
1716
+
1717
+ (d) If the Work includes a "NOTICE" text file as part of its
1718
+ distribution, then any Derivative Works that You distribute must
1719
+ include a readable copy of the attribution notices contained
1720
+ within such NOTICE file, excluding those notices that do not
1721
+ pertain to any part of the Derivative Works, in at least one
1722
+ of the following places: within a NOTICE text file distributed
1723
+ as part of the Derivative Works; within the Source form or
1724
+ documentation, if provided along with the Derivative Works; or,
1725
+ within a display generated by the Derivative Works, if and
1726
+ wherever such third-party notices normally appear. The contents
1727
+ of the NOTICE file are for informational purposes only and
1728
+ do not modify the License. You may add Your own attribution
1729
+ notices within Derivative Works that You distribute, alongside
1730
+ or as an addendum to the NOTICE text from the Work, provided
1731
+ that such additional attribution notices cannot be construed
1732
+ as modifying the License.
1733
+
1734
+ You may add Your own copyright statement to Your modifications and
1735
+ may provide additional or different license terms and conditions
1736
+ for use, reproduction, or distribution of Your modifications, or
1737
+ for any such Derivative Works as a whole, provided Your use,
1738
+ reproduction, and distribution of the Work otherwise complies with
1739
+ the conditions stated in this License.
1740
+
1741
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
1742
+ any Contribution intentionally submitted for inclusion in the Work
1743
+ by You to the Licensor shall be under the terms and conditions of
1744
+ this License, without any additional terms or conditions.
1745
+ Notwithstanding the above, nothing herein shall supersede or modify
1746
+ the terms of any separate license agreement you may have executed
1747
+ with Licensor regarding such Contributions.
1748
+
1749
+ 6. Trademarks. This License does not grant permission to use the trade
1750
+ names, trademarks, service marks, or product names of the Licensor,
1751
+ except as required for reasonable and customary use in describing the
1752
+ origin of the Work and reproducing the content of the NOTICE file.
1753
+
1754
+ 7. Disclaimer of Warranty. Unless required by applicable law or
1755
+ agreed to in writing, Licensor provides the Work (and each
1756
+ Contributor provides its Contributions) on an "AS IS" BASIS,
1757
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1758
+ implied, including, without limitation, any warranties or conditions
1759
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1760
+ PARTICULAR PURPOSE. You are solely responsible for determining the
1761
+ appropriateness of using or redistributing the Work and assume any
1762
+ risks associated with Your exercise of permissions under this License.
1763
+
1764
+ 8. Limitation of Liability. In no event and under no legal theory,
1765
+ whether in tort (including negligence), contract, or otherwise,
1766
+ unless required by applicable law (such as deliberate and grossly
1767
+ negligent acts) or agreed to in writing, shall any Contributor be
1768
+ liable to You for damages, including any direct, indirect, special,
1769
+ incidental, or consequential damages of any character arising as a
1770
+ result of this License or out of the use or inability to use the
1771
+ Work (including but not limited to damages for loss of goodwill,
1772
+ work stoppage, computer failure or malfunction, or any and all
1773
+ other commercial damages or losses), even if such Contributor
1774
+ has been advised of the possibility of such damages.
1775
+
1776
+ 9. Accepting Warranty or Additional Liability. While redistributing
1777
+ the Work or Derivative Works thereof, You may choose to offer,
1778
+ and charge a fee for, acceptance of support, warranty, indemnity,
1779
+ or other liability obligations and/or rights consistent with this
1780
+ License. However, in accepting such obligations, You may act only
1781
+ on Your own behalf and on Your sole responsibility, not on behalf
1782
+ of any other Contributor, and only if You agree to indemnify,
1783
+ defend, and hold each Contributor harmless for any liability
1784
+ incurred by, or claims asserted against, such Contributor by reason
1785
+ of your accepting any such warranty or additional liability.
1786
+
1787
+ END OF TERMS AND CONDITIONS
1788
+
1789
+ APPENDIX: How to apply the Apache License to your work.
1790
+
1791
+ To apply the Apache License to your work, attach the following
1792
+ boilerplate notice, with the fields enclosed by brackets "[]"
1793
+ replaced with your own identifying information. (Don't include
1794
+ the brackets!) The text should be enclosed in the appropriate
1795
+ comment syntax for the file format. We also recommend that a
1796
+ file or class name and description of purpose be included on the
1797
+ same "printed page" as the copyright notice for easier
1798
+ identification within third-party archives.
1799
+
1800
+ Copyright [yyyy] [name of copyright owner]
1801
+
1802
+ Licensed under the Apache License, Version 2.0 (the "License");
1803
+ you may not use this file except in compliance with the License.
1804
+ You may obtain a copy of the License at
1805
+
1806
+ http://www.apache.org/licenses/LICENSE-2.0
1807
+
1808
+ Unless required by applicable law or agreed to in writing, software
1809
+ distributed under the License is distributed on an "AS IS" BASIS,
1810
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1811
+ See the License for the specific language governing permissions and
1812
+ limitations under the License.
1813
+
1814
+ ```
1815
+
1396
1816
  ### @opentelemetry/sdk-metrics
1397
1817
 
1398
1818
  This product includes source derived from [@opentelemetry/sdk-metrics](https://github.com/open-telemetry/opentelemetry-js) ([v2.0.1](https://github.com/open-telemetry/opentelemetry-js/tree/v2.0.1)), distributed under the [Apache-2.0 License](https://github.com/open-telemetry/opentelemetry-js/blob/v2.0.1/LICENSE):
@@ -1902,7 +2322,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1902
2322
 
1903
2323
  ### import-in-the-middle
1904
2324
 
1905
- This product includes source derived from [import-in-the-middle](https://github.com/nodejs/import-in-the-middle) ([v1.13.2](https://github.com/nodejs/import-in-the-middle/tree/v1.13.2)), distributed under the [Apache-2.0 License](https://github.com/nodejs/import-in-the-middle/blob/v1.13.2/LICENSE):
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):
1906
2326
 
1907
2327
  ```
1908
2328
  Apache License
@@ -2333,7 +2753,7 @@ SOFTWARE.
2333
2753
 
2334
2754
  ### @aws-sdk/client-s3
2335
2755
 
2336
- This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.808.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.808.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.808.0/LICENSE):
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):
2337
2757
 
2338
2758
  ```
2339
2759
  Apache License
@@ -2542,7 +2962,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co
2542
2962
 
2543
2963
  ### @aws-sdk/s3-request-presigner
2544
2964
 
2545
- This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.808.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.808.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.808.0/LICENSE):
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):
2546
2966
 
2547
2967
  ```
2548
2968
  Apache License
@@ -4370,7 +4790,7 @@ SOFTWARE.
4370
4790
 
4371
4791
  ### eslint-plugin-jsdoc
4372
4792
 
4373
- This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v50.6.14](https://github.com/gajus/eslint-plugin-jsdoc/tree/v50.6.14)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v50.6.14/LICENSE):
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):
4374
4794
 
4375
4795
  ```
4376
4796
  Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/)
@@ -4402,7 +4822,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4402
4822
 
4403
4823
  ### eslint
4404
4824
 
4405
- This product includes source derived from [eslint](https://github.com/eslint/eslint) ([v9.26.0](https://github.com/eslint/eslint/tree/v9.26.0)), distributed under the [MIT License](https://github.com/eslint/eslint/blob/v9.26.0/LICENSE):
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):
4406
4826
 
4407
4827
  ```
4408
4828
  Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
package/index.js CHANGED
@@ -26,6 +26,10 @@ logger.info(
26
26
  pkgJSON.version,
27
27
  process.version
28
28
  )
29
+ const path = require('node:path')
30
+ const Module = require('node:module')
31
+ const otelPackages = Object.keys(pkgJSON.dependencies).filter(d => d.startsWith('@opentelemetry'))
32
+ const otelRequire = Module.createRequire(path.join(__dirname, __filename))
29
33
 
30
34
  if (require.cache.__NR_cache) {
31
35
  logger.warn(
@@ -40,14 +44,15 @@ if (require.cache.__NR_cache) {
40
44
  initialize()
41
45
  }
42
46
 
43
- function initApi({ agent, apiPath }) {
44
- const API = require(`./${apiPath}`)
47
+ function initApi({ agent }) {
48
+ const API = agent != null ? require('./api.js') : require('./stub_api.js')
45
49
 
46
50
  const api = new API(agent)
47
51
  require.cache.__NR_cache = module.exports = api
48
52
  return api
49
53
  }
50
54
 
55
+ // eslint-disable-next-line sonarjs/cognitive-complexity
51
56
  function initialize() {
52
57
  logger.debug('Loading agent from %s', __dirname)
53
58
  let agent = null
@@ -97,6 +102,10 @@ function initialize() {
97
102
  logger.warn(
98
103
  'New Relic for Node.js in worker_threads is not officially supported. Not starting! To bypass this, set `config.worker_threads.enabled` to true in configuration.'
99
104
  )
105
+ } else if (config.opentelemetry_bridge.enabled === true && otelBridgeAvailable() === false) {
106
+ logger.warn(
107
+ 'OpenTelemetry bridge enabled, but packages are missing. Not starting!'
108
+ )
100
109
  } else {
101
110
  if (!isMainThread && config.worker_threads.enabled) {
102
111
  logger.warn(
@@ -114,7 +123,7 @@ function initialize() {
114
123
  console.error(error.stack)
115
124
  }
116
125
 
117
- const api = agent ? initApi({ agent, apiPath: 'api' }) : initApi({ apiPath: 'stub_api' })
126
+ const api = initApi({ agent })
118
127
 
119
128
  // If we loaded an agent, record a startup time for the agent.
120
129
  // NOTE: Metrics are recorded in seconds, so divide the value by 1000.
@@ -191,6 +200,7 @@ function addStartupSupportabilities(agent) {
191
200
  recordNodeVersionMetric(agent)
192
201
  recordFeatureFlagMetrics(agent)
193
202
  recordSourceMapMetric(agent)
203
+ recordDisabledPackages(agent)
194
204
  }
195
205
 
196
206
  /**
@@ -265,3 +275,28 @@ function recordSourceMapMetric(agent) {
265
275
  agent.metrics.getOrCreateMetric(NAMES.FEATURES.SOURCE_MAPS).incrementCallCount()
266
276
  }
267
277
  }
278
+
279
+ /**
280
+ * Records supportability metrics for disabled instrumentation packages.
281
+ * @param {Agent} agent active NR agent
282
+ */
283
+ function recordDisabledPackages(agent) {
284
+ for (const [pkg, config] of Object.entries(agent.config.instrumentation)) {
285
+ if (config.enabled === false) {
286
+ agent.recordSupportability(`Nodejs/Instrumentation/${pkg}/disabled`)
287
+ }
288
+ }
289
+ }
290
+
291
+ function otelBridgeAvailable() {
292
+ for (const p of otelPackages) {
293
+ try {
294
+ otelRequire.resolve(p)
295
+ } catch (error) {
296
+ if (error.code === 'ERR_MODULE_NOT_FOUND') {
297
+ return false
298
+ }
299
+ }
300
+ }
301
+ return true
302
+ }
package/lib/agent.js CHANGED
@@ -112,6 +112,13 @@ const DEFAULT_HARVEST_INTERVAL_MS = 60000
112
112
  * @event Agent#otelMetricsBootstrapped
113
113
  */
114
114
 
115
+ /**
116
+ * Indicates that the OpenTelemetry logs API has been configured and is
117
+ * ready for use.
118
+ *
119
+ * @event Agent#otelLogsBootstrapped
120
+ */
121
+
115
122
  /**
116
123
  * Indicates that the agent state has entered the "started" state. That is,
117
124
  * the agent has finished bootstrapping and is collecting and sending data.
@@ -1722,6 +1722,18 @@ defaultConfig.definition = () => ({
1722
1722
  enabled: { default: false, formatter: boolean }
1723
1723
  },
1724
1724
 
1725
+ /**
1726
+ * `logs` governs automatic configuration of the OpenTelemetry logs API.
1727
+ * When true, the agent will automatically configure the logs API to send
1728
+ * logs emitted through the OTEL specific API to New Relic.
1729
+ *
1730
+ * This feature is dependent on application logs forwarding. Thus,
1731
+ * application logs forwarding must be enabled as well.
1732
+ */
1733
+ logs: {
1734
+ enabled: { default: false, formatter: boolean }
1735
+ },
1736
+
1725
1737
  /**
1726
1738
  * `metrics` governs automatic configuration of the OpenTelemetry
1727
1739
  * metrics API. When `true`, the agent will automatically configure the
@@ -11,7 +11,6 @@ const urltils = require('../../util/urltils')
11
11
  const logger = require('../../logger').child({ component: 'outbound' })
12
12
  const shimmer = require('../../shimmer')
13
13
  const url = require('url')
14
- const copy = require('../../util/copy')
15
14
  const symbols = require('../../symbols')
16
15
  const synthetics = require('../../synthetics')
17
16
  const { URL } = require('node:url')
@@ -57,24 +56,6 @@ function getDefaultHostName(opts) {
57
56
  return opts.hostname || opts.host || DEFAULT_HOST
58
57
  }
59
58
 
60
- /**
61
- * Parses http opts to an object
62
- * If string will call url.parse, otherwise it will
63
- * do a shallow copy
64
- *
65
- * @param {string|object} opts a url string or HTTP request options
66
- * @returns {object} parsed http opts
67
- */
68
- function parseOpts(opts) {
69
- if (typeof opts === 'string') {
70
- opts = url.parse(opts)
71
- } else {
72
- opts = copy.shallow(opts)
73
- }
74
-
75
- return opts
76
- }
77
-
78
59
  /**
79
60
  * Extracts host, hostname, port from http request options
80
61
  *
@@ -122,8 +103,6 @@ function extractHostPortViaProxy(opts) {
122
103
  * @returns {object} The instrumented outbound HTTP request.
123
104
  */
124
105
  module.exports = function instrumentOutbound(agent, opts, makeRequest) {
125
- opts = parseOpts(opts)
126
-
127
106
  const viaProxy = extractHostPortViaProxy(opts)
128
107
  const { host, hostname, port } = viaProxy ? viaProxy : extractHostPort(opts)
129
108
 
@@ -265,23 +244,29 @@ function assignOutgoingHeaders(currentHeaders, outboundHeaders) {
265
244
  function applySegment({ opts, makeRequest, host, port, hostname, segment, config }) {
266
245
  segment.start()
267
246
  const request = makeRequest(opts)
268
- const parsed = urltils.scrubAndParseParameters(request.path)
269
- parsed.path = urltils.obfuscatePath(config, parsed.path)
247
+
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)
255
+
270
256
  const proto = parsed.protocol || opts.protocol || 'http:'
271
- segment.name += parsed.path
257
+ segment.name += obfuscatedPath
272
258
  segment.captureExternalAttributes({
273
259
  protocol: proto,
274
260
  hostname,
275
261
  host,
276
262
  method: opts.method,
277
263
  port,
278
- path: parsed.path,
264
+ path: obfuscatedPath,
279
265
  queryParams: parsed.parameters
280
266
  })
281
267
  request[symbols.segment] = segment
282
268
  return request
283
269
  }
284
-
285
270
  /**
286
271
  * Wrap the emit method. We're doing a special wrapper instead of using
287
272
  * `tracer.bindEmitter` because we want to do some logic based on certain
@@ -0,0 +1,84 @@
1
+ /*
2
+ * Copyright 2025 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ module.exports = bootstrapOtelLogs
9
+
10
+ const logsApi = require('@opentelemetry/api-logs')
11
+ const logsSdk = require('@opentelemetry/sdk-logs')
12
+ const defaultLogger = require('#agentlib/logger.js').child({ component: 'otel-logs' })
13
+ const {
14
+ isApplicationLoggingEnabled,
15
+ isLogForwardingEnabled,
16
+ isMetricsEnabled,
17
+ incrementLoggingLinesMetrics
18
+ } = require('#agentlib/util/application-logging.js')
19
+
20
+ const NewRelicLoggerProvider = require('./proxying-provider.js')
21
+ const NoOpExporter = require('./no-op-exporter.js')
22
+ const normalizeTimestamp = require('./normalize-timestamp.js')
23
+ const severityToString = require('./severity-to-string.js')
24
+
25
+ /**
26
+ * Sets up the OTEL logging system and instruments it in such a fashion
27
+ * that logs are shipped to New Relic when logs forwarding is enabled.
28
+ *
29
+ * The API, as of 2025-07, is in development. We should expect changes that
30
+ * will require significant refactoring here. For example, we might need to
31
+ * accept instances of various components, e.g. record processors, in order
32
+ * for customer apps to work as they expect.
33
+ *
34
+ * @param {object} params Factory function parameters.
35
+ * @param {Agent} params.agent The Node.js agent instance.
36
+ * @param {object} [params.logger] An agent logger instance.
37
+ */
38
+ function bootstrapOtelLogs({ agent, logger = defaultLogger } = {}) {
39
+ if (isApplicationLoggingEnabled(agent.config) === false) {
40
+ logger.info('application logging disabled, skipping otel logs setup')
41
+ return
42
+ }
43
+
44
+ agent.metrics
45
+ .getOrCreateMetric('Supportability/Nodejs/OpenTelemetryBridge/Logs')
46
+ .incrementCallCount()
47
+
48
+ const exporter = new NoOpExporter()
49
+ const processor = new logsSdk.BatchLogRecordProcessor(exporter)
50
+ const otelProvider = new logsSdk.LoggerProvider({
51
+ processors: [processor]
52
+ })
53
+ const provider = new NewRelicLoggerProvider({
54
+ agent,
55
+ provider: otelProvider,
56
+ emitHandler: nrEmitHandler
57
+ })
58
+ logsApi.logs.setGlobalLoggerProvider(provider)
59
+
60
+ function nrEmitHandler(record) {
61
+ const level = severityToString(record.severityNumber ?? 0)
62
+ if (isMetricsEnabled(agent.config) === true) {
63
+ incrementLoggingLinesMetrics(level, agent.metrics)
64
+ }
65
+
66
+ // TODO: if we decide to support local decorating, implement it here
67
+
68
+ if (isLogForwardingEnabled(agent.config, agent) === true) {
69
+ const meta = agent.getLinkingMetadata(true)
70
+ const timestamp = normalizeTimestamp(record.timestamp)
71
+ const logData = {
72
+ message: record.body,
73
+ level,
74
+ timestamp,
75
+ ...record.attributes,
76
+ ...meta
77
+ }
78
+
79
+ agent.logs.add(logData)
80
+ }
81
+ }
82
+
83
+ agent.emit('otelLogsBootstrapped')
84
+ }
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright 2025 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const { ExportResultCode } = require('@opentelemetry/core')
9
+
10
+ /**
11
+ * @see https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_sdk-node.logs.LogRecordExporter.html
12
+ */
13
+ class NewRelicNoOpExporter {
14
+ export(_, done) {
15
+ if (typeof done === 'function') {
16
+ done(ExportResultCode.SUCCESS)
17
+ }
18
+ }
19
+
20
+ shutdown() {
21
+ return Promise.resolve()
22
+ }
23
+ }
24
+
25
+ module.exports = NewRelicNoOpExporter
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright 2025 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ module.exports = normalizeTimestamp
9
+
10
+ const {
11
+ isTimeInputHrTime
12
+ } = require('@opentelemetry/core')
13
+
14
+ /**
15
+ * Returns a normalized epoch in milliseconds based upon the value provided
16
+ * to the logger's `emit` method (if it was provided). The emit method receives
17
+ * a `LogRecord` instance. In the upstream code, a `LogRecord` is supposed to
18
+ * have a nanosecond epoch delta. But we are receiving it from user code. So
19
+ * it is possible for the value to be a variety of different kinds.
20
+ *
21
+ * @see https://github.com/open-telemetry/opentelemetry-js/blob/99dde77/api/src/common/Time.ts#L39
22
+ * @see https://github.com/open-telemetry/opentelemetry-js/blob/99dde77/packages/opentelemetry-core/src/common/time.ts#L61-L83
23
+ *
24
+ * @param {number[]|number|Date|undefined} input The value from the logger.
25
+ *
26
+ * @returns {number}
27
+ */
28
+ function normalizeTimestamp(input) {
29
+ if (typeof input === 'number' && input >= 10_000_000_000_000_000) {
30
+ // Looks like a nanosecond epoch delta.
31
+ return Math.floor(input / 1_000_000)
32
+ }
33
+
34
+ if (typeof input === 'number' && input >= 100_000_000_000_000) {
35
+ // Looks like a microsecond epoch delta.
36
+ return Math.floor(input / 1_000)
37
+ }
38
+
39
+ if (typeof input === 'number' && input >= 100_000_000_000) {
40
+ // Looks like a millisecond epoch delta.
41
+ return input
42
+ }
43
+
44
+ if (isTimeInputHrTime(input) === true) {
45
+ // It's unclear why upstream tries to support a `process.hrtime()` value.
46
+ // Such tuples are relative to an arbitrary point in time, not the Unix
47
+ // epoch. So there's no way to determine an actual wall clock time and date
48
+ // from such input. For lack of a better solution, we'll return the
49
+ // current epoch in this case.
50
+ return Date.now()
51
+ }
52
+
53
+ if (Object.getPrototypeOf(input) === Date.prototype) {
54
+ return input.getTime()
55
+ }
56
+
57
+ // We don't know what they've given us, so just return the current time.
58
+ return Date.now()
59
+ }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright 2025 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ const symLogPatched = Symbol('nr.log.patched')
9
+
10
+ /**
11
+ * Provides a logger provider that proxies to another logger provider.
12
+ * This allows us to intercept loggers as they are retrieved so that we can
13
+ * patch their `emit` method to do what we need.
14
+ *
15
+ * @see https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api-logs.LoggerProvider.html
16
+ */
17
+ class NewRelicLoggerProvider {
18
+ #provider
19
+ #emitHandler
20
+
21
+ constructor({ provider, emitHandler }) {
22
+ this.#provider = provider
23
+ this.#emitHandler = emitHandler
24
+ }
25
+
26
+ getLogger(name, version, options) {
27
+ const logger = this.#provider.getLogger(name, version, options)
28
+ const emit = logger.emit
29
+ const handler = this.#emitHandler
30
+
31
+ // Logger has already been patched, so just return it.
32
+ if (logger[symLogPatched] === true) {
33
+ return logger
34
+ }
35
+
36
+ logger.emit = function nrEmitWrapper(record) {
37
+ handler(record)
38
+ return emit.apply(this, arguments)
39
+ }
40
+
41
+ logger[symLogPatched] = true
42
+ return logger
43
+ }
44
+ }
45
+
46
+ module.exports = NewRelicLoggerProvider
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright 2025 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ 'use strict'
7
+
8
+ module.exports = severityToString
9
+
10
+ const SEV_UNKNOWN = 'unknown'
11
+ const SEV_TRACE = 'trace'
12
+ const SEV_DEBUG = 'debug'
13
+ const SEV_INFO = 'info'
14
+ const SEV_WARN = 'warn'
15
+ const SEV_ERROR = 'error'
16
+ const SEV_FATAL = 'fatal'
17
+ const severityMap = new Map([
18
+ [0, SEV_UNKNOWN],
19
+ [1, SEV_TRACE],
20
+ [2, SEV_TRACE],
21
+ [3, SEV_TRACE],
22
+ [4, SEV_TRACE],
23
+ [5, SEV_DEBUG],
24
+ [6, SEV_DEBUG],
25
+ [7, SEV_DEBUG],
26
+ [8, SEV_DEBUG],
27
+ [9, SEV_INFO],
28
+ [10, SEV_INFO],
29
+ [11, SEV_INFO],
30
+ [12, SEV_INFO],
31
+ [13, SEV_WARN],
32
+ [14, SEV_WARN],
33
+ [15, SEV_WARN],
34
+ [16, SEV_WARN],
35
+ [17, SEV_ERROR],
36
+ [18, SEV_ERROR],
37
+ [19, SEV_ERROR],
38
+ [20, SEV_ERROR],
39
+ [21, SEV_FATAL],
40
+ [22, SEV_FATAL],
41
+ [23, SEV_FATAL],
42
+ [24, SEV_FATAL]
43
+ ])
44
+
45
+ /**
46
+ * Converts the OTEL severity number to a recognizable string.
47
+ *
48
+ * @see https://github.com/open-telemetry/opentelemetry-specification/blob/c041658/specification/logs/data-model.md?plain=1#L292-L299
49
+ *
50
+ * @param {number} severityNumber The number to convert.
51
+ *
52
+ * @returns {string} The known string.
53
+ */
54
+ function severityToString(severityNumber) {
55
+ return severityMap.get(severityNumber) ?? SEV_UNKNOWN
56
+ }
package/lib/otel/setup.js CHANGED
@@ -6,6 +6,7 @@
6
6
  'use strict'
7
7
 
8
8
  const opentelemetry = require('@opentelemetry/api')
9
+ const logsApi = require('@opentelemetry/api-logs')
9
10
  const { BasicTracerProvider } = require('@opentelemetry/sdk-trace-base')
10
11
 
11
12
  const NrSpanProcessor = require('./span-processor')
@@ -16,6 +17,7 @@ const defaultLogger = require('../logger').child({ component: 'opentelemetry-bri
16
17
  const createOtelLogger = require('./logger')
17
18
  const interceptSpanKey = require('./span-key-interceptor')
18
19
  const bootstrapMetrics = require('./metrics/bootstrap-metrics')
20
+ const bootstrapLogs = require('./logs/bootstrap-logs')
19
21
 
20
22
  function setupOtel(agent, logger = defaultLogger) {
21
23
  if (agent.config.opentelemetry_bridge.enabled !== true) {
@@ -25,8 +27,18 @@ function setupOtel(agent, logger = defaultLogger) {
25
27
  return
26
28
  }
27
29
 
30
+ // When bridge mode is enabled, our context manager must utilize the OTEL
31
+ // context manager. Otherwise, traces within, e.g. logs, will not be
32
+ // captured correctly. The internal OTEL logger also must be configured
33
+ // for the OTEL context manager to generate diagnostics messages that get
34
+ // delivered to the correct place.
35
+ createOtelLogger(logger, agent.config)
36
+ interceptSpanKey(agent)
37
+ opentelemetry.context.setGlobalContextManager(new ContextManager(agent))
38
+ opentelemetry.propagation.setGlobalPropagator(new TracePropagator(agent))
39
+
28
40
  if (agent.config.opentelemetry_bridge.traces.enabled === true) {
29
- bootstrapTraces(agent, logger)
41
+ bootstrapTraces(agent)
30
42
  } else {
31
43
  logger.debug('`opentelemetry_bridge.traces` is not enabled, skipping')
32
44
  }
@@ -37,14 +49,18 @@ function setupOtel(agent, logger = defaultLogger) {
37
49
  logger.debug('`opentelemetry_bridge.metrics` is not enabled, skipping')
38
50
  }
39
51
 
52
+ if (agent.config.opentelemetry_bridge.logs.enabled === true) {
53
+ bootstrapLogs({ agent })
54
+ } else {
55
+ logger.debug('`opentelemetry_bridge.logs` is not enabled, skipping')
56
+ }
57
+
40
58
  agent.metrics
41
59
  .getOrCreateMetric('Supportability/Nodejs/OpenTelemetryBridge/Setup')
42
60
  .incrementCallCount()
43
61
  }
44
62
 
45
- function bootstrapTraces(agent, logger) {
46
- createOtelLogger(logger, agent.config)
47
-
63
+ function bootstrapTraces(agent) {
48
64
  opentelemetry.trace.setGlobalTracerProvider(new BasicTracerProvider({
49
65
  sampler: new NrSampler(),
50
66
  spanProcessors: [new NrSpanProcessor(agent)],
@@ -53,10 +69,6 @@ function bootstrapTraces(agent, logger) {
53
69
  }
54
70
  }))
55
71
 
56
- interceptSpanKey(agent)
57
- opentelemetry.context.setGlobalContextManager(new ContextManager(agent))
58
- opentelemetry.propagation.setGlobalPropagator(new TracePropagator(agent))
59
-
60
72
  agent.metrics
61
73
  .getOrCreateMetric('Supportability/Nodejs/OpenTelemetryBridge/Traces')
62
74
  .incrementCallCount()
@@ -71,6 +83,7 @@ function teardownOtel(agent) {
71
83
  opentelemetry.context.disable()
72
84
  opentelemetry.propagation.disable()
73
85
  opentelemetry.diag.disable()
86
+ logsApi.logs.disable()
74
87
  }
75
88
 
76
89
  module.exports = {
@@ -409,7 +409,10 @@ function finalizeNameFromUri(requestURL, statusCode) {
409
409
  )
410
410
  }
411
411
 
412
- this.url = urltils.scrub(requestURL)
412
+ if (!this.agent.config.url_obfuscation.enabled) {
413
+ this.url = urltils.scrub(requestURL)
414
+ }
415
+
413
416
  this.statusCode = statusCode
414
417
  this.name = this.getFullName()
415
418
 
@@ -83,7 +83,7 @@ module.exports = {
83
83
  * 2. Strip off session trackers after ';' (a New Relic convention)
84
84
  * 3. Remove trailing slash.
85
85
  *
86
- * @param {string} requestURL The URL fragment to be scrubbed.
86
+ * @param {string|url.URL} requestURL The URL fragment to be scrubbed.
87
87
  * @returns {string} The cleaned URL.
88
88
  */
89
89
  scrub: function scrub(requestURL) {
@@ -116,28 +116,34 @@ module.exports = {
116
116
  * variable. Some web frameworks behave this way as well, so don't lose
117
117
  * information.
118
118
  *
119
- * @param {string} requestURL The URL to be parsed.
119
+ * @param {string|url.URL} requestURL The URL to be parsed.
120
120
  * @returns {object} The parameters parsed from the request
121
121
  */
122
122
  parseParameters: function parseParameters(requestURL) {
123
123
  let parsed = requestURL
124
+ const parameters = Object.create(null)
125
+
126
+ function addParam(key, value, raw) {
127
+ if (value === '' && raw.indexOf(key + '=') === -1) {
128
+ parameters[key] = true
129
+ } else {
130
+ parameters[key] = value
131
+ }
132
+ }
124
133
 
125
134
  if (typeof requestURL === 'string') {
126
135
  parsed = url.parse(requestURL, true)
127
136
  }
128
137
 
129
- const parameters = Object.create(null)
130
-
131
138
  if (parsed.query) {
132
- const keys = Object.keys(parsed.query)
139
+ for (const key of Object.keys(parsed.query)) {
140
+ addParam(key, parsed.query[key], parsed.path || '')
141
+ }
142
+ }
133
143
 
134
- for (let i = 0, l = keys.length; i < l; ++i) {
135
- const key = keys[i]
136
- if (parsed.query[key] === '' && parsed.path.indexOf(key + '=') === -1) {
137
- parameters[key] = true
138
- } else {
139
- parameters[key] = parsed.query[key]
140
- }
144
+ if (parsed.searchParams) {
145
+ for (const [key, value] of parsed.searchParams) {
146
+ addParam(key, value, parsed.pathname || '')
141
147
  }
142
148
  }
143
149
 
@@ -148,7 +154,7 @@ module.exports = {
148
154
  * Performs the logic of `urltils.scrub` and `urltils.parseParameters` with
149
155
  * only a single parse of the given URL.
150
156
  *
151
- * @param {string} requestURL - The URL to scrub and extra parameters from.
157
+ * @param {string|url.URL} requestURL - The URL to scrub and extra parameters from.
152
158
  * @returns {object} An object containing the scrubbed url at `.path` and the
153
159
  * parsed parameters at `.parameters`.
154
160
  */
package/newrelic.js CHANGED
@@ -22,6 +22,16 @@ exports.config = {
22
22
  */
23
23
  level: 'info'
24
24
  },
25
+ /**
26
+ * This provides instrumentation for `setTimeout` and `setInterval` calls.
27
+ * We recommend you disable this instrumentation as it does not not provide
28
+ * much value and creates a lot of unncessary TraceSegments/Span events.
29
+ */
30
+ instrumentation: {
31
+ timers: {
32
+ enabled: false
33
+ }
34
+ },
25
35
  /**
26
36
  * When true, all request headers except for those listed in attributes.exclude
27
37
  * will be captured for all traces, unless otherwise specified in a destination's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "13.0.0",
3
+ "version": "13.1.0",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -205,9 +205,11 @@
205
205
  "@grpc/proto-loader": "^0.7.5",
206
206
  "@newrelic/security-agent": "^2.4.2",
207
207
  "@opentelemetry/api": "^1.9.0",
208
+ "@opentelemetry/api-logs": "^0.203.0",
208
209
  "@opentelemetry/core": "^2.0.0",
209
210
  "@opentelemetry/exporter-metrics-otlp-proto": "^0.201.1",
210
211
  "@opentelemetry/resources": "^2.0.1",
212
+ "@opentelemetry/sdk-logs": "^0.203.0",
211
213
  "@opentelemetry/sdk-metrics": "^2.0.1",
212
214
  "@opentelemetry/sdk-trace-base": "^2.0.0",
213
215
  "@tyriar/fibonacci-heap": "^2.0.7",