An enhancement to the APM implementation.
Here's how to get started. First, understand how I did the Command Monitoring implementation (CDRIVER-769), which is a precursor to this feature and has a very similar implementation to this one.
- Read the Command Monitoring Spec: https://github.com/mongodb/specifications/blob/master/source/command-monitoring/command-monitoring.rst
- Read application-performance-monitoring.page, mongoc-apm.h, and the monitoring-related parts of mongoc_cluster_run_command_internal, to understand how I implemented it.
- Look at a typical Command Monitoring test: https://github.com/mongodb/specifications/blob/master/source/command-monitoring/tests/insertOne.yml
- Read test-mongoc-command-monitoring.c, and in particular the test_all_spec_tests() function, which runs all the standard Command Monitoring tests.
Now do similar work for SDAM Monitoring. Add to mongoc-apm.h and .c:
- Events: mongoc_apm_server_changed_t, mongoc_apm_server_opening_t, mongoc_apm_server_closed_t, mongoc_apm_topology_changed_t, mongoc_apm_topology_opening_t, mongoc_apm_topology_closed_t, mongoc_apm_server_heartbeat_started_t, mongoc_apm_server_heartbeat_succeeded_t, mongoc_apm_server_heartbeat_failed_t.
- Make event-field accessors for these 9 event structs: mongoc_apm_server_changed_get_address and so on. About 20 functions in all.
- Typedef the 9 callback function pointer types: mongoc_apm_server_changed_cb_t, mongoc_apm_server_opening_cb_t, mongoc_apm_server_closed_cb_t, mongoc_apm_cb_topology_changed_cb_t, mongoc_apm_cb_topology_opening_cb_t, mongoc_apm_cb_topology_closed_cb_t, mongoc_apm_server_heartbeat_started_cb_t, mongoc_apm_server_heartbeat_succeeded_cb_t, mongoc_apm_server_heartbeat_failed_cb_t
- Add 9 function pointers to _mongoc_apm_callbacks_t: _mongoc_apm_callbacks_t.server_changed, etc.
- Make 9 callback registrar functions: mongoc_apm_set_server_changed_cb, etc.
- Add mongoc_apm_callbacks_t* apm_callbacks field to topology description and server description.
Start testing and implementing the events.
- Adapt test-mongoc-command-monitoring.c for the SDAM Monitoring events.
- Copy the JSON tests from the specs repo.
- Disable all test asserts except for mongoc_apm_server_changed_t, then implement that event in mongoc_server_description_handle_ismaster?
- Enable test asserts for mongoc_apm_server_opening_t, implement in mongoc_topology_description_add_server.
- Enable test asserts for mongoc_apm_server_closed_t, implement in _mongoc_topology_description_remove_server.
- Enable test asserts for mongoc_apm_topology_changed_t, implement at the end of _mongoc_topology_scanner_cb?
- Enable test asserts for mongoc_apm_topology_opening_t, implement in mongoc_topology_description_init.
- Enable test asserts for mongoc_apm_topology_closed_t, implement in mongoc_topology_description_destroy.
- Enable test asserts for mongoc_apm_server_heartbeat_started_t, implement in new function mongoc_server_description_heartbeat_started, called from mongoc_topology_scanner_node_setup?
- Enable test asserts for mongoc_apm_server_heartbeat_succeeded_t, implement in mongoc_server_description_handle_ismaster.
- Enable test asserts for mongoc_apm_server_heartbeat_failed_t, implement in mongoc_server_description_handle_ismaster.
Finally, update application-performance-monitoring.page with an SDAM Monitoring example.
- is depended on by
-
DRIVERS-296 Implement SDAM Monitoring spec
- Closed
-
PHPC-618 Implement SDAM Monitoring spec
- Closed
- is related to
-
CDRIVER-2811 Heartbeat succeeded/failed events have uninitialized duration
- Closed
- related to
-
CDRIVER-2298 /TopologyDescription/readable_writable/pooled test sometimes fails
- Closed