From a76e2fc5cc819b48344df7b12abfcc6fb457939f Mon Sep 17 00:00:00 2001 From: Sibelius Seraphini Date: Fri, 26 Dec 2025 01:43:04 +0000 Subject: [PATCH 1/2] feat(mongodb): support mongodb v7, fix #4910 --- .tav.yml | 2 +- docs/reference/supported-technologies.md | 58 +++++++-------- lib/instrumentation/modules/mongodb.js | 2 +- package-lock.json | 94 +++++++++++++----------- package.json | 2 +- test/_is_mongodb_incompat.js | 6 +- 6 files changed, 89 insertions(+), 75 deletions(-) diff --git a/.tav.yml b/.tav.yml index b4737dbc40..e652529ab8 100644 --- a/.tav.yml +++ b/.tav.yml @@ -127,7 +127,7 @@ mongodb: - versions: '>=5 <6' node: '>=14.20.1' commands: node test/instrumentation/modules/mongodb/mongodb.test.js - - versions: '>=6 <7' + - versions: '>=6 <8' node: '>=16.20.1' commands: node test/instrumentation/modules/mongodb/mongodb.test.js diff --git a/docs/reference/supported-technologies.md b/docs/reference/supported-technologies.md index c7e0dea11b..e723b8aafc 100644 --- a/docs/reference/supported-technologies.md +++ b/docs/reference/supported-technologies.md @@ -80,36 +80,36 @@ By default transactions are named based on their matched HTTP route if the frame The Node.js agent will automatically instrument the following modules to give you detailed performance metrics: -| Module | Version | Note | -| --- | --- | --- | -| [aws-sdk](https://www.npmjs.com/package/aws-sdk) | >=2.858.0 <3 | Will instrument SQS send/receive/delete messages, all S3 methods, all DynamoDB methods, and the SNS publish method | -| [@aws-sdk/client-s3](https://www.npmjs.com/package/@aws-sdk/client-s3) | >=3.15.0 <4 | Will instrument all S3 methods | -| [@aws-sdk/client-sns](https://www.npmjs.com/package/@aws-sdk/client-s3) | >=3.15.0 <4 | Will instrument the SNS publish method | -| [@aws-sdk/client-sqs](https://www.npmjs.com/package/@aws-sdk/client-s3) | >=3.15.0 <4 | Will instrument SQS send/receive/delete messages | -| [@aws-sdk/client-dynamodb](https://www.npmjs.com/package/@aws-sdk/client-dynamodb) | >=3.15.0 <4 | Will instrument all DynamoDB methods | -| [cassandra-driver](https://www.npmjs.com/package/cassandra-driver) | >=3.0.0 <5 | Will instrument all queries | -| [elasticsearch](https://www.npmjs.com/package/elasticsearch) | >=8.0.0 <17 | Will instrument all queries | +| Module | Version | Note | +| --- |-----------------| --- | +| [aws-sdk](https://www.npmjs.com/package/aws-sdk) | >=2.858.0 <3 | Will instrument SQS send/receive/delete messages, all S3 methods, all DynamoDB methods, and the SNS publish method | +| [@aws-sdk/client-s3](https://www.npmjs.com/package/@aws-sdk/client-s3) | >=3.15.0 <4 | Will instrument all S3 methods | +| [@aws-sdk/client-sns](https://www.npmjs.com/package/@aws-sdk/client-s3) | >=3.15.0 <4 | Will instrument the SNS publish method | +| [@aws-sdk/client-sqs](https://www.npmjs.com/package/@aws-sdk/client-s3) | >=3.15.0 <4 | Will instrument SQS send/receive/delete messages | +| [@aws-sdk/client-dynamodb](https://www.npmjs.com/package/@aws-sdk/client-dynamodb) | >=3.15.0 <4 | Will instrument all DynamoDB methods | +| [cassandra-driver](https://www.npmjs.com/package/cassandra-driver) | >=3.0.0 <5 | Will instrument all queries | +| [elasticsearch](https://www.npmjs.com/package/elasticsearch) | >=8.0.0 <17 | Will instrument all queries | | [@elastic/elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) | >=7.0.0 <10.0.0 | Will instrument all queries | -| [graphql](https://www.npmjs.com/package/graphql) | >=0.7.0 <17 | Will instrument all queries | -| [handlebars](https://www.npmjs.com/package/handlebars) | >=1 <5 | Will instrument compile and render calls | -| [jade](https://www.npmjs.com/package/jade) | >=0.5.6 <2 | Will instrument compile and render calls; Deprecated. No longer tested. Use pug. | -| [pug](https://www.npmjs.com/package/pug) | >=0.1.0 <4 | Will instrument compile and render calls | -| [ioredis](https://www.npmjs.com/package/ioredis) | >=2.0.0 <6.0.0 | Will instrument all queries | -| [memcached](https://www.npmjs.com/package/memcached) | >=2.2.0 <3 | Will instrument all commands. | -| [mongodb-core](https://www.npmjs.com/package/mongodb-core) | >=1.2.19 <4 | Will instrument all queries.A lot of higher level MongoDB modules use mongodb-core,so those should be supported as well. | -| [mongodb](https://www.npmjs.com/package/mongodb) | >=2.0.0 <3.3.0 | Supported via mongodb-core | -| [mongodb](https://www.npmjs.com/package/mongodb) | >=3.3.0 <7 | Will instrument all queries | -| [mongojs](https://www.npmjs.com/package/mongojs) | >=1.0.0 <2.7.0 | Supported via mongodb-core | -| [mongoose](https://www.npmjs.com/package/mongoose) | >=4.0.0 <5.7.0 | Supported via mongodb-core | -| [mongoose](https://www.npmjs.com/package/mongoose) | >=5.7.0 <8 | Supported via mongodb | -| [mysql](https://www.npmjs.com/package/mysql) | >=2.0.0 <3 | Will instrument all queries | -| [mysql2](https://www.npmjs.com/package/mysql2) | >=1.0.0 <4.0.0 | Will instrument all queries | -| [pg](https://www.npmjs.com/package/pg) | >=4.0.0 <9.0.0 | Will instrument all queries | -| [redis](https://www.npmjs.com/package/redis) | >=2.0.0 <5.0.0 | Will instrument all queries | -| [tedious](https://www.npmjs.com/package/tedious) | >=1.9 <20.0.0 | (Excluding v4.0.0.) Will instrument all queries | -| [undici](https://www.npmjs.com/package/undici) | >=4.7.1 <8 | Will instrument undici HTTP requests, except HTTP CONNECT. Requires node v14.17.0 or later, or the user to have installed the [*diagnostics_channel* polyfill](https://www.npmjs.com/package/diagnostics_channel). | -| [ws](https://www.npmjs.com/package/ws) | >=1.0.0 <8.0.0 | Will instrument outgoing WebSocket messages | -| [kafkajs](https://www.npmjs.com/package/kafkajs) | >=2.0.0 <3.0.0 | Will instrument all send methods for producers and message and batch processing for consumers. | +| [graphql](https://www.npmjs.com/package/graphql) | >=0.7.0 <17 | Will instrument all queries | +| [handlebars](https://www.npmjs.com/package/handlebars) | >=1 <5 | Will instrument compile and render calls | +| [jade](https://www.npmjs.com/package/jade) | >=0.5.6 <2 | Will instrument compile and render calls; Deprecated. No longer tested. Use pug. | +| [pug](https://www.npmjs.com/package/pug) | >=0.1.0 <4 | Will instrument compile and render calls | +| [ioredis](https://www.npmjs.com/package/ioredis) | >=2.0.0 <6.0.0 | Will instrument all queries | +| [memcached](https://www.npmjs.com/package/memcached) | >=2.2.0 <3 | Will instrument all commands. | +| [mongodb-core](https://www.npmjs.com/package/mongodb-core) | >=1.2.19 <4 | Will instrument all queries.A lot of higher level MongoDB modules use mongodb-core,so those should be supported as well. | +| [mongodb](https://www.npmjs.com/package/mongodb) | >=2.0.0 <3.3.0 | Supported via mongodb-core | +| [mongodb](https://www.npmjs.com/package/mongodb) | >=3.3.0 <8 | Will instrument all queries | +| [mongojs](https://www.npmjs.com/package/mongojs) | >=1.0.0 <2.7.0 | Supported via mongodb-core | +| [mongoose](https://www.npmjs.com/package/mongoose) | >=4.0.0 <5.7.0 | Supported via mongodb-core | +| [mongoose](https://www.npmjs.com/package/mongoose) | >=5.7.0 <8 | Supported via mongodb | +| [mysql](https://www.npmjs.com/package/mysql) | >=2.0.0 <3 | Will instrument all queries | +| [mysql2](https://www.npmjs.com/package/mysql2) | >=1.0.0 <4.0.0 | Will instrument all queries | +| [pg](https://www.npmjs.com/package/pg) | >=4.0.0 <9.0.0 | Will instrument all queries | +| [redis](https://www.npmjs.com/package/redis) | >=2.0.0 <5.0.0 | Will instrument all queries | +| [tedious](https://www.npmjs.com/package/tedious) | >=1.9 <20.0.0 | (Excluding v4.0.0.) Will instrument all queries | +| [undici](https://www.npmjs.com/package/undici) | >=4.7.1 <8 | Will instrument undici HTTP requests, except HTTP CONNECT. Requires node v14.17.0 or later, or the user to have installed the [*diagnostics_channel* polyfill](https://www.npmjs.com/package/diagnostics_channel). | +| [ws](https://www.npmjs.com/package/ws) | >=1.0.0 <8.0.0 | Will instrument outgoing WebSocket messages | +| [kafkajs](https://www.npmjs.com/package/kafkajs) | >=2.0.0 <3.0.0 | Will instrument all send methods for producers and message and batch processing for consumers. | ## Better Stack Traces [compatibility-better-stack-traces] diff --git a/lib/instrumentation/modules/mongodb.js b/lib/instrumentation/modules/mongodb.js index e2159c0a76..b3213d4464 100644 --- a/lib/instrumentation/modules/mongodb.js +++ b/lib/instrumentation/modules/mongodb.js @@ -19,7 +19,7 @@ const HOSTNAME_PORT_RE = /^(.+):(\d+)$/; module.exports = (mongodb, agent, { version, enabled }) => { if (!enabled) return mongodb; - if (!semver.satisfies(version, '>=3.3 <7')) { + if (!semver.satisfies(version, '>=3.3 <8')) { agent.logger.debug( 'mongodb version %s not instrumented (mongodb <3.3 is instrumented via mongodb-core)', version, diff --git a/package-lock.json b/package-lock.json index d6415e8437..c8a2851713 100644 --- a/package-lock.json +++ b/package-lock.json @@ -106,7 +106,7 @@ "memcached": "^2.2.2", "mimic-response": "1.0.0", "mkdirp": "^3.0.1", - "mongodb": "^6.0.0", + "mongodb": "^7.0.0", "mongodb-core": "^3.2.7", "mysql": "^2.18.1", "mysql2": "^3.2.4", @@ -6597,13 +6597,15 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/whatwg-url": { - "version": "11.0.5", - "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", - "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q==", "dev": true, + "license": "MIT", "dependencies": { "@types/webidl-conversions": "*" } @@ -7760,13 +7762,13 @@ } }, "node_modules/bson": { - "version": "6.10.4", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", - "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-7.0.0.tgz", + "integrity": "sha512-Kwc6Wh4lQ5OmkqqKhYGKIuELXl+EPYSCObVE6bWsp1T/cGkOCBN0I8wF/T44BiuhHyNi1mmKVPXk60d41xZ7kw==", "dev": true, "license": "Apache-2.0", "engines": { - "node": ">=16.20.1" + "node": ">=20.19.0" } }, "node_modules/buffer": { @@ -12946,26 +12948,27 @@ "license": "MIT" }, "node_modules/mongodb": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.21.0.tgz", - "integrity": "sha512-URyb/VXMjJ4da46OeSXg+puO39XH9DeQpWCslifrRn9JWugy0D+DvvBvkm2WxmHe61O/H19JM66p1z7RHVkZ6A==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.0.0.tgz", + "integrity": "sha512-vG/A5cQrvGGvZm2mTnCSz1LUcbOPl83hfB6bxULKQ8oFZauyox/2xbZOoGNl+64m8VBrETkdGCDBdOsCr3F3jg==", "dev": true, + "license": "Apache-2.0", "dependencies": { "@mongodb-js/saslprep": "^1.3.0", - "bson": "^6.10.4", - "mongodb-connection-string-url": "^3.0.2" + "bson": "^7.0.0", + "mongodb-connection-string-url": "^7.0.0" }, "engines": { - "node": ">=16.20.1" + "node": ">=20.19.0" }, "peerDependencies": { - "@aws-sdk/credential-providers": "^3.188.0", - "@mongodb-js/zstd": "^1.1.0 || ^2.0.0", - "gcp-metadata": "^5.2.0", - "kerberos": "^2.0.1", - "mongodb-client-encryption": ">=6.0.0 <7", + "@aws-sdk/credential-providers": "^3.806.0", + "@mongodb-js/zstd": "^7.0.0", + "gcp-metadata": "^7.0.1", + "kerberos": "^7.0.0", + "mongodb-client-encryption": ">=7.0.0 <7.1.0", "snappy": "^7.3.2", - "socks": "^2.7.1" + "socks": "^2.8.6" }, "peerDependenciesMeta": { "@aws-sdk/credential-providers": { @@ -12992,13 +12995,17 @@ } }, "node_modules/mongodb-connection-string-url": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", - "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.0.tgz", + "integrity": "sha512-irhhjRVLE20hbkRl4zpAYLnDMM+zIZnp0IDB9akAFFUZp/3XdOfwwddc7y6cNvF2WCEtfTYRwYbIfYa2kVY0og==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "@types/whatwg-url": "^11.0.2", - "whatwg-url": "^14.1.0 || ^13.0.0" + "@types/whatwg-url": "^13.0.0", + "whatwg-url": "^14.1.0" + }, + "engines": { + "node": ">=20.19.0" } }, "node_modules/mongodb-connection-string-url/node_modules/tr46": { @@ -13006,6 +13013,7 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", "dev": true, + "license": "MIT", "dependencies": { "punycode": "^2.3.1" }, @@ -13018,6 +13026,7 @@ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=12" } @@ -13027,6 +13036,7 @@ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", "dev": true, + "license": "MIT", "dependencies": { "tr46": "^5.1.0", "webidl-conversions": "^7.0.0" @@ -21973,9 +21983,9 @@ "dev": true }, "@types/whatwg-url": { - "version": "11.0.5", - "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", - "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q==", "dev": true, "requires": { "@types/webidl-conversions": "*" @@ -22820,9 +22830,9 @@ } }, "bson": { - "version": "6.10.4", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", - "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-7.0.0.tgz", + "integrity": "sha512-Kwc6Wh4lQ5OmkqqKhYGKIuELXl+EPYSCObVE6bWsp1T/cGkOCBN0I8wF/T44BiuhHyNi1mmKVPXk60d41xZ7kw==", "dev": true }, "buffer": { @@ -26600,24 +26610,24 @@ "integrity": "sha512-EGWKgxALGMgzvxYF1UyGTy0HXX/2vHLkw6+NvDKW2jypWbHpjQuj4UMcqQWXHERJhVGKikolT06G3bcKe4fi7w==" }, "mongodb": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.21.0.tgz", - "integrity": "sha512-URyb/VXMjJ4da46OeSXg+puO39XH9DeQpWCslifrRn9JWugy0D+DvvBvkm2WxmHe61O/H19JM66p1z7RHVkZ6A==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.0.0.tgz", + "integrity": "sha512-vG/A5cQrvGGvZm2mTnCSz1LUcbOPl83hfB6bxULKQ8oFZauyox/2xbZOoGNl+64m8VBrETkdGCDBdOsCr3F3jg==", "dev": true, "requires": { "@mongodb-js/saslprep": "^1.3.0", - "bson": "^6.10.4", - "mongodb-connection-string-url": "^3.0.2" + "bson": "^7.0.0", + "mongodb-connection-string-url": "^7.0.0" } }, "mongodb-connection-string-url": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", - "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.0.tgz", + "integrity": "sha512-irhhjRVLE20hbkRl4zpAYLnDMM+zIZnp0IDB9akAFFUZp/3XdOfwwddc7y6cNvF2WCEtfTYRwYbIfYa2kVY0og==", "dev": true, "requires": { - "@types/whatwg-url": "^11.0.2", - "whatwg-url": "^14.1.0 || ^13.0.0" + "@types/whatwg-url": "^13.0.0", + "whatwg-url": "^14.1.0" }, "dependencies": { "tr46": { diff --git a/package.json b/package.json index 0f9644241d..0fea72778a 100644 --- a/package.json +++ b/package.json @@ -187,7 +187,7 @@ "memcached": "^2.2.2", "mimic-response": "1.0.0", "mkdirp": "^3.0.1", - "mongodb": "^6.0.0", + "mongodb": "^7.0.0", "mongodb-core": "^3.2.7", "mysql": "^2.18.1", "mysql2": "^3.2.4", diff --git a/test/_is_mongodb_incompat.js b/test/_is_mongodb_incompat.js index 615df86bea..12571daf48 100644 --- a/test/_is_mongodb_incompat.js +++ b/test/_is_mongodb_incompat.js @@ -38,7 +38,11 @@ function isMongodbIncompat() { if (!semver.satisfies(nodeVer, '>=14.20.1')) { return msg; } - } else if (semver.satisfies(mongodbVer, '>=6.0.0')) { + } else if (semver.satisfies(mongodbVer, '>=6.0.0 <7')) { + if (!semver.satisfies(nodeVer, '>=16.20.1')) { + return msg; + } + } else if (semver.satisfies(mongodbVer, '>=7.0.0')) { if (!semver.satisfies(nodeVer, '>=16.20.1')) { return msg; } From a40b904e0b5224fe804da95e3e33f6bb8fdd359a Mon Sep 17 00:00:00 2001 From: Sibelius Seraphini Date: Fri, 26 Dec 2025 01:44:46 +0000 Subject: [PATCH 2/2] feat(release): add to release notes --- docs/release-notes/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/index.md b/docs/release-notes/index.md index f4a57c929c..0c70bb907e 100644 --- a/docs/release-notes/index.md +++ b/docs/release-notes/index.md @@ -30,6 +30,7 @@ To check for security updates, go to [Security announcements for the Elastic sta **Release date:** Month day, year ### Features and enhancements [next-features-enhancements] +* Support instrumenting `mongodb` v7. ([#4911](https://github.com/elastic/apm-agent-nodejs/pull/4911)) ### Fixes [next-fixes]