-
Notifications
You must be signed in to change notification settings - Fork 34
DOCSP-41982: cluster monitoring #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOCSP-41982: cluster monitoring #144
Conversation
✅ Deploy Preview for docs-php-library ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! A few very small changes
- Description | ||
|
||
* - ``ServerChangedEvent`` | ||
- Created when an instance state changes, such as from secondary to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: Could remove "Created when" from the start of every event (probably along with a new column header name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a good way to adjust the column header, as renaming it "Situation that Triggers Event" seems worse than keeping the "Created when"s in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the docs for ServerChangedEvent we say the event class "encapsulates information about a changed server description".
Here, the table is presenting the event as the thing that happened instead of just an object containing some information about a thing that happened.
The "Condition" column in Events API from the driver spec might be helpful. Note that the spec includes "Description" in the name of these events, where PHP just calls it ServerChangedEvent. I think that was due to us copying the shorter name from our libmongoc dependency.
I might suggest:
When the server description changes, such as the server's type changing from secondary to primary.
a36de3e
to
fce8972
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
source/includes/monitoring/sdam.php
Outdated
{ | ||
$this->stream = $stream; | ||
} | ||
public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void | |
public function serverOpening(MongoDB\Driver\Monitoring\ServerOpeningEvent $event): void |
Also, between any methods with bodies.
public function serverHeartbeatSucceeded(MongoDB\Driver\Monitoring\ServerHeartbeatSucceededEvent $event): void {} | ||
public function topologyChanged(MongoDB\Driver\Monitoring\TopologyChangedEvent $event): void {} | ||
public function topologyClosed(MongoDB\Driver\Monitoring\TopologyClosedEvent $event): void {} | ||
public function topologyOpening(MongoDB\Driver\Monitoring\TopologyOpeningEvent $event): void {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe contravariance would allow us to remove the type hints from these methods and make the code more concise. See: https://3v4l.org/H34oT#v8.3.11
That said, it'd make the example code less useful for copying if users want to implement these methods themselves. I'm fine to leave these as-is.
/cc @alcaeus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omitting the types would make the example more concise, but I'd like to avoid suggesting to do this in documentation, as I consider it bad practice. We could leverage use
statements to shorten the types, but that may be difficult if only small snippets of this code are included in the documentation.
We face a similar issue with the other documentation examples used in the server docs, and we decided to just deal with the long types in favour of having copy-pastable code.
|
||
This guide shows you how to use the {+php-library+} to monitor topology | ||
events in a MongoDB instance, replica set, or sharded cluster. The | ||
driver creates topology events, also known as Server Discovery and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, topology events are those related to the entire cluster, while server events are those pertaining to a single server within the topology. SDAM monitoring includes both types of events.
I would personally just refer to them as SDAM events, as you seem to do in a subsequent section. If you need a short name, "cluster events" might also work but there's no prior art for that in any driver spec.
Disregard if this name was intentionally chosen for consistency with existing driver docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know, in general it is ok if this page differs from the same page in other docs. Each docs standardization is meant to improve on previous ones!
- Description | ||
|
||
* - ``ServerChangedEvent`` | ||
- Created when an instance state changes, such as from secondary to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the docs for ServerChangedEvent we say the event class "encapsulates information about a changed server description".
Here, the table is presenting the event as the thing that happened instead of just an object containing some information about a thing that happened.
The "Condition" column in Events API from the driver spec might be helpful. Note that the spec includes "Description" in the name of these events, where PHP just calls it ServerChangedEvent. I think that was due to us copying the shorter name from our libmongoc dependency.
I might suggest:
When the server description changes, such as the server's type changing from secondary to primary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggested rewording, but I want to wait until I hear back from other folks in drivers before signing off on the ServerOpeningEvent text.
|
||
* - ``TopologyClosedEvent`` | ||
* - :php:`TopologyClosedEvent <mongodb-driver-monitoring-topologyclosedevent>` | ||
- Created when the topology is closed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd reword this as "the driver disconnects from the cluster". Given the event name, I don't think we need to repeat "topology is closed" in the description, although you can still include both if you like. In that case, maybe note the disconnect behavior with "i.e." or something.
Per the SDAM Monitoring spec, this would always be the last event to be dispatched. In the PHP driver, it's not actually possible to observe this event when using default behavior, as we persist the libmongoc client object (and thus the connections) beyond the lifetime of the PHP script. So by the time a client is actually closed, there'd be no subscriber in memory to receive the event.
This event can only be observed when specifying disableClientPersistence: true
in the Manager or Client driver options array. There's more context to be found in PHPC-2023 and mongodb/mongo-php-driver@c2410ab.
Having said that, I think it's sufficient to just refer to disconnecting from the cluster here. And admittedly, we (the PHP team) should improve the docs for these event classes. I created PHPC-2449 to track that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for providing this background!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with my suggestions applied.
- Created when the driver disconnects from the cluster. | ||
|
||
* - :php:`ServerHeartbeatStartedEvent <mongodb-driver-monitoring-serverheartbeatstartedevent>` | ||
- Created when the server monitor sends a ``hello`` call to the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Created when the server monitor sends a ``hello`` call to the server. | |
- Created when the server monitor sends a ``hello`` command to the server. |
"Command" is less ambiguous.
- Created when a server connection is closed. | ||
|
||
* - :php:`TopologyChangedEvent <mongodb-driver-monitoring-topologychangedevent>` | ||
- Created when the topology description changes, such when there is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you accidentally a word in this sentence.
- Created when the topology description changes, such when there is | |
- Created when the topology description changes, such as when there is |
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-41982
Staging - https://deploy-preview-144--docs-php-library.netlify.app/monitoring/cluster-monitoring/
Self-Review Checklist