Skip to content

Commit

Permalink
feat(command-monitoring): support enabling command monitoring
Browse files Browse the repository at this point in the history
This allows passing a new option `enableCommandMonitoring` to
MongoClient, or any of the native topologies, which will be passed
to the core topology to enable monitoring in the connection pool.

NODE-1390
  • Loading branch information
mbroadst committed Apr 9, 2018
1 parent c18a261 commit 5903680
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/mongo_client.js
Expand Up @@ -106,7 +106,8 @@ var validOptionNames = [
'readPreferenceTags',
'numberOfRetries',
'auto_reconnect',
'minSize'
'minSize',
'enableCommandMonitoring'
];

var ignoreOptionNames = ['native_parser'];
Expand Down Expand Up @@ -199,6 +200,7 @@ function validOptions(options) {
* @param {array} [options.readPreferenceTags=null] Read preference tags
* @param {number} [options.numberOfRetries=5] The number of retries for a tailable cursor
* @param {boolean} [options.auto_reconnect=true] Enable auto reconnecting for single server instances
* @param {boolean} [options.enableCommandMonitoring=false] Enable command monitoring for this client
* @param {MongoClient~connectCallback} [callback] The command result callback
* @return {MongoClient} a MongoClient instance
*/
Expand Down
9 changes: 7 additions & 2 deletions lib/topologies/mongos.js
Expand Up @@ -58,7 +58,8 @@ var legalOptionNames = [
'promoteLongs',
'promoteValues',
'promoteBuffers',
'promiseLibrary'
'promiseLibrary',
'enableCommandMonitoring'
];

/**
Expand Down Expand Up @@ -149,7 +150,11 @@ class Mongos extends TopologyBase {
cursorFactory: Cursor,
reconnect: reconnect,
emitError: typeof options.emitError === 'boolean' ? options.emitError : true,
size: typeof options.poolSize === 'number' ? options.poolSize : 5
size: typeof options.poolSize === 'number' ? options.poolSize : 5,
enableCommandMonitoring:
typeof options.enableCommandMonitoring === 'boolean'
? options.enableCommandMonitoring
: false
}
);

Expand Down
9 changes: 7 additions & 2 deletions lib/topologies/replset.js
Expand Up @@ -66,7 +66,8 @@ var legalOptionNames = [
'promoteBuffers',
'maxStalenessSeconds',
'promiseLibrary',
'minSize'
'minSize',
'enableCommandMonitoring'
];

/**
Expand Down Expand Up @@ -156,7 +157,11 @@ class ReplSet extends TopologyBase {
cursorFactory: Cursor,
reconnect: false,
emitError: typeof options.emitError === 'boolean' ? options.emitError : true,
size: typeof options.poolSize === 'number' ? options.poolSize : 5
size: typeof options.poolSize === 'number' ? options.poolSize : 5,
enableCommandMonitoring:
typeof options.enableCommandMonitoring === 'boolean'
? options.enableCommandMonitoring
: false
}
);

Expand Down
9 changes: 7 additions & 2 deletions lib/topologies/server.js
Expand Up @@ -61,7 +61,8 @@ var legalOptionNames = [
'promoteValues',
'promoteBuffers',
'compression',
'promiseLibrary'
'promiseLibrary',
'enableCommandMonitoring'
];

/**
Expand Down Expand Up @@ -149,7 +150,11 @@ class Server extends TopologyBase {
cursorFactory: Cursor,
reconnect: reconnect,
emitError: typeof options.emitError === 'boolean' ? options.emitError : true,
size: typeof options.poolSize === 'number' ? options.poolSize : 5
size: typeof options.poolSize === 'number' ? options.poolSize : 5,
enableCommandMonitoring:
typeof options.enableCommandMonitoring === 'boolean'
? options.enableCommandMonitoring
: false
}
);

Expand Down

0 comments on commit 5903680

Please sign in to comment.