From d45f93b703faa5ce7210b13ec7ba77aa32a77f00 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Thu, 15 Aug 2024 12:52:29 -0400 Subject: [PATCH] chore: Reverted to upstream require-in-the-middle --- THIRD_PARTY_NOTICES.md | 49 +++++++++--- lib/instrumentation/langchain/nr-hooks.js | 10 ++- lib/shimmer.js | 2 +- package.json | 2 +- third_party_manifest.json | 90 +++++++++++++---------- 5 files changed, 103 insertions(+), 50 deletions(-) diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 6e40a327cd..243ee0750b 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -26,6 +26,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic * [json-stringify-safe](#json-stringify-safe) * [module-details-from-path](#module-details-from-path) * [readable-stream](#readable-stream) +* [require-in-the-middle](#require-in-the-middle) * [semver](#semver) * [winston-transport](#winston-transport) @@ -541,7 +542,7 @@ SOFTWARE. ### @newrelic/security-agent -This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v1.4.0](https://github.com/newrelic/csec-node-agent/tree/v1.4.0)), distributed under the [UNKNOWN License](https://github.com/newrelic/csec-node-agent/blob/v1.4.0/LICENSE): +This product includes source derived from [@newrelic/security-agent](https://github.com/newrelic/csec-node-agent) ([v1.5.0](https://github.com/newrelic/csec-node-agent/tree/v1.5.0)), distributed under the [UNKNOWN License](https://github.com/newrelic/csec-node-agent/blob/v1.5.0/LICENSE): ``` ## New Relic Software License v1.0 @@ -676,7 +677,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ### import-in-the-middle -This product includes source derived from [import-in-the-middle](https://github.com/nodejs/import-in-the-middle) ([v1.9.1](https://github.com/nodejs/import-in-the-middle/tree/v1.9.1)), distributed under the [Apache-2.0 License](https://github.com/nodejs/import-in-the-middle/blob/v1.9.1/LICENSE): +This product includes source derived from [import-in-the-middle](https://github.com/nodejs/import-in-the-middle) ([v1.11.0](https://github.com/nodejs/import-in-the-middle/tree/v1.11.0)), distributed under the [Apache-2.0 License](https://github.com/nodejs/import-in-the-middle/blob/v1.11.0/LICENSE): ``` Apache License @@ -1018,6 +1019,36 @@ IN THE SOFTWARE. ``` +### require-in-the-middle + +This product includes source derived from [require-in-the-middle](https://github.com/elastic/require-in-the-middle) ([v7.4.0](https://github.com/elastic/require-in-the-middle/tree/v7.4.0)), distributed under the [MIT License](https://github.com/elastic/require-in-the-middle/blob/v7.4.0/LICENSE): + +``` +The MIT License (MIT) + +Copyright (c) 2016-2019, Thomas Watson Steen +Copyright (c) 2019-2023, Elasticsearch B.V. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +``` + ### semver This product includes source derived from [semver](https://github.com/npm/node-semver) ([v7.6.3](https://github.com/npm/node-semver/tree/v7.6.3)), distributed under the [ISC License](https://github.com/npm/node-semver/blob/v7.6.3/LICENSE): @@ -1076,7 +1107,7 @@ SOFTWARE. ### @aws-sdk/client-s3 -This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.616.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.616.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.616.0/LICENSE): +This product includes source derived from [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3) ([v3.631.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.631.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.631.0/LICENSE): ``` Apache License @@ -1285,7 +1316,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co ### @aws-sdk/s3-request-presigner -This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.616.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.616.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.616.0/LICENSE): +This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.631.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.631.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.631.0/LICENSE): ``` Apache License @@ -2179,7 +2210,7 @@ THE SOFTWARE. ### @slack/bolt -This product includes source derived from [@slack/bolt](https://github.com/slackapi/bolt) ([v3.19.0](https://github.com/slackapi/bolt/tree/v3.19.0)), distributed under the [MIT License](https://github.com/slackapi/bolt/blob/v3.19.0/LICENSE): +This product includes source derived from [@slack/bolt](https://github.com/slackapi/bolt) ([v3.21.0](https://github.com/slackapi/bolt/tree/v3.21.0)), distributed under the [MIT License](https://github.com/slackapi/bolt/blob/v3.21.0/LICENSE): ``` The MIT License (MIT) @@ -2683,7 +2714,7 @@ THE SOFTWARE. ### aws-sdk -This product includes source derived from [aws-sdk](https://github.com/aws/aws-sdk-js) ([v2.1659.0](https://github.com/aws/aws-sdk-js/tree/v2.1659.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js/blob/v2.1659.0/LICENSE.txt): +This product includes source derived from [aws-sdk](https://github.com/aws/aws-sdk-js) ([v2.1675.0](https://github.com/aws/aws-sdk-js/tree/v2.1675.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js/blob/v2.1675.0/LICENSE.txt): ``` @@ -3111,7 +3142,7 @@ THE SOFTWARE. ### eslint-plugin-jsdoc -This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v48.8.0](https://github.com/gajus/eslint-plugin-jsdoc/tree/v48.8.0)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v48.8.0/LICENSE): +This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v48.11.0](https://github.com/gajus/eslint-plugin-jsdoc/tree/v48.11.0)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v48.11.0/LICENSE): ``` Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/) @@ -4189,7 +4220,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ### @contrast/fn-inspect -This product includes source derived from [@contrast/fn-inspect](https://github.com/Contrast-Security-Inc/node-fn-inspect) ([v4.2.0](https://github.com/Contrast-Security-Inc/node-fn-inspect/tree/v4.2.0)), distributed under the [MIT License](https://github.com/Contrast-Security-Inc/node-fn-inspect/blob/v4.2.0/LICENSE): +This product includes source derived from [@contrast/fn-inspect](https://github.com/Contrast-Security-Inc/node-fn-inspect) ([v4.3.0](https://github.com/Contrast-Security-Inc/node-fn-inspect/tree/v4.3.0)), distributed under the [MIT License](https://github.com/Contrast-Security-Inc/node-fn-inspect/blob/v4.3.0/LICENSE): ``` Copyright 2022 Contrast Security, Inc @@ -4215,7 +4246,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ### @newrelic/native-metrics -This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v10.2.0](https://github.com/newrelic/node-native-metrics/tree/v10.2.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v10.2.0/LICENSE): +This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v11.0.0](https://github.com/newrelic/node-native-metrics/tree/v11.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v11.0.0/LICENSE): ``` Apache License diff --git a/lib/instrumentation/langchain/nr-hooks.js b/lib/instrumentation/langchain/nr-hooks.js index 23cde12459..7949c12e2d 100644 --- a/lib/instrumentation/langchain/nr-hooks.js +++ b/lib/instrumentation/langchain/nr-hooks.js @@ -22,8 +22,16 @@ module.exports = [ onRequire: cbManagerInstrumentation }, { + // This block is for catching langchain internal imports + // of the callback manager. See: + // https://github.com/elastic/require-in-the-middle/pull/88#issuecomment-2124940546 type: InstrumentationDescriptor.TYPE_GENERIC, - moduleName: '@langchain/core/dist/runnables/base', + moduleName: '@langchain/core/dist/callbacks/manager.cjs', + onRequire: cbManagerInstrumentation + }, + { + type: InstrumentationDescriptor.TYPE_GENERIC, + moduleName: '@langchain/core/runnables', onRequire: runnableInstrumentation }, { diff --git a/lib/shimmer.js b/lib/shimmer.js index 85c93a8234..deab878465 100644 --- a/lib/shimmer.js +++ b/lib/shimmer.js @@ -11,7 +11,7 @@ const fs = require('./util/unwrapped-core').fs const logger = require('./logger').child({ component: 'shimmer' }) const INSTRUMENTATIONS = require('./instrumentations')() const shims = require('./shim') -const { Hook } = require('@newrelic/ritm') +const { Hook } = require('require-in-the-middle') const IitmHook = require('import-in-the-middle') const { nrEsmProxy } = require('./symbols') const isAbsolutePath = require('./util/is-absolute-path') diff --git a/package.json b/package.json index 9b173280f8..7917c5f7f2 100644 --- a/package.json +++ b/package.json @@ -197,7 +197,6 @@ "dependencies": { "@grpc/grpc-js": "^1.9.4", "@grpc/proto-loader": "^0.7.5", - "@newrelic/ritm": "^7.2.0", "@newrelic/security-agent": "^1.3.0", "@tyriar/fibonacci-heap": "^2.0.7", "concat-stream": "^2.0.0", @@ -207,6 +206,7 @@ "json-stringify-safe": "^5.0.0", "module-details-from-path": "^1.0.3", "readable-stream": "^3.6.1", + "require-in-the-middle": "^7.4.0", "semver": "^7.5.2", "winston-transport": "^4.5.0" }, diff --git a/third_party_manifest.json b/third_party_manifest.json index 04337fd15b..0e997cfdba 100644 --- a/third_party_manifest.json +++ b/third_party_manifest.json @@ -1,30 +1,30 @@ { - "lastUpdated": "Wed Jul 31 2024 12:48:28 GMT-0400 (Eastern Daylight Time)", + "lastUpdated": "Thu Aug 15 2024 12:52:31 GMT-0400 (Eastern Daylight Time)", "projectName": "New Relic Node Agent", "projectUrl": "https://github.com/newrelic/node-newrelic", "includeOptDeps": true, "optionalDependencies": { - "@contrast/fn-inspect@4.2.0": { + "@contrast/fn-inspect@4.3.0": { "name": "@contrast/fn-inspect", - "version": "4.2.0", + "version": "4.3.0", "range": "^4.2.0", "licenses": "MIT", "repoUrl": "https://github.com/Contrast-Security-Inc/node-fn-inspect", - "versionedRepoUrl": "https://github.com/Contrast-Security-Inc/node-fn-inspect/tree/v4.2.0", + "versionedRepoUrl": "https://github.com/Contrast-Security-Inc/node-fn-inspect/tree/v4.3.0", "licenseFile": "node_modules/@contrast/fn-inspect/LICENSE", - "licenseUrl": "https://github.com/Contrast-Security-Inc/node-fn-inspect/blob/v4.2.0/LICENSE", + "licenseUrl": "https://github.com/Contrast-Security-Inc/node-fn-inspect/blob/v4.3.0/LICENSE", "licenseTextSource": "file", "publisher": "Contrast Security" }, - "@newrelic/native-metrics@10.2.0": { + "@newrelic/native-metrics@11.0.0": { "name": "@newrelic/native-metrics", - "version": "10.2.0", - "range": "^10.0.0", + "version": "11.0.0", + "range": "^11.0.0", "licenses": "Apache-2.0", "repoUrl": "https://github.com/newrelic/node-native-metrics", - "versionedRepoUrl": "https://github.com/newrelic/node-native-metrics/tree/v10.2.0", + "versionedRepoUrl": "https://github.com/newrelic/node-native-metrics/tree/v11.0.0", "licenseFile": "node_modules/@newrelic/native-metrics/LICENSE", - "licenseUrl": "https://github.com/newrelic/node-native-metrics/blob/v10.2.0/LICENSE", + "licenseUrl": "https://github.com/newrelic/node-native-metrics/blob/v11.0.0/LICENSE", "licenseTextSource": "file", "publisher": "New Relic Node.js agent team", "email": "nodejs@newrelic.com" @@ -82,15 +82,15 @@ "email": "w@tson.dk", "url": "https://twitter.com/wa7son" }, - "@newrelic/security-agent@1.4.0": { + "@newrelic/security-agent@1.5.0": { "name": "@newrelic/security-agent", - "version": "1.4.0", + "version": "1.5.0", "range": "^1.3.0", "licenses": "UNKNOWN", "repoUrl": "https://github.com/newrelic/csec-node-agent", - "versionedRepoUrl": "https://github.com/newrelic/csec-node-agent/tree/v1.4.0", + "versionedRepoUrl": "https://github.com/newrelic/csec-node-agent/tree/v1.5.0", "licenseFile": "node_modules/@newrelic/security-agent/LICENSE", - "licenseUrl": "https://github.com/newrelic/csec-node-agent/blob/v1.4.0/LICENSE", + "licenseUrl": "https://github.com/newrelic/csec-node-agent/blob/v1.5.0/LICENSE", "licenseTextSource": "file", "publisher": "newrelic" }, @@ -134,15 +134,15 @@ "email": "nathan@tootallnate.net", "url": "http://n8.io/" }, - "import-in-the-middle@1.9.1": { + "import-in-the-middle@1.11.0": { "name": "import-in-the-middle", - "version": "1.9.1", + "version": "1.11.0", "range": "^1.6.0", "licenses": "Apache-2.0", "repoUrl": "https://github.com/nodejs/import-in-the-middle", - "versionedRepoUrl": "https://github.com/nodejs/import-in-the-middle/tree/v1.9.1", + "versionedRepoUrl": "https://github.com/nodejs/import-in-the-middle/tree/v1.11.0", "licenseFile": "node_modules/import-in-the-middle/LICENSE", - "licenseUrl": "https://github.com/nodejs/import-in-the-middle/blob/v1.9.1/LICENSE", + "licenseUrl": "https://github.com/nodejs/import-in-the-middle/blob/v1.11.0/LICENSE", "licenseTextSource": "file", "publisher": "Bryan English", "email": "bryan.english@datadoghq.com" @@ -199,6 +199,20 @@ "licenseUrl": "https://github.com/nodejs/readable-stream/blob/v3.6.2/LICENSE", "licenseTextSource": "file" }, + "require-in-the-middle@7.4.0": { + "name": "require-in-the-middle", + "version": "7.4.0", + "range": "^7.4.0", + "licenses": "MIT", + "repoUrl": "https://github.com/elastic/require-in-the-middle", + "versionedRepoUrl": "https://github.com/elastic/require-in-the-middle/tree/v7.4.0", + "licenseFile": "node_modules/require-in-the-middle/LICENSE", + "licenseUrl": "https://github.com/elastic/require-in-the-middle/blob/v7.4.0/LICENSE", + "licenseTextSource": "file", + "publisher": "Thomas Watson Steen", + "email": "w@tson.dk", + "url": "https://twitter.com/wa7son" + }, "semver@7.6.3": { "name": "semver", "version": "7.6.3", @@ -226,28 +240,28 @@ } }, "devDependencies": { - "@aws-sdk/client-s3@3.616.0": { + "@aws-sdk/client-s3@3.631.0": { "name": "@aws-sdk/client-s3", - "version": "3.616.0", + "version": "3.631.0", "range": "^3.556.0", "licenses": "Apache-2.0", "repoUrl": "https://github.com/aws/aws-sdk-js-v3", - "versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.616.0", + "versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.631.0", "licenseFile": "node_modules/@aws-sdk/client-s3/LICENSE", - "licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.616.0/LICENSE", + "licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.631.0/LICENSE", "licenseTextSource": "file", "publisher": "AWS SDK for JavaScript Team", "url": "https://aws.amazon.com/javascript/" }, - "@aws-sdk/s3-request-presigner@3.616.0": { + "@aws-sdk/s3-request-presigner@3.631.0": { "name": "@aws-sdk/s3-request-presigner", - "version": "3.616.0", + "version": "3.631.0", "range": "^3.556.0", "licenses": "Apache-2.0", "repoUrl": "https://github.com/aws/aws-sdk-js-v3", - "versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.616.0", + "versionedRepoUrl": "https://github.com/aws/aws-sdk-js-v3/tree/v3.631.0", "licenseFile": "node_modules/@aws-sdk/s3-request-presigner/LICENSE", - "licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.616.0/LICENSE", + "licenseUrl": "https://github.com/aws/aws-sdk-js-v3/blob/v3.631.0/LICENSE", "licenseTextSource": "file", "publisher": "AWS SDK for JavaScript Team", "url": "https://aws.amazon.com/javascript/" @@ -314,15 +328,15 @@ "licenseUrl": "https://github.com/octokit/rest.js/blob/v18.12.0/LICENSE", "licenseTextSource": "file" }, - "@slack/bolt@3.19.0": { + "@slack/bolt@3.21.0": { "name": "@slack/bolt", - "version": "3.19.0", + "version": "3.21.0", "range": "^3.7.0", "licenses": "MIT", "repoUrl": "https://github.com/slackapi/bolt", - "versionedRepoUrl": "https://github.com/slackapi/bolt/tree/v3.19.0", + "versionedRepoUrl": "https://github.com/slackapi/bolt/tree/v3.21.0", "licenseFile": "node_modules/@slack/bolt/LICENSE", - "licenseUrl": "https://github.com/slackapi/bolt/blob/v3.19.0/LICENSE", + "licenseUrl": "https://github.com/slackapi/bolt/blob/v3.21.0/LICENSE", "licenseTextSource": "file", "publisher": "Slack Technologies, LLC" }, @@ -376,15 +390,15 @@ "licenseTextSource": "file", "publisher": "Caolan McMahon" }, - "aws-sdk@2.1659.0": { + "aws-sdk@2.1675.0": { "name": "aws-sdk", - "version": "2.1659.0", + "version": "2.1675.0", "range": "^2.1604.0", "licenses": "Apache-2.0", "repoUrl": "https://github.com/aws/aws-sdk-js", - "versionedRepoUrl": "https://github.com/aws/aws-sdk-js/tree/v2.1659.0", + "versionedRepoUrl": "https://github.com/aws/aws-sdk-js/tree/v2.1675.0", "licenseFile": "node_modules/aws-sdk/LICENSE.txt", - "licenseUrl": "https://github.com/aws/aws-sdk-js/blob/v2.1659.0/LICENSE.txt", + "licenseUrl": "https://github.com/aws/aws-sdk-js/blob/v2.1675.0/LICENSE.txt", "licenseTextSource": "file", "publisher": "Amazon Web Services", "url": "https://aws.amazon.com/" @@ -493,15 +507,15 @@ "publisher": "Michael Radionov", "url": "https://github.com/mradionov" }, - "eslint-plugin-jsdoc@48.8.3": { + "eslint-plugin-jsdoc@48.11.0": { "name": "eslint-plugin-jsdoc", - "version": "48.8.3", + "version": "48.11.0", "range": "^48.0.5", "licenses": "BSD-3-Clause", "repoUrl": "https://github.com/gajus/eslint-plugin-jsdoc", - "versionedRepoUrl": "https://github.com/gajus/eslint-plugin-jsdoc/tree/v48.8.3", + "versionedRepoUrl": "https://github.com/gajus/eslint-plugin-jsdoc/tree/v48.11.0", "licenseFile": "node_modules/eslint-plugin-jsdoc/LICENSE", - "licenseUrl": "https://github.com/gajus/eslint-plugin-jsdoc/blob/v48.8.3/LICENSE", + "licenseUrl": "https://github.com/gajus/eslint-plugin-jsdoc/blob/v48.11.0/LICENSE", "licenseTextSource": "file", "publisher": "Gajus Kuizinas", "email": "gajus@gajus.com",