Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Status API

From MoodleDocs
Revision as of 02:51, 11 August 2016 by Brendan Heywood (talk | contribs)

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',
   );

}

Metric dependencies