Skip to content

Commit ff32186

Browse files
committed
fix(mongodb): fix cursor instrumentation below 2.0.0
1 parent 3ca4df8 commit ff32186

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/instrumentations/mongodb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ function wrapper (mongodb, agent, pkg) {
5454
continuationMethod = typeof args[args.length - 1] === 'function' ? 'callback' : 'readStream'
5555
} else {
5656
// below 2.0.0 if a cursor description is provided, a cursor is returned, otherwise callback is called
57-
continuationMethod = queryOptions.cursor ? 'readStream' : 'callback'
57+
continuationMethod = queryOptions.cursor ? false : 'callback'
5858
}
5959
} else if (typeof args[args.length - 1] === 'function') {
6060
continuationMethod = 'callback'
6161
} else if (name === 'find') {
62-
continuationMethod = 'readStream'
62+
continuationMethod = version && semver.satisfies(version, '>= 2.0.0') ? 'readStream' : false
6363
} else if (version && semver.satisfies(version, '>= 2.0.0')) {
6464
continuationMethod = 'promise'
6565
} else {

lib/instrumentations/mongodb.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('The mongodb wrapper module', function () {
5252
method: 'find',
5353
protocol: 'mongodb',
5454
url: 'unknown',
55-
continuationMethod: 'readStream'
55+
continuationMethod: false
5656
})
5757
})
5858

0 commit comments

Comments
 (0)