Status API
Declaring a metric for a plugin
Each plugin can declare as many metrics as they want. Each metric extends a base class, and it also registered with the Status API via a hook in lib.php:
/admin/tool/task/lib.php:
function tool_task_define_metrics(){
return array(
'\tool_task\metric\cronlastrun',
'\tool_task\metric\scheduledtask',
);
}
Other plugins have done this via a static file the db directory, however it is important that the metrics registered with the system is dynamic and can change according to how moodle is configured. For instance auth_ldap could declare a bind test metric, but if the ldap auth is disabled then we don't want to know about the metric at all or show it in any reports or checks.
/admin/tool/task/lib.php:
function auth_ldap_define_metrics(){
return array(
'\auth_ldap\metric\bindlatency',
);
}