Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(instr-mongodb): fix instr to no longer break mongodb >=6.4.0 #3897

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ See the <<upgrade-to-v4>> 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

Expand Down
11 changes: 6 additions & 5 deletions lib/instrumentation/modules/mongodb/lib/cmap/connection_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/_is_mongodb_incompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Loading