22Monitoring
33==========
44
5-
6-
75.. contents:: On this page
86 :local:
97 :backlinks: none
@@ -13,31 +11,26 @@ Monitoring
1311Overview
1412--------
1513
16- .. What is on this page?
17-
1814In this guide, you can learn how to set up and configure **monitoring** in the
19- MongoDB Java driver.
15+ {+ driver-long+} .
2016
21- .. What do any new terms mean?
17+ Monitoring involves collecting information about the activities of a running
18+ program, which you can use with an application performance management
19+ library.
2220
23- Monitoring is the process of getting information about the activities a running
24- program performs for use in an application or an application performance
25- management library.
26-
27- Monitoring the MongoDB Java driver lets you understand the
28- driver's resource usage and performance, and can help you make informed
21+ Monitoring the {+driver-short+} lets you understand the driver's resource usage
22+ and performance and can help you make informed
2923decisions when designing and debugging your application.
3024
31- .. What can you expect to see on this page?
32-
3325In this guide you will learn how to perform these tasks:
3426
35- - :ref:`Monitor different types of events in the MongoDB Java Driver <monitoring-monitor-events>`
36- - :ref:`Monitor connection pool events with Java Management Extensions (JMX) and JConsole <monitoring-jmx>`
27+ - :ref:`Monitor Events <monitoring-monitor-events>`
28+ - :ref:`Monitor Connection Pool Events with Java Management Extensions (JMX)
29+ and JConsole <monitoring-jmx>`
3730
3831This guide shows how to use information about the activity of the driver in code.
39- If you would like to learn how to record events in the driver,
40- consider reading our :doc:`guide on logging </ logging>`.
32+ To learn how to record events in the driver, see the {+driver-short+}'s
33+ :ref:`Logging < logging>` guide.
4134
4235.. _monitoring-monitor-events:
4336
@@ -65,8 +58,8 @@ The MongoDB Java driver organizes the events it defines into three categories:
6558
6659The following sections show how to monitor each event category.
6760
68- For a full list of the events you can monitor,
69- `see the event package of the MongoDB Java Driver <{+api+}/apidocs/mongodb-driver-core/com/mongodb/event/package-summary.html>`__.
61+ To learn more about the events you can monitor, see the API documentation for `event classes
62+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/event/package-summary.html>`__.
7063
7164.. _command-events-java:
7265
@@ -81,13 +74,14 @@ To monitor command events, write a class that implements the
8174``CommandListener`` interface and register an instance of that class with your
8275``MongoClient`` instance.
8376
84- For more information about MongoDB database commands, see the
85- :manual:`MongoDB manual entry on database commands </reference/command/>`.
77+ To learn more about MongoDB database commands, see the
78+ :manual:`Database Commands </reference/command/>` guide in the
79+ Server Manual.
8680
8781.. note:: Internal Commands
8882
89- The driver does not publish events for commands it calls internally. This
90- includes database commands the driver uses to monitor your cluster and
83+ The {+ driver-short+} does not publish events for commands it calls internally.
84+ This includes database commands the driver uses to monitor your cluster and
9185 commands related to connection establishment (such as the initial ``hello``
9286 command).
9387
@@ -96,7 +90,8 @@ For more information about MongoDB database commands, see the
9690 As a security measure, the driver redacts the contents of some command events. This
9791 protects the sensitive information contained in these command events. For a
9892 full list of redacted command events, see the
99- :spec:`MongoDB command logging and monitoring specification </command-logging-and-monitoring/command-logging-and-monitoring.rst#security>`.
93+ :spec:`Security </command-logging-and-monitoring/command-logging-and-monitoring.md#security>`
94+ section of the MongoDB Command Logging and Monitoring specification in GitHub.
10095
10196Example
10297^^^^^^^
@@ -109,7 +104,7 @@ To make a counter, do the following:
109104
110105#. Make a class with counter functionality that implements the ``CommandListener`` interface.
111106#. Add an instance of the new class that implements ``CommandListener`` to a ``MongoClientSettings`` object.
112- #. Configure a ``MongoClient`` instance with the ``MongoClientSettings`` object.
107+ #. Configure a ``MongoClient`` instance by using the ``MongoClientSettings`` object.
113108
114109The following code defines the ``CommandCounter`` class which implements the
115110``CommandListener`` interface:
@@ -121,8 +116,8 @@ The following code defines the ``CommandCounter`` class which implements the
121116 :end-before: end command-listener-impl
122117
123118The following code adds an instance of the ``CommandCounter`` class to a
124- ``MongoClientSettings`` object, and configures a ``MongoClient`` instance with the
125- ``MongoClientSettings`` object. The code then runs some database commands to test the
119+ ``MongoClientSettings`` object, and configures a ``MongoClient`` instance by using the
120+ ``MongoClientSettings`` object. The code then runs sample ``find()`` commands to test the
126121counter.
127122
128123.. _listener-mongo-client-settings-example:
@@ -142,7 +137,7 @@ The preceding code snippet produces output that resembles the following:
142137 {find=2}
143138 {find=2, endSessions=1}
144139
145- For more information about the classes and methods mentioned in this section, see
140+ To learn more about the classes and methods mentioned in this section, see
146141the following API Documentation:
147142
148143- `CommandListener <{+api+}/apidocs/mongodb-driver-core/com/mongodb/event/CommandListener.html>`__
@@ -159,8 +154,8 @@ A server discovery and monitoring (SDAM) event is an event related to a change
159154in the state of the MongoDB instance or cluster you have connected the driver to.
160155
161156The driver defines nine SDAM events. The driver divides these nine events
162- between three separate listener interfaces which each listen for three of the
163- nine events. Here are the three interfaces and the events they listen for:
157+ between three separate listener interfaces. The following are the three interfaces
158+ and the events they listen for:
164159
165160- ``ClusterListener``: :spec:`topology </server-discovery-and-monitoring/server-discovery-and-monitoring.md#topology>`
166161 related events
@@ -171,12 +166,17 @@ To monitor a type of SDAM event, write a class that
171166implements one of the three preceding interfaces and register an instance of that
172167class with your ``MongoClient`` instance.
173168
174- For a detailed description of each SDAM event in the driver, see the
175- :spec:`MongoDB SDAM Logging and Monitoring Specification </server-discovery-and-monitoring/server-discovery-and-monitoring-logging-and-monitoring.md#events-api>`.
169+ For a detailed description of each SDAM event in the driver, see the
170+ :spec:`Server API
171+ </server-discovery-and-monitoring/server-discovery-and-monitoring-logging-and-monitoring.md#events-api>`
172+ section of th MongoDB SDAM Logging and Monitoring Specification in GitHub.
176173
177174.. note:: Load Balanced Mode
178175
179- The driver doesn't emit heartbeat related events when in load balanced mode. For more details about SDAM events with load balancing, see :spec:`MongoDB Load Balancer Support Specification </load-balancers/load-balancers.md#server-discovery-logging-and-monitoring>`.
176+ The driver doesn't emit heartbeat related events when in load balanced mode.
177+ To learn more about SDAM events with load balancing, see the
178+ :spec:`Server Discovery Logging and Monitoring </load-balancers/load-balancers.md#server-discovery-logging-and-monitoring>`
179+ section of the MongoDB Load Balancer Support Specification in GitHub.
180180
181181Example
182182^^^^^^^
@@ -203,7 +203,8 @@ The following code adds an instance of the ``IsWritable`` class to a
203203 :start-after: start monitor-cluster-example
204204 :end-before: end monitor-cluster-example
205205
206- The preceding code snippet produces output that resembles the following:
206+ The preceding code snippet produces a confirmation message that resembles the
207+ following:
207208
208209.. code-block:: none
209210 :copyable: false
@@ -226,8 +227,11 @@ Connection Pool Events
226227A connection pool event is an event related to a **connection pool** held by the driver.
227228A connection pool is a set of open TCP connections your driver maintains with
228229a MongoDB instance. Connection pools help reduce the number of network handshakes
229- your application needs to perform with a MongoDB instance, and can help your
230- application run faster.
230+ your application needs to perform with a MongoDB instance and can help your
231+ application run faster.
232+
233+ .. Add when page is ready: To learn more about connection pools, see the {+driver-short+}'s
234+ .. :ref:`Connection Pools <connection-pools>` guide.
231235
232236To monitor connection pool events, write a class that implements the
233237``ConnectionPoolListener`` interface and register an instance of that class with your
@@ -240,7 +244,7 @@ This example shows how to make a listener class that prints a message each time
240244you check out a connection from your connection pool.
241245
242246The following code defines the ``ConnectionPoolLibrarian`` class which implements the
243- ``ConnectionPoolListener`` interface.
247+ ``ConnectionPoolListener`` interface:
244248
245249.. literalinclude:: /includes/fundamentals/code-snippets/Monitoring.java
246250 :language: java
@@ -250,7 +254,7 @@ The following code defines the ``ConnectionPoolLibrarian`` class which implement
250254
251255The following code adds an instance of the ``ConnectionPoolLibrarian`` class to a
252256``MongoClient`` object. The code then runs a database command to test the
253- librarian.
257+ librarian:
254258
255259.. literalinclude:: /includes/fundamentals/code-snippets/Monitoring.java
256260 :language: java
@@ -282,8 +286,8 @@ Monitor Connection Pool Events with JMX
282286You can monitor connection pool events using **Java Management Extensions (JMX)**.
283287JMX provides tools to monitor applications and devices.
284288
285- For more information about JMX, see
286- `the official Oracle JMX documentation <https://docs.oracle.com/javase/tutorial/jmx/index.html>`__.
289+ To learn more information about JMX, see the official
290+ `Oracle JMX documentation <https://docs.oracle.com/javase/tutorial/jmx/index.html>`__.
287291
288292JMX Support
289293~~~~~~~~~~~
@@ -333,12 +337,12 @@ MXBeans registered on the platform MBean server have the following properties:
333337All MXBean instances created by the driver are under the domain
334338``"org.mongodb.driver"``.
335339
336- For more information about the topics discussed in this subsection, see the
340+ To learn more about the topics discussed in this subsection, see the
337341following resources from Oracle:
338342
339- - `Platform MBean Server Reference Documentation <https://docs.oracle.com/en/java/javase/16/management/overview-java-se-monitoring-and-management.html#GUID-F7B9AB8A-F5A8-472A-AEC6-93B5B7FBE7CE>`__
340- - `MXBean Documentation <https://docs.oracle.com/javase/tutorial/jmx/mbeans/mxbeans.html>`__
341- - `MBean Documentation <https://docs.oracle.com/javase/tutorial/jmx/mbeans/standard.html>`__
343+ - `Platform MBean Server Reference documentation <https://docs.oracle.com/en/java/javase/16/management/overview-java-se-monitoring-and-management.html#GUID-F7B9AB8A-F5A8-472A-AEC6-93B5B7FBE7CE>`__
344+ - `MXBean documentation <https://docs.oracle.com/javase/tutorial/jmx/mbeans/mxbeans.html>`__
345+ - `MBean documentation <https://docs.oracle.com/javase/tutorial/jmx/mbeans/standard.html>`__
342346
343347JMX and JConsole Example
344348~~~~~~~~~~~~~~~~~~~~~~~~
@@ -353,12 +357,12 @@ the Java Platform.
353357 rather than a source of truth. For guaranteed up to date information, consult
354358 the following official Oracle resources:
355359
356- - `JConsole documentation <https://www.oracle.com/technical-resources/articles/java/jconsole.html>`__.
360+ - `JConsole documentation <https://www.oracle.com/technical-resources/articles/java/jconsole.html>`__
357361 - `JMX documentation <https://docs.oracle.com/javase/tutorial/jmx/index.html>`__
358362
359363The following code snippet adds a ``JMXConnectionPoolListener`` to a
360364``MongoClient`` instance. The code then pauses execution so you can
361- navigate to JConsole and inspect your connection pools.
365+ navigate to JConsole and inspect your connection pools:
362366
363367.. literalinclude:: /includes/fundamentals/code-snippets/JMXMonitoring.java
364368 :language: java
@@ -393,13 +397,13 @@ following:
393397- Exit JConsole by closing the JConsole window
394398- Stop the Java program running the preceding code snippet
395399
396- For more information about JMX and JConsole, see the following resources from
400+ To learn more about JMX and JConsole, see the following resources from
397401Oracle:
398402
399- - `JConsole Documentation <https://www.oracle.com/technical-resources/articles/java/jconsole.html>`__.
403+ - `JConsole documentation <https://www.oracle.com/technical-resources/articles/java/jconsole.html>`__.
400404- `Monitoring and Management Guide <https://docs.oracle.com/en/java/javase/16/management/monitoring-and-management-using-jmx-technology.html>`__
401405
402- For more information about the ``JMXConnectionPoolListener`` class, see
406+ To learn more about the ``JMXConnectionPoolListener`` class, see
403407the API Documentation for
404408`JMXConnectionPoolListener <{+api+}/apidocs/mongodb-driver-core/com/mongodb/management/JMXConnectionPoolListener.html>`__.
405409
@@ -418,8 +422,8 @@ include MongoDB event data in the
418422`Zipkin <https://zipkin.io/>`__ distributed tracing system.
419423
420424If you do not use Spring Cloud or need to include driver event data in a distributed
421- tracing system other than Zipkin, you must write a command event listener that
422- manages `spans <https://docs.spring.io/spring-cloud-sleuth/docs/current-SNAPSHOT/reference/html/getting-started.html#getting-started-terminology>`__
425+ tracing system other than Zipkin, you must write a command event listener that manages
426+ `spans <https://docs.spring.io/spring-cloud-sleuth/docs/current-SNAPSHOT/reference/html/getting-started.html#getting-started-terminology>`__
423427for your desired distributed tracing system. To see an implementation of such a
424428listener, see the
425429:github:`TraceMongoCommandListener
0 commit comments