Once a Monitor has been defined, we can start to define monitor tasks. Ideally these would be the code portion of the config entity and would reference the machine name of the config entity to allow grouping and enabling/disabling all of a monitor’s tasks as a group.
The tasks would be what is performed during cron jobs to determine the status of a monitor. They should be short, simple tasks that can easily be performed during a cron job session without causing timeouts or heavy load on the server. Ideas for this include:
- Checking a connection between Drupal and an endpoint can be established.
- Checking that an automated process completed successfully.
- Checking the status of the queue table (size, date + source of oldest entry, etc)
- Check that latest video was posted to homepage as expected
- …and more
To aid developers in creating their Monitor Tasks, a base class should be created that contains instantiations of default methods. Ideas for these methods include:
- Getters for the task’s Monitor config entity detail.
- Abstract class: runTask that will be run to determine the status of the task.
These tasks should include detail in their annotations that include the following values:
|
Machine name |
Description |
|---|---|
|
id |
Machine name for this task. |
|
monitor_type |
Machine name of associated Monitor |
|
monitor_task_group |
A machine name of a cron group to use for this task. Allows devs to split tests across cron jobs and only run them when they want rather than throwing everything into cron all the time. |
|
retry_threshold |
The amount of time to wait before retrying a failed task. This helps grants control and over the frequency that an endpoint of a task is queried given it is in an error state. Warning states will be processed as usual. |
Monitor Tasks will be the source of triggering Monitor Events. These events should be one of four:
- OK
- WARNING
- ERROR
-
PENDING
Checklist items
- Create plugin for Monitor Task Statuses - In progress
- Create base class with common Monitor Task methods - In progress
- Create PHP Unit tests for Monitor Task (as needed)
- Create function tests for Monitor Task (as needed and able)
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | system_monitor--add_system_monitor_task--3075951--4.patch | 14.29 KB | merauluka |
Comments
Comment #2
merauluka commentedComment #3
merauluka commentedComment #5
merauluka commentedAttached is a patch of the system monitor work. Ideally this should be reviewed in Gitlab using Merge requests, but those are not yet available.
https://git.drupalcode.org/project/system_monitor/compare/8.x-1.x...task...
Comment #6
robpowell@merauluka, are you sure you don't have to pass the service through the create factory method?
From a code review stand point, everything else looks good.
Comment #8
merauluka commentedI updated the service call, but I don't need to run the create methods unless I need to manipulate the values that are coming in.
If we need to do that later we can address it at that time.
Merged and marking as "fixed".
Comment #9
merauluka commented