Skip to content

Commit b83a75b

Browse files
fix(instr-mongodb): fix instr to no longer break mongodb >=6.4.0 (#3897)
* chore(deps-dev): bump mongodb from 6.3.0 to 6.4.0 Co-authored-by: Trent Mick <trent.mick@elastic.co>
1 parent ec41c97 commit b83a75b

5 files changed

Lines changed: 26 additions & 21 deletions

File tree

.tav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ mongodb:
131131
node: '>=14.20.1'
132132
commands: node test/instrumentation/modules/mongodb/mongodb.test.js
133133
- versions: '>=6 <7'
134-
node: '>=15.0.0'
134+
node: '>=16.20.1'
135135
commands: node test/instrumentation/modules/mongodb/mongodb.test.js
136136

137137
# Bluebird is effectively deprecated (https://github.com/petkaantonov/bluebird#%EF%B8%8Fnote%EF%B8%8F).

CHANGELOG.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ See the <<upgrade-to-v4>> guide.
4646
[float]
4747
===== Bug fixes
4848
49+
* Fix instrumentation of mongodb to not break mongodb@6.4.0. Mongodb v6.4.0
50+
included changes that resulted in the APM agent's instrumentation breaking it.
51+
({pull}3897[#3897])
52+
4953
[float]
5054
===== Chores
5155

lib/instrumentation/modules/mongodb/lib/cmap/connection_pool.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ const semver = require('semver');
1212

1313
module.exports = (mod, agent, { version, enabled }) => {
1414
if (!enabled) return mod;
15-
if (!semver.satisfies(version, '>=3.3 <7.0')) {
16-
agent.logger.debug(
17-
'mongodb version %s not instrumented (mongodb <3.3 is instrumented via mongodb-core)',
18-
version,
19-
);
15+
if (!semver.satisfies(version, '>=3.3 <6.4.0')) {
16+
// - mongodb <3.3 is instrumented via mongodb-core
17+
// - mongodb >=6.4.0 now longer requires ConnectionPool#checkOut to be
18+
// patched to fix async context tracking. See discussion at
19+
// https://github.com/elastic/apm-agent-nodejs/pull/3897
2020
return mod;
2121
}
22+
agent.logger.debug('instrumenting mongodb ConnectionPool#checkOut');
2223

2324
if (mod.ConnectionPool) {
2425
class ConnectionPoolTraced extends mod.ConnectionPool {

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/_is_mongodb_incompat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function isMongodbIncompat() {
3939
return msg;
4040
}
4141
} else if (semver.satisfies(mongodbVer, '>=6.0.0')) {
42-
if (!semver.satisfies(nodeVer, '>=15.0.0')) {
42+
if (!semver.satisfies(nodeVer, '>=16.20.1')) {
4343
return msg;
4444
}
4545
}

0 commit comments

Comments
 (0)