Skip to content

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

Merged

Conversation

norareidy
Copy link
Collaborator

@norareidy norareidy commented Oct 1, 2024

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

  • Is this free of any warnings or errors in the RST?
  • Did you run a spell-check?
  • Did you run a grammar-check?
  • Are all the links working?
  • Are the facets and meta keywords accurate?

Copy link

netlify bot commented Oct 1, 2024

Deploy Preview for docs-c ready!

Name Link
🔨 Latest commit aae7635
🔍 Latest deploy log https://app.netlify.com/sites/docs-c/deploys/66fdab9fbfca460008d8f23d
😎 Deploy Preview https://deploy-preview-63--docs-c.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@mcmorisi mcmorisi left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Creates a ``mongoc_apm_callbacks_t`` to store callbacks
- Creates a ``mongoc_apm_callbacks_t`` instance to store callbacks

Copy link
Collaborator Author

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

@norareidy norareidy requested a review from kevinAlbs October 1, 2024 17:45
@kevinAlbs kevinAlbs requested review from eramongodb and removed request for kevinAlbs October 1, 2024 20:04
Comment on lines 39 to 43
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.
Copy link
Collaborator

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 using mongoc_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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Creates a ``mongoc_apm_callbacks_t`` structure to store callbacks
- Creates a ``mongoc_apm_callbacks_t`` object to store callbacks

Comment on lines 50 to 52
- 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the callback with the client
the list of callbacks in the ``mongoc_apm_callbacks_t`` object with the client

Copy link
Collaborator Author

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

Comment on lines 12 to 15
stats_t *context;

context = (stats_t *) mongoc_apm_server_opening_get_context (event);
context->server_opening_events++;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

Comment on lines 23 to 25
mongoc_client_t *client;
mongoc_apm_callbacks_t *cbs
stats_t stats = {0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
}

mongoc_cleanup ();

return EXIT_SUCCESS;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Missing EOF newline.

Copy link
Collaborator

@eramongodb eramongodb left a 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.

Comment on lines 69 to 71
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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
event callback function. The following table provides the name of
APM callback function. The following table provides the name of

Consistency.

@norareidy norareidy merged commit 14e0d91 into mongodb:standardization Oct 2, 2024
5 checks passed
@norareidy norareidy deleted the DOCSP-43082-cluster-monitoring branch October 2, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants