@@ -67,7 +67,7 @@ var legalOptionNames = [
67
67
'maxStalenessSeconds' ,
68
68
'promiseLibrary' ,
69
69
'minSize' ,
70
- 'enableCommandMonitoring '
70
+ 'monitorCommands '
71
71
] ;
72
72
73
73
/**
@@ -101,6 +101,7 @@ var legalOptionNames = [
101
101
* @param {number } [options.socketOptions.socketTimeoutMS=0] TCP Socket timeout setting
102
102
* @param {boolean } [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit.
103
103
* @param {number } [options.maxStalenessSeconds=undefined] The max staleness to secondary reads (values under 10 seconds cannot be guaranteed);
104
+ * @param {boolean } [options.monitorCommands=false] Enable command monitoring for this topology
104
105
* @fires ReplSet#connect
105
106
* @fires ReplSet#ha
106
107
* @fires ReplSet#joined
@@ -111,6 +112,9 @@ var legalOptionNames = [
111
112
* @fires ReplSet#error
112
113
* @fires ReplSet#timeout
113
114
* @fires ReplSet#parseError
115
+ * @fires ReplSet#commandStarted
116
+ * @fires ReplSet#commandSucceeded
117
+ * @fires ReplSet#commandFailed
114
118
* @property {string } parserType the parser type used (c++ or js).
115
119
* @return {ReplSet } a ReplSet instance.
116
120
*/
@@ -158,10 +162,8 @@ class ReplSet extends TopologyBase {
158
162
reconnect : false ,
159
163
emitError : typeof options . emitError === 'boolean' ? options . emitError : true ,
160
164
size : typeof options . poolSize === 'number' ? options . poolSize : 5 ,
161
- enableCommandMonitoring :
162
- typeof options . enableCommandMonitoring === 'boolean'
163
- ? options . enableCommandMonitoring
164
- : false
165
+ monitorCommands :
166
+ typeof options . monitorCommands === 'boolean' ? options . monitorCommands : false
165
167
}
166
168
) ;
167
169
@@ -498,4 +500,25 @@ define.classMethod('connections', { callback: false, promise: false, returns: [A
498
500
* @type {object }
499
501
*/
500
502
503
+ /**
504
+ * An event emitted indicating a command was started, if command monitoring is enabled
505
+ *
506
+ * @event ReplSet#commandStarted
507
+ * @type {object }
508
+ */
509
+
510
+ /**
511
+ * An event emitted indicating a command succeeded, if command monitoring is enabled
512
+ *
513
+ * @event ReplSet#commandSucceeded
514
+ * @type {object }
515
+ */
516
+
517
+ /**
518
+ * An event emitted indicating a command failed, if command monitoring is enabled
519
+ *
520
+ * @event ReplSet#commandFailed
521
+ * @type {object }
522
+ */
523
+
501
524
module . exports = ReplSet ;
0 commit comments