2
2
Monitoring
3
3
==========
4
4
5
-
6
-
7
5
.. contents:: On this page
8
6
:local:
9
7
:backlinks: none
@@ -13,31 +11,26 @@ Monitoring
13
11
Overview
14
12
--------
15
13
16
- .. What is on this page?
17
-
18
14
In this guide, you can learn how to set up and configure **monitoring** in the
19
- MongoDB Java driver.
20
-
21
- .. What do any new terms mean?
15
+ {+driver-long+}.
22
16
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
17
+ Monitoring is the process of getting information about the activities a
18
+ running program performs for use in an application or an application performance
25
19
management library.
26
20
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 your application lets you understand the driver's resource usage
22
+ and performance and can help you make informed
29
23
decisions when designing and debugging your application.
30
24
31
- .. What can you expect to see on this page?
32
-
33
25
In this guide you will learn how to perform these tasks:
34
26
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>`
37
30
38
31
This guide shows how to use information about the activity of the driver in code.
39
32
If you would like to learn how to record events in the driver,
40
- consider reading our :doc:`guide on logging </ logging>`.
33
+ see the {+driver-short+}'s :ref:`Logging < logging>` guide.
41
34
42
35
.. _monitoring-monitor-events:
43
36
@@ -65,8 +58,10 @@ The MongoDB Java driver organizes the events it defines into three categories:
65
58
66
59
The following sections show how to monitor each event category.
67
60
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 event package of the
62
+ MongoDB Java Driver <{+api+}/apidocs/mongodb-driver-core/com/mongodb/event/package-summary.html>`__.
63
+
64
+ .. fix this link text^
70
65
71
66
.. _command-events-java:
72
67
@@ -81,13 +76,16 @@ To monitor command events, write a class that implements the
81
76
``CommandListener`` interface and register an instance of that class with your
82
77
``MongoClient`` instance.
83
78
84
- For more information about MongoDB database commands, see the
85
- :manual:`MongoDB manual entry on database commands </reference/command/>`.
79
+ To learn more about MongoDB database commands, see the
80
+ :manual:`MongoDB manual entry on database commands </reference/command/>` in the
81
+ Server (or MongoDB?) Manual.
82
+
83
+ .. fix this link ^
86
84
87
85
.. note:: Internal Commands
88
86
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
87
+ The {+ driver-short+} does not publish events for commands it calls internally.
88
+ This includes database commands the driver uses to monitor your cluster and
91
89
commands related to connection establishment (such as the initial ``hello``
92
90
command).
93
91
@@ -98,6 +96,8 @@ For more information about MongoDB database commands, see the
98
96
full list of redacted command events, see the
99
97
:spec:`MongoDB command logging and monitoring specification </command-logging-and-monitoring/command-logging-and-monitoring.rst#security>`.
100
98
99
+ .. ^fix this link
100
+
101
101
Example
102
102
^^^^^^^
103
103
@@ -109,7 +109,7 @@ To make a counter, do the following:
109
109
110
110
#. Make a class with counter functionality that implements the ``CommandListener`` interface.
111
111
#. Add an instance of the new class that implements ``CommandListener`` to a ``MongoClientSettings`` object.
112
- #. Configure a ``MongoClient`` instance with the ``MongoClientSettings`` object.
112
+ #. Configure a ``MongoClient`` instance by using the ``MongoClientSettings`` object.
113
113
114
114
The following code defines the ``CommandCounter`` class which implements the
115
115
``CommandListener`` interface:
@@ -121,8 +121,8 @@ The following code defines the ``CommandCounter`` class which implements the
121
121
:end-before: end command-listener-impl
122
122
123
123
The 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
124
+ ``MongoClientSettings`` object, and configures a ``MongoClient`` instance by using the
125
+ ``MongoClientSettings`` object. The code then runs sample ``find()`` commands to test the
126
126
counter.
127
127
128
128
.. _listener-mongo-client-settings-example:
@@ -142,7 +142,7 @@ The preceding code snippet produces output that resembles the following:
142
142
{find=2}
143
143
{find=2, endSessions=1}
144
144
145
- For more information about the classes and methods mentioned in this section, see
145
+ To learn more about the classes and methods mentioned in this section, see
146
146
the following API Documentation:
147
147
148
148
- `CommandListener <{+api+}/apidocs/mongodb-driver-core/com/mongodb/event/CommandListener.html>`__
@@ -159,8 +159,8 @@ A server discovery and monitoring (SDAM) event is an event related to a change
159
159
in the state of the MongoDB instance or cluster you have connected the driver to.
160
160
161
161
The 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:
162
+ between three separate listener interfaces. The following are the three interfaces
163
+ and the events they listen for:
164
164
165
165
- ``ClusterListener``: :spec:`topology </server-discovery-and-monitoring/server-discovery-and-monitoring.md#topology>`
166
166
related events
@@ -172,11 +172,14 @@ implements one of the three preceding interfaces and register an instance of tha
172
172
class with your ``MongoClient`` instance.
173
173
174
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>`.
175
+ :spec:`MongoDB SDAM Logging and Monitoring Specification
176
+ </server-discovery-and-monitoring/server-discovery-and-monitoring-logging-and-monitoring.md#events-api>`.
176
177
177
178
.. note:: Load Balanced Mode
178
179
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>`.
180
+ The driver doesn't emit heartbeat related events when in load balanced mode.
181
+ To learn more about SDAM events with load balancing, see
182
+ :spec:`MongoDB Load Balancer Support Specification </load-balancers/load-balancers.md#server-discovery-logging-and-monitoring>`.
180
183
181
184
Example
182
185
^^^^^^^
@@ -203,7 +206,8 @@ The following code adds an instance of the ``IsWritable`` class to a
203
206
:start-after: start monitor-cluster-example
204
207
:end-before: end monitor-cluster-example
205
208
206
- The preceding code snippet produces output that resembles the following:
209
+ The preceding code snippet produces a confirmation message that resembles the
210
+ following:
207
211
208
212
.. code-block:: none
209
213
:copyable: false
@@ -226,8 +230,12 @@ Connection Pool Events
226
230
A connection pool event is an event related to a **connection pool** held by the driver.
227
231
A connection pool is a set of open TCP connections your driver maintains with
228
232
a 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.
233
+ your application needs to perform with a MongoDB instance and can help your
234
+ application run faster.
235
+
236
+ .. Add when page is ready: To learn more about connection pools, see the {+driver-short+}'s
237
+ .. :ref:`Connection Pools <connection-pools>` guide.
238
+
231
239
232
240
To monitor connection pool events, write a class that implements the
233
241
``ConnectionPoolListener`` interface and register an instance of that class with your
@@ -240,7 +248,7 @@ This example shows how to make a listener class that prints a message each time
240
248
you check out a connection from your connection pool.
241
249
242
250
The following code defines the ``ConnectionPoolLibrarian`` class which implements the
243
- ``ConnectionPoolListener`` interface.
251
+ ``ConnectionPoolListener`` interface:
244
252
245
253
.. literalinclude:: /includes/fundamentals/code-snippets/Monitoring.java
246
254
:language: java
@@ -250,7 +258,7 @@ The following code defines the ``ConnectionPoolLibrarian`` class which implement
250
258
251
259
The following code adds an instance of the ``ConnectionPoolLibrarian`` class to a
252
260
``MongoClient`` object. The code then runs a database command to test the
253
- librarian.
261
+ librarian:
254
262
255
263
.. literalinclude:: /includes/fundamentals/code-snippets/Monitoring.java
256
264
:language: java
@@ -282,8 +290,8 @@ Monitor Connection Pool Events with JMX
282
290
You can monitor connection pool events using **Java Management Extensions (JMX)**.
283
291
JMX provides tools to monitor applications and devices.
284
292
285
- For more information about JMX, see
286
- `the official Oracle JMX documentation <https://docs.oracle.com/javase/tutorial/jmx/index.html>`__.
293
+ To learn more information about JMX, see the official
294
+ `Oracle JMX documentation <https://docs.oracle.com/javase/tutorial/jmx/index.html>`__.
287
295
288
296
JMX Support
289
297
~~~~~~~~~~~
@@ -333,7 +341,7 @@ MXBeans registered on the platform MBean server have the following properties:
333
341
All MXBean instances created by the driver are under the domain
334
342
``"org.mongodb.driver"``.
335
343
336
- For more information about the topics discussed in this subsection, see the
344
+ To learn more about the topics discussed in this subsection, see the
337
345
following resources from Oracle:
338
346
339
347
- `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>`__
@@ -358,7 +366,7 @@ the Java Platform.
358
366
359
367
The following code snippet adds a ``JMXConnectionPoolListener`` to a
360
368
``MongoClient`` instance. The code then pauses execution so you can
361
- navigate to JConsole and inspect your connection pools.
369
+ navigate to JConsole and inspect your connection pools:
362
370
363
371
.. literalinclude:: /includes/fundamentals/code-snippets/JMXMonitoring.java
364
372
:language: java
@@ -393,13 +401,13 @@ following:
393
401
- Exit JConsole by closing the JConsole window
394
402
- Stop the Java program running the preceding code snippet
395
403
396
- For more information about JMX and JConsole, see the following resources from
404
+ To learn more about JMX and JConsole, see the following resources from
397
405
Oracle:
398
406
399
407
- `JConsole Documentation <https://www.oracle.com/technical-resources/articles/java/jconsole.html>`__.
400
408
- `Monitoring and Management Guide <https://docs.oracle.com/en/java/javase/16/management/monitoring-and-management-using-jmx-technology.html>`__
401
409
402
- For more information about the ``JMXConnectionPoolListener`` class, see
410
+ To learn more about the ``JMXConnectionPoolListener`` class, see
403
411
the API Documentation for
404
412
`JMXConnectionPoolListener <{+api+}/apidocs/mongodb-driver-core/com/mongodb/management/JMXConnectionPoolListener.html>`__.
405
413
@@ -418,8 +426,8 @@ include MongoDB event data in the
418
426
`Zipkin <https://zipkin.io/>`__ distributed tracing system.
419
427
420
428
If 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>`__
429
+ tracing system other than Zipkin, you must write a command event listener that manages
430
+ `spans <https://docs.spring.io/spring-cloud-sleuth/docs/current-SNAPSHOT/reference/html/getting-started.html#getting-started-terminology>`__
423
431
for your desired distributed tracing system. To see an implementation of such a
424
432
listener, see the
425
433
:github:`TraceMongoCommandListener
0 commit comments