Skip to content

Commit 06ad293

Browse files
DOCSP-22799 updated monitoring example (#324)
* updated monitoring example
1 parent 8008dcc commit 06ad293

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

source/code-snippets/monitoring/apm-subscribe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { MongoClient } = require("mongodb");
55
const uri =
66
"mongodb+srv://<clusterUrl>/?replicaSet=rs&writeConcern=majority";
77

8-
const client = new MongoClient(uri);
8+
const client = new MongoClient(uri, { monitorCommands:true });
99

1010
// Replace <event name> with the name of the event you are subscribing to.
1111
const eventName = "<event name>";

source/fundamentals/monitoring/command-monitoring.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ events created by the MongoDB deployment:
3030
.. literalinclude:: /code-snippets/monitoring/apm-subscribe.js
3131
:language: javascript
3232

33+
.. note::
34+
35+
Command monitoring is disabled by default. To enable command
36+
monitoring, pass the ``monitorCommands`` option as ``true`` to
37+
your ``MongoClient`` constructor.
38+
3339
Event Descriptions
3440
------------------
3541

0 commit comments

Comments
 (0)