Skip to content

Commit 5903680

Browse files
committed
feat(command-monitoring): support enabling command monitoring
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
1 parent c18a261 commit 5903680

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

lib/mongo_client.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ var validOptionNames = [
106106
'readPreferenceTags',
107107
'numberOfRetries',
108108
'auto_reconnect',
109-
'minSize'
109+
'minSize',
110+
'enableCommandMonitoring'
110111
];
111112

112113
var ignoreOptionNames = ['native_parser'];
@@ -199,6 +200,7 @@ function validOptions(options) {
199200
* @param {array} [options.readPreferenceTags=null] Read preference tags
200201
* @param {number} [options.numberOfRetries=5] The number of retries for a tailable cursor
201202
* @param {boolean} [options.auto_reconnect=true] Enable auto reconnecting for single server instances
203+
* @param {boolean} [options.enableCommandMonitoring=false] Enable command monitoring for this client
202204
* @param {MongoClient~connectCallback} [callback] The command result callback
203205
* @return {MongoClient} a MongoClient instance
204206
*/

lib/topologies/mongos.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ var legalOptionNames = [
5858
'promoteLongs',
5959
'promoteValues',
6060
'promoteBuffers',
61-
'promiseLibrary'
61+
'promiseLibrary',
62+
'enableCommandMonitoring'
6263
];
6364

6465
/**
@@ -149,7 +150,11 @@ class Mongos extends TopologyBase {
149150
cursorFactory: Cursor,
150151
reconnect: reconnect,
151152
emitError: typeof options.emitError === 'boolean' ? options.emitError : true,
152-
size: typeof options.poolSize === 'number' ? options.poolSize : 5
153+
size: typeof options.poolSize === 'number' ? options.poolSize : 5,
154+
enableCommandMonitoring:
155+
typeof options.enableCommandMonitoring === 'boolean'
156+
? options.enableCommandMonitoring
157+
: false
153158
}
154159
);
155160

lib/topologies/replset.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ var legalOptionNames = [
6666
'promoteBuffers',
6767
'maxStalenessSeconds',
6868
'promiseLibrary',
69-
'minSize'
69+
'minSize',
70+
'enableCommandMonitoring'
7071
];
7172

7273
/**
@@ -156,7 +157,11 @@ class ReplSet extends TopologyBase {
156157
cursorFactory: Cursor,
157158
reconnect: false,
158159
emitError: typeof options.emitError === 'boolean' ? options.emitError : true,
159-
size: typeof options.poolSize === 'number' ? options.poolSize : 5
160+
size: typeof options.poolSize === 'number' ? options.poolSize : 5,
161+
enableCommandMonitoring:
162+
typeof options.enableCommandMonitoring === 'boolean'
163+
? options.enableCommandMonitoring
164+
: false
160165
}
161166
);
162167

lib/topologies/server.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ var legalOptionNames = [
6161
'promoteValues',
6262
'promoteBuffers',
6363
'compression',
64-
'promiseLibrary'
64+
'promiseLibrary',
65+
'enableCommandMonitoring'
6566
];
6667

6768
/**
@@ -149,7 +150,11 @@ class Server extends TopologyBase {
149150
cursorFactory: Cursor,
150151
reconnect: reconnect,
151152
emitError: typeof options.emitError === 'boolean' ? options.emitError : true,
152-
size: typeof options.poolSize === 'number' ? options.poolSize : 5
153+
size: typeof options.poolSize === 'number' ? options.poolSize : 5,
154+
enableCommandMonitoring:
155+
typeof options.enableCommandMonitoring === 'boolean'
156+
? options.enableCommandMonitoring
157+
: false
153158
}
154159
);
155160

0 commit comments

Comments
 (0)