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

Add tracing support for .count() and .countDocuments() in datadog-plugin-mongodb-core #1008

Closed
patrickshuff opened this issue Jul 1, 2020 · 4 comments

Comments

@patrickshuff
Copy link

Currently there are only a limited number of mongodb-core calls that are being dynamically patched:
https://github.com/DataDog/dd-trace-js/blob/master/packages/datadog-plugin-mongodb-core/src/index.js#L139

function patch (core, tracer, config) {
  this.wrap(core.Server.prototype, 'command', createWrapOperation(tracer, config))
  this.wrap(core.Server.prototype, 'insert', createWrapOperation(tracer, config, 'insert'))
  this.wrap(core.Server.prototype, 'update', createWrapOperation(tracer, config, 'update'))
  this.wrap(core.Server.prototype, 'remove', createWrapOperation(tracer, config, 'remove'))

  if (core.Cursor.prototype.next) {
    this.wrap(core.Cursor.prototype, 'next', createWrapNext(tracer, config))
  } else if (core.Cursor.prototype._next) {
    this.wrap(core.Cursor.prototype, '_next', createWrapNext(tracer, config))
  }
}

Please add support for the default patching/tracing of both the .count() and the .countDocument() queries as they (unfortunately) can be very expensive if there are MongoDB indexes that are missing and are worth tracing by default.

@patrickshuff patrickshuff changed the title Add default tracing support for .count() and .countDocument() in the datadog-plugin-mongodb-core Add tracing support for .count() and .countDocument() in the datadog-plugin-mongodb-core Jul 1, 2020
@patrickshuff patrickshuff changed the title Add tracing support for .count() and .countDocument() in the datadog-plugin-mongodb-core Add tracing support for .count() and .countDocuments() in the datadog-plugin-mongodb-core Jul 1, 2020
@patrickshuff patrickshuff changed the title Add tracing support for .count() and .countDocuments() in the datadog-plugin-mongodb-core Add tracing support for .count() and .countDocuments() in datadog-plugin-mongodb-core Jul 1, 2020
@rochdev
Copy link
Member

rochdev commented Nov 6, 2020

Can you provide a code example of how you use count()? I tried reproducing but I'm getting traces for count commands.

@rochdev
Copy link
Member

rochdev commented Nov 16, 2020

We're looking into instrumenting the driver at the wire protocol directly which should intercept every command sent to Mongo, so this will be supported as well at that point.

@patrickshuff
Copy link
Author

@rochdev -- we are using mongoose-paginate-v2 which was doing some .count() calls and were causing us some pain that weren't showing up in Datadog APM.

@rochdev
Copy link
Member

rochdev commented Nov 19, 2020

Fixed in #1159

@rochdev rochdev closed this as completed Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants