From 3cd523aad99ff86ef31a17955c9faaf3d80749fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 01:22:31 +0000 Subject: [PATCH 1/4] chore(deps-dev): bump mongodb from 6.3.0 to 6.4.0 Bumps [mongodb](https://github.com/mongodb/node-mongodb-native) from 6.3.0 to 6.4.0. - [Release notes](https://github.com/mongodb/node-mongodb-native/releases) - [Changelog](https://github.com/mongodb/node-mongodb-native/blob/main/HISTORY.md) - [Commits](https://github.com/mongodb/node-mongodb-native/compare/v6.3.0...v6.4.0) --- updated-dependencies: - dependency-name: mongodb dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9081c9003fa..d633bd179dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7730,9 +7730,9 @@ } }, "node_modules/bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.4.0.tgz", + "integrity": "sha512-6/gSSEdbkuFlSb+ufj5jUSU4+wo8xQOwm2bDSqwmxiPE17JTpsP63eAwoN8iF8Oy4gJYj+PAL3zdRCTdaw5Y1g==", "dev": true, "engines": { "node": ">=16.20.1" @@ -13542,13 +13542,13 @@ "integrity": "sha1-EUyUlnPiqKNenTV4hSeqN7Z52is=" }, "node_modules/mongodb": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.3.0.tgz", - "integrity": "sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.4.0.tgz", + "integrity": "sha512-MdFHsyb1a/Ee0H3NmzWTSLqchacDV/APF0H6BNQvraWrOiIocys2EmTFZPgHxWhcfO94c1F34I9MACU7x0hHKA==", "dev": true, "dependencies": { "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.2.0", + "bson": "^6.4.0", "mongodb-connection-string-url": "^3.0.0" }, "engines": { @@ -24443,9 +24443,9 @@ } }, "bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.4.0.tgz", + "integrity": "sha512-6/gSSEdbkuFlSb+ufj5jUSU4+wo8xQOwm2bDSqwmxiPE17JTpsP63eAwoN8iF8Oy4gJYj+PAL3zdRCTdaw5Y1g==", "dev": true }, "buffer": { @@ -28826,13 +28826,13 @@ "integrity": "sha1-EUyUlnPiqKNenTV4hSeqN7Z52is=" }, "mongodb": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.3.0.tgz", - "integrity": "sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.4.0.tgz", + "integrity": "sha512-MdFHsyb1a/Ee0H3NmzWTSLqchacDV/APF0H6BNQvraWrOiIocys2EmTFZPgHxWhcfO94c1F34I9MACU7x0hHKA==", "dev": true, "requires": { "@mongodb-js/saslprep": "^1.1.0", - "bson": "^6.2.0", + "bson": "^6.4.0", "mongodb-connection-string-url": "^3.0.0" } }, From fe375a0739b5fea5275165e53b0b46081b5a2aa6 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 4 Mar 2024 14:13:53 -0800 Subject: [PATCH 2/4] fix(mongodb): fix instr to no longer break mongodb >=6.4.0 --- CHANGELOG.asciidoc | 4 ++++ .../modules/mongodb/lib/cmap/connection_pool.js | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 1a5d32c34c2..4f9d9c96edb 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -44,6 +44,10 @@ See the <> guide. [float] ===== Bug fixes +* Fix instrumentation of mongodb to not break mongodb@6.4.0. Mongodb v6.4.0 + included changes that resulted in the APM agent's instrumentation breaking it. + ({pull}3897[#3897]) + [float] ===== Chores diff --git a/lib/instrumentation/modules/mongodb/lib/cmap/connection_pool.js b/lib/instrumentation/modules/mongodb/lib/cmap/connection_pool.js index 22089015b2e..0dfb25e84c8 100644 --- a/lib/instrumentation/modules/mongodb/lib/cmap/connection_pool.js +++ b/lib/instrumentation/modules/mongodb/lib/cmap/connection_pool.js @@ -12,13 +12,14 @@ const semver = require('semver'); module.exports = (mod, agent, { version, enabled }) => { if (!enabled) return mod; - if (!semver.satisfies(version, '>=3.3 <7.0')) { - agent.logger.debug( - 'mongodb version %s not instrumented (mongodb <3.3 is instrumented via mongodb-core)', - version, - ); + if (!semver.satisfies(version, '>=3.3 <6.4.0')) { + // - mongodb <3.3 is instrumented via mongodb-core + // - mongodb >=6.4.0 now longer requires ConnectionPool#checkOut to be + // patched to fix async context tracking. See discussion at + // https://github.com/elastic/apm-agent-nodejs/pull/3897 return mod; } + agent.logger.debug('instrumenting mongodb ConnectionPool#checkOut'); if (mod.ConnectionPool) { class ConnectionPoolTraced extends mod.ConnectionPool { From c07c2a13206f1fb98c0e7b2cb6ccfbef69b73ab0 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 4 Mar 2024 14:41:47 -0800 Subject: [PATCH 3/4] refine the min-supported Node.js version for mongodb TAV tests --- .tav.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tav.yml b/.tav.yml index 954150abc15..e4b498b2a25 100644 --- a/.tav.yml +++ b/.tav.yml @@ -131,7 +131,7 @@ mongodb: node: '>=14.20.1' commands: node test/instrumentation/modules/mongodb/mongodb.test.js - versions: '>=6 <7' - node: '>=15.0.0' + node: '>=16.20.1' commands: node test/instrumentation/modules/mongodb/mongodb.test.js # Bluebird is effectively deprecated (https://github.com/petkaantonov/bluebird#%EF%B8%8Fnote%EF%B8%8F). From fbfbc782687a6cbeda8a8ebf2b1a81d344d08be3 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 4 Mar 2024 14:52:22 -0800 Subject: [PATCH 4/4] missed this change to set min-supported node for mongodb tests in regular unit-tests --- test/_is_mongodb_incompat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/_is_mongodb_incompat.js b/test/_is_mongodb_incompat.js index 6f547b9f74f..615df86bea1 100644 --- a/test/_is_mongodb_incompat.js +++ b/test/_is_mongodb_incompat.js @@ -39,7 +39,7 @@ function isMongodbIncompat() { return msg; } } else if (semver.satisfies(mongodbVer, '>=6.0.0')) { - if (!semver.satisfies(nodeVer, '>=15.0.0')) { + if (!semver.satisfies(nodeVer, '>=16.20.1')) { return msg; } }