-
Notifications
You must be signed in to change notification settings - Fork 13
DOCSP-43082: Cluster monitoring #63
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-43082: Cluster monitoring #63
Conversation
✅ Deploy Preview for docs-c 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.
LGTM with some small things!
actions: | ||
|
||
- Defines a ``server_opening()`` event handler function, or callback | ||
- Creates a ``mongoc_apm_callbacks_t`` to store callbacks |
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.
- Creates a ``mongoc_apm_callbacks_t`` to store callbacks | |
- Creates a ``mongoc_apm_callbacks_t`` instance to store callbacks |
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.
Is it accurate to use "instance" with C? "Structure" might be a better word
in your application. To subscribe to an event, create a value of | ||
type ``mongoc_apm_callbacks_t`` and create an event callback function | ||
for the event you want to subscribe to. Use the callback's corresponding | ||
setter method to set the callback on the ``mongoc_apm_callbacks_t`` and | ||
pass this type to the ``mongoc_client_set_apm_callbacks()`` function. |
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.
Recommended rewording:
To subscribe to an event, define a callback function to handle each event type you want to subscribe to. Use a
mongoc_apm_callbacks_t
object to register the list of APM callbacks with a client object usingmongoc_client_set_apm_callbacks()
.
There is a lot of overlap with the actual code example below. Wordy details can be delegated to the code example.
Also recommend referring to these user-defined functions as "APM callbacks" or "APM callback functions" for consistency with C Driver API documentation.
This code monitors server opening events by performing the following | ||
actions: | ||
|
||
- Defines a ``server_opening()`` event handler function, or callback |
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.
- Defines a ``server_opening()`` event handler function, or callback | |
- Defines a ``server_opening()`` APM callback function |
For consistent terminology.
actions: | ||
|
||
- Defines a ``server_opening()`` event handler function, or callback | ||
- Creates a ``mongoc_apm_callbacks_t`` structure to store callbacks |
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.
- Creates a ``mongoc_apm_callbacks_t`` structure to store callbacks | |
- Creates a ``mongoc_apm_callbacks_t`` object to store callbacks |
- Calls the ``mongoc_apm_set_server_opening_cb()`` function, which instructs | ||
the ``mongoc_apm_callbacks_t`` type to store a pointer to the ``server_opening()`` | ||
callback |
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.
- Calls the ``mongoc_apm_set_server_opening_cb()`` function, which instructs | |
the ``mongoc_apm_callbacks_t`` type to store a pointer to the ``server_opening()`` | |
callback | |
- Calls the ``mongoc_apm_set_server_opening_cb()`` function, which stores a pointer to the provided APM callback function in the ``mongoc_apm_callbacks_t`` object |
the ``mongoc_apm_callbacks_t`` type to store a pointer to the ``server_opening()`` | ||
callback | ||
- Calls the ``mongoc_client_set_apm_callbacks()`` function, which registers | ||
the callback with the client |
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.
the callback with the client | |
the list of callbacks in the ``mongoc_apm_callbacks_t`` object with the client |
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.
There's only one callback in this code example (server_opening()) rather than a list so I reworded slightly
source/includes/monitoring/sdam.c
Outdated
stats_t *context; | ||
|
||
context = (stats_t *) mongoc_apm_server_opening_get_context (event); | ||
context->server_opening_events++; |
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.
stats_t *context; | |
context = (stats_t *) mongoc_apm_server_opening_get_context (event); | |
context->server_opening_events++; | |
stats_t *stats = (stats_t *) mongoc_apm_server_opening_get_context (event); | |
stats->server_opening_events += 1; |
source/includes/monitoring/sdam.c
Outdated
mongoc_client_t *client; | ||
mongoc_apm_callbacks_t *cbs | ||
stats_t stats = {0}; |
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.
mongoc_client_t *client; | |
mongoc_apm_callbacks_t *cbs | |
stats_t stats = {0}; |
Avoid C89/C90 style declarations.
Also recommend including use of the stats
object.
int
main (void)
{
mongoc_init ();
stats_t stats = {0};
mongoc_client_t *client = mongoc_client_new ("<connection string URI>");
{
mongoc_apm_callbacks_t *cbs = mongoc_apm_callbacks_new ();
mongoc_apm_set_server_opening_cb (cbs, server_opening);
mongoc_client_set_apm_callbacks (client, cbs, &stats);
mongoc_apm_callbacks_destroy (cbs);
}
// Perform database operations.
mongoc_client_destroy (client);
printf ("Observed %d server opening events\n", stats.server_opening_events);
mongoc_cleanup ();
return EXIT_SUCCESS;
}
source/includes/monitoring/sdam.c
Outdated
mongoc_cleanup (); | ||
|
||
return EXIT_SUCCESS; | ||
} |
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.
} | |
} | |
Missing EOF newline.
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.
Minor feedback remaining; otherwise, LGTM.
Server opening on ac-rmuag0v-shard-00-00.gh0qg50.mongodb.net:27017 | ||
Server opening on ac-rmuag0v-shard-00-01.gh0qg50.mongodb.net:27017 | ||
Server opening on ac-rmuag0v-shard-00-02.gh0qg50.mongodb.net:27017 |
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.
These examples seem a bit noisy / unnecessarily specific ("ac-rmuag0v"? "gh0qg50"?). Can they be simplified?
------------------ | ||
|
||
You can subscribe to SDAM events by defining the corresponding | ||
event callback function. The following table provides the name of |
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.
event callback function. The following table provides the name of | |
APM callback function. The following table provides the name of |
Consistency.
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-43082
Staging - https://deploy-preview-63--docs-c.netlify.app/monitoring/cluster-monitoring/
Self-Review Checklist