Skip to content

Commit

Permalink
fix mongodb instrumentation re-throwing promises (#4175)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev committed Mar 21, 2024
1 parent 344d929 commit 7647c20
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "2"
services:
aerospike:
image: aerospike:ce-6.4.0.3
ports:
ports:
- "127.0.0.1:3000-3002:3000-3002"
couchbase:
image: ghcr.io/datadog/couchbase-server-sandbox:latest
Expand Down Expand Up @@ -38,6 +38,7 @@ services:
- "127.0.0.1:6379:6379"
mongo:
image: circleci/mongo:3.6
platform: linux/amd64
ports:
- "127.0.0.1:27017:27017"
oracledb:
Expand Down
4 changes: 1 addition & 3 deletions packages/datadog-instrumentations/src/mongodb-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function instrumentPromise (operation, command, ctx, args, server, ns, ops, opti

const promise = command.apply(ctx, args)

promise.then(function (res) {
return promise.then(function (res) {
finishCh.publish()
return res
}, function (err) {
Expand All @@ -206,7 +206,5 @@ function instrumentPromise (operation, command, ctx, args, server, ns, ops, opti

return Promise.reject(err)
})

return promise
})
}
6 changes: 3 additions & 3 deletions packages/datadog-plugin-mongodb-core/test/core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Plugin', () => {
const Server = getServer()

server = new Server({
host: 'localhost',
host: '127.0.0.1',
port: 27017,
reconnect: false
})
Expand All @@ -86,7 +86,7 @@ describe('Plugin', () => {
expect(span).to.have.property('type', 'mongodb')
expect(span.meta).to.have.property('span.kind', 'client')
expect(span.meta).to.have.property('db.name', `test.${collection}`)
expect(span.meta).to.have.property('out.host', 'localhost')
expect(span.meta).to.have.property('out.host', '127.0.0.1')
expect(span.meta).to.have.property('component', 'mongodb')
})
.then(done)
Expand Down Expand Up @@ -360,7 +360,7 @@ describe('Plugin', () => {
const Server = getServer()

server = new Server({
host: 'localhost',
host: '127.0.0.1',
port: 27017,
reconnect: false
})
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/setup/services/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function waitForMongo () {

operation.attempt(currentAttempt => {
const server = new mongo.Server({
host: 'localhost',
host: '127.0.0.1',
port: 27017,
reconnect: false
})
Expand Down

0 comments on commit 7647c20

Please sign in to comment.