Skip to content

Commit

Permalink
fix(mongodb): fix cursor instrumentation below 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowbeetle committed Dec 22, 2016
1 parent 3ca4df8 commit ff32186
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/instrumentations/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ function wrapper (mongodb, agent, pkg) {
continuationMethod = typeof args[args.length - 1] === 'function' ? 'callback' : 'readStream'
} else {
// below 2.0.0 if a cursor description is provided, a cursor is returned, otherwise callback is called
continuationMethod = queryOptions.cursor ? 'readStream' : 'callback'
continuationMethod = queryOptions.cursor ? false : 'callback'
}
} else if (typeof args[args.length - 1] === 'function') {
continuationMethod = 'callback'
} else if (name === 'find') {
continuationMethod = 'readStream'
continuationMethod = version && semver.satisfies(version, '>= 2.0.0') ? 'readStream' : false
} else if (version && semver.satisfies(version, '>= 2.0.0')) {
continuationMethod = 'promise'
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/instrumentations/mongodb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('The mongodb wrapper module', function () {
method: 'find',
protocol: 'mongodb',
url: 'unknown',
continuationMethod: 'readStream'
continuationMethod: false
})
})

Expand Down

0 comments on commit ff32186

Please sign in to comment.