Skip to content

Commit aa7e5ee

Browse files
authored
DOCSP-47042 Monitoring Edits (#633)
* DOCSP-47042 Monitoring * code edits * more edits * edits * tech review * monitoring def edit
1 parent d9b266f commit aa7e5ee

File tree

2 files changed

+59
-55
lines changed

2 files changed

+59
-55
lines changed

source/includes/fundamentals/code-snippets/Monitoring.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private void monitorCommandEvent() {
4242
MongoClient mongoClient = MongoClients.create(settings);
4343
MongoDatabase database = mongoClient.getDatabase(DATABASE);
4444
MongoCollection<Document> collection = database.getCollection(COLLECTION);
45-
// Run some commands to test the timer
45+
// Runs sample find() commands to test the timer
4646
collection.find().first();
4747
collection.find().first();
4848
mongoClient.close();
@@ -61,7 +61,7 @@ private void monitorClusterEvent() {
6161
MongoClient mongoClient = MongoClients.create(settings);
6262
MongoDatabase database = mongoClient.getDatabase(DATABASE);
6363
MongoCollection<Document> collection = database.getCollection(COLLECTION);
64-
// Run a command to trigger a ClusterDescriptionChangedEvent event
64+
// Runs a sample find() command to trigger a ClusterDescriptionChangedEvent event
6565
collection.find().first();
6666
// end monitor-cluster-example
6767
mongoClient.close();
@@ -79,7 +79,7 @@ private void monitorConnectionPoolEvent() {
7979
MongoClient mongoClient = MongoClients.create(settings);
8080
MongoDatabase database = mongoClient.getDatabase(DATABASE);
8181
MongoCollection<Document> collection = database.getCollection(COLLECTION);
82-
// Run a command to trigger connection pool events
82+
// Runs a sample find() command to trigger connection pool events
8383
collection.find().first();
8484
// end monitor-cp-example
8585
/* We do not close this connection in order to prevent the driver from requesting two connections, giving

source/logging-monitoring/monitoring.txt

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
Monitoring
33
==========
44

5-
6-
75
.. contents:: On this page
86
:local:
97
:backlinks: none
@@ -13,31 +11,26 @@ Monitoring
1311
Overview
1412
--------
1513

16-
.. What is on this page?
17-
1814
In 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
2923
decisions when designing and debugging your application.
3024

31-
.. What can you expect to see on this page?
32-
3325
In 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

3831
This 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

6659
The 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

10196
Example
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

114109
The 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

123118
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
119+
``MongoClientSettings`` object, and configures a ``MongoClient`` instance by using the
120+
``MongoClientSettings`` object. The code then runs sample ``find()`` commands to test the
126121
counter.
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
146141
the 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
159154
in the state of the MongoDB instance or cluster you have connected the driver to.
160155

161156
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:
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
171166
implements one of the three preceding interfaces and register an instance of that
172167
class 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

181181
Example
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
226227
A connection pool event is an event related to a **connection pool** held by the driver.
227228
A connection pool is a set of open TCP connections your driver maintains with
228229
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.
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

232236
To 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
240244
you check out a connection from your connection pool.
241245

242246
The 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

251255
The 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
282286
You can monitor connection pool events using **Java Management Extensions (JMX)**.
283287
JMX 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

288292
JMX Support
289293
~~~~~~~~~~~
@@ -333,12 +337,12 @@ MXBeans registered on the platform MBean server have the following properties:
333337
All 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
337341
following 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

343347
JMX 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

359363
The 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
397401
Oracle:
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
403407
the 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

420424
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>`__
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>`__
423427
for your desired distributed tracing system. To see an implementation of such a
424428
listener, see the
425429
:github:`TraceMongoCommandListener

0 commit comments

Comments
 (0)