0

In order to optimize the connection pool size, I thought it would make sense to graph query queue times. Is it possible to retrieve this metric from Mongoose?

User9123
  • 179
  • 9

1 Answers1

1

See here for node monitoring. You need cmap events that apparently aren't documented there, see Ruby docs for example but they should be published by the node driver also.

Track ConnectionCheckOutStarted and ConnectionCheckOutSucceeded and subtract the times to get the wait time.

D. SM
  • 13,584
  • 3
  • 12
  • 21
  • Found the node driver documentation for CMAP monitoring: https://github.com/mongodb/node-mongodb-native/blob/a630389bef2cc2a360dacd84d67cf514ed321fdd/docs/reference/content/reference/management/cmap-monitoring.md – User9123 Aug 30 '20 at 14:54
  • For documentation purposes: These events can be caught with mongoose using `require('mongoose').connection.client.on('connectionCheckedOut', (event) => console.dir(event))`; – User9123 Aug 30 '20 at 18:07